// Overlay Ad Manager V2.0 to run with OAS tags
// keep cookie alive for 1 month not required
var nextmonth = new Date()
nextmonth.setMonth(nextmonth.getMonth()+1);
var allcookies = document.cookie;
if(!allcookies) {
	document.cookie="c4ADcontrol=0;path=/; expires=" + nextmonth.toGMTString();
} else {
	c4ADcookie = allcookies.indexOf("c4ADcontrol=");
	if(c4ADcookie==-1){
		document.cookie="c4ADcontrol=0;path=/; expires=" + nextmonth.toGMTString();
	}
	if(c4ADcookie!=-1){
	s = c4ADcookie + 12;
	e = allcookies.indexOf(";", s);
	c4ADcookie = allcookies.substring(s,((e!=-1)?e:allcookies.length));
	increments  = Number(c4ADcookie);

	if(increments==0) {
		//set position
		if(OAS_listpos!="") {
		OAS_listpos+=",Middle";
		} else {
		OAS_listpos+="Middle";
		}
		increments=2;
	} else if(increments!=0) {
		increments--;
	}
	document.cookie="c4ADcontrol="+increments+";path=/; expires=" + nextmonth.toGMTString();
	}
}
if (screen.width>1000 && screen.width<1152)
{
OAS_listpos+=",x07";
}
if (screen.width>=1152)
{
OAS_listpos+=",x08";
}



appendListPos("Bottom");
appendListPos("Middle1");
appendListPos("Left");
appendListPos("Left1");
appendListPos("Left2");
appendListPos("Left3");

appendListPos("Right");
appendListPos("Right1");
appendListPos("Right2");
appendListPos("x05");
appendListPos("x06");
appendListPos("x09");
OAS_listpos+=",x10";


//
c4vertical = "/bigbrother/" 
c4url = document.location.href;
if(c4url.indexOf(c4vertical)!=-1) {
	endURL = c4url.split(c4vertical)[1];
	if(endURL=="" || endURL=="undefined") {
		endURL="index.html"
	}
	if(endURL.charAt(endURL.length-1)=="/") {
		endURL+="index.html"
	}  
	if(c4url.indexOf("geo.channel4.com/")!=-1 || c4url.indexOf("cms.channel4.com/")!=-1 || c4url.indexOf("test.channel4.com/")!=-1 || c4url.indexOf("www.channel4.com/")!=-1 || c4url.indexOf("dev.channel4.com/")!=-1) {
	OAS_sitepage="bbwww."+c4vertical.substring(1,c4vertical.length-1)+".channel4.com/"+endURL
} 
} else {
OAS_sitepage = c4url;
}
if(OAS_sitepage.indexOf("?")!=-1) {
OAS_sitepage = OAS_sitepage.substring(0,OAS_sitepage.indexOf("?"))
}