﻿function makehead()
{
	document.write('<head><style type="text/css"><!-- #sponsorAdDiv {position:absolute; height:1; width:1px; top:0; left:0;} --></style>');
	document.write('<script type="text/javascript">');
	document.write('adTime=20;chanceAd=1;');
	document.write('var ns=(document.layers);');
	document.write('var ie=(document.all);');	
	document.write('var w3=(document.getElementById && !ie);');
	document.write('var calunit=ns? "" : "px";');
	document.write('adCount=0;');
}

function initAd()
{
	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.sponsorAdDiv.style');
	else if(ns)	adDiv=eval('document.layers["sponsorAdDiv"]');
	else if(w3)	adDiv=eval('document.getElementById("sponsorAdDiv").style');
	randAd=Math.ceil(Math.random()*chanceAd);
        if (ie||w3)
        adDiv.visibility="visible";
        else
        adDiv.visibility ="show";
        winleft=0;
	wintop=25;
	goleft=1
	godown=goleft2=0;
	adDiv.width=jWidth;
	adDiv.height=jHeight;
	if(randAd==1) showAd();
}

function showAd()
{
if(adCount<adTime*10)
{
	adCount+=1;
	if (ie)
	{
		documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
		fdocumentWidth  =truebody().offsetWidth+truebody().scrollLeft-20;
		fdocumentHeight =truebody().scrollTop-20;
		fdocumentTop =truebody().offsetHeight-20;
	}	
	else if (ns)
	{
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
		fdocumentWidth=window.innerWidth+window.pageXOffset-20;
		fdocumentHeight=window.pageYOffset-20;
	} 
	else if (w3)
	{
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20;
		fdocumentWidth=self.innerWidth+window.pageXOffset-20;
		fdocumentHeight=window.pageYOffset-20;
	}
		if (goleft>0){
			if((winleft+400)<fdocumentWidth)
			{
				winleft=winleft+10;
			} else {goleft=0;godown=1;}
		} else if(godown>0) 
		{
			if((wintop+350)<fdocumentTop)		
			{
				wintop=wintop+10;
			}
			if (winleft>0)
			{
				winleft=winleft-20;				
			}else {godown=0;goleft2=1}
		} else if (goleft2>0){
			if((winleft+400)<fdocumentWidth)
			{
				winleft=winleft+10;
				if((wintop+350)!=fdocumentTop)		
				{
				wintop=fdocumentTop-350;
				}
			} else {goleft2=0;
				
			}
		} else {
			if((winleft+400)!=fdocumentWidth)
				{
					winleft=fdocumentWidth-400;
				}
			if((wintop+350)!=fdocumentTop)		
				{
				wintop=fdocumentTop-350;
				}
			}
		adDiv.left=winleft+calunit;
		adDiv.top =fdocumentHeight+wintop+calunit;
		setTimeout("showAd()",100);
	}
	else stayleft();
	//closeAd();
}
function stayleft()
{	if(adCount<adTime*100)adCount+=1;
	{
		if (ie)
	{
		documentWidth  =truebody().offsetWidth+truebody().scrollLeft-20;
		documentHeight =truebody().offsetHeight+truebody().scrollTop-20;
	}	
	else if (ns)
	{
		documentWidth=window.innerWidth+window.pageXOffset-20;
		documentHeight=window.innerHeight+window.pageYOffset-20;} 
	else if (w3)
	{
		documentWidth=self.innerWidth+window.pageXOffset-20;
		documentHeight=self.innerHeight+window.pageYOffset-20;
	}		
		winleft=documentWidth-jWidth;
		wintop=documentHeight-jHeight;
		adDiv.left=winleft+calunit;
		adDiv.top=wintop+calunit;
		adDiv.width=jWidth;
		adDiv.height=jHeight;
		setTimeout("stayleft()",100);
	}
}

function closeAd(){
if (ie||w3)
adDiv.display="none";
else
adDiv.visibility ="hide";
}

function truebody()
{
	return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function disp_ban()
{
	document.write("<object id='FlashObj' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0' width='100%' height='100%'>");
	document.write("<param name='movie' value='" + jImg + "'>");
	document.write("<param name='quality' value='high'>");
	document.write("<param name='menu' value='false'>");
	document.write("<param name='wmode' value='transparent'>");	
	document.write("<embed src='" + jImg + "' quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent' width='100%' height='100%' menu='false'></embed>");
	document.write("</object>");
}

function makehead2(){
	document.write('onload="initAd";');
	document.write('//End-->');
}
function makebody(){
	document.write('</script></head><body>');
	document.write('<div id="sponsorAdDiv" style="visibility:hidden;">');
}
function makebody2(){
	document.write('</div></body>');
}
function FlashObj_DoFSCommand(command,args)
{
  var Site = "http://www.bingoliner.co.uk/?cid=" + jCid;
  if (command=="flash") {window.open(Site)}
}

function HookEvent()
{
	document.write("<script id=\"fscommandscript\" for=\"FlashObj\" event=\"FSCommand(command,args)\">");
	document.write("if(document.all)");
	document.write("{");
	document.write("	FlashObj_DoFSCommand(command,args);");
	document.write("	}");
	document.write("	</script>");
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function cookied() {
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 30 * 60 * 1000);
	var visits = getCookie("counter");
	if (!visits) {
  	return null;
	} else {
  	return true;
  	} 	
}

if (!cookied()  || true ){
makehead();
makehead2();
makebody();
disp_ban();
HookEvent();
makebody2();
}
