// This values can be overwritten at affilate script-snippet!!!
// Do not modify anything in this script!!!

var ad_af = ''; // affiliate-id
var ad_baseDomain = ''; // domain for cookie, empty = default, set .domain.tld for all subdomains and domain, too
var ad_last_adServer = '';
var ad_rc = ""; // Region Code, e.g. 7 for NRW (GER)
var ad_cc = "10"; // 10 = Germany (changes after db update!!!!)
var ad_cc_shortcut = "DE"; // Germany Shortcut
var ad_clickcount = 1;
var ad_server_base = "target.ergebnis-dienst.de/js/";
var ad_server = '';
var ad_containerPrefix = 'wac_';
var ad_category = '';
var ad_mark = '';

function ad_detect()
{
	var proto;
	
	if (document.location.protocol=='https:')
	{
		proto = 'https://';
	}
	else
	{
		proto = 'http://';
	}

	var cookieVal = ad_readCookie("cc");
	var parts = Array();
	
	if (cookieVal != null)
	{
		parts = cookieVal.split('-');
	}
	
	if (typeof parts[0] != 'undefined')
	{
		ad_clickcount = parts[0];
		ad_clickcount++;
	}
	else
	{
		parts[0] = 1;
	}
	
	var load_cc = true;
	if (typeof parts[1] != 'undefined')
	{
		ad_cc_shortcut = parts[1];
		if (ad_cc_shortcut != '')
		{
			load_cc = false;
		}
	}
	else
	{
		parts[1] = 'DE';
	}

	if (typeof parts[2] != 'undefined')
	{
		ad_cc = parts[2];
	}
	else
	{
		parts[2] = 11;
	}
	
	if (typeof parts[3] != 'undefined')
	{
		ad_rc = parts[3];
	}
	else
	{
		parts[3] = 0;
	}
	
	
	if (load_cc == true)
	{
		var initServer;
		initServer = proto+ad_server_base+"detect.js.php";
		initServer += "?af="+ad_af+"";
		if (ad_active == 1)
		{
			document.write('<scr'+'ipt src="'+initServer+'"></scr'+'ipt>');
		}
		
	}

}

function ad_load_manager()
{
	if (ad_active == 1)
	{
		document.write('<scr'+'ipt type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"><'+'/scr'+'ipt>');
	}
}

function ad_activate(site_id)
{
	if (ad_active == 1)
	{
		GS_googleAddAdSenseService(site_id);
		GS_googleEnableAllServices();
	}
}

function ad_fetch()
{
	if (ad_active == 1)
	{
		GA_googleFetchAds();
	}
}

function ad_fill(ad_id)
{
	if (ad_active == 1)
	{
		GA_googleFillSlot(ad_id);
	}
}

function ad_slot(site_id, ad_id)
{
	if (ad_active == 1)
	{
		GA_googleAddSlot(site_id, ad_id);	
	}
}

function ad_createCookie(name,value,days,domain)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	if (domain)
	{
		var domainAd ="; domain="+domain;
	}
	else var domainAd = "";
	document.cookie = name+"="+value+expires+domainAd+"; path=/";
}

function ad_readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function ad_eraseCookie(name)
{
	ad_createCookie(name,"",-1);
}

function ad_at(ad_id)
{
//	document.write(ad_id);
	if (ad_id > 0)
	{
		var m3_u = (location.protocol=='https:'?'https://ads.clubportal.at/www/delivery/ajs.php':'http://ads.clubportal.at/www/delivery/ajs.php');
		var m3_r = Math.floor(Math.random()*99999999999);
		if (!document.MAX_used) document.MAX_used = ',';
		document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
		document.write ("?zoneid="+ad_id+"&amp;target=_blank");
		document.write ('&amp;cb=' + m3_r);
		if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
		document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
		document.write ("&amp;loc=" + escape(window.location));
		if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
		if (document.context) document.write ("&context=" + escape(document.context));
		if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
		document.write ("'><\/scr"+"ipt>");	
	}
}


