adTime=10000;  // seconds ad reminder is shown
chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime)

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;

var adDiv;
var adDiv2;
var closeBx;
var showvideo = 0;
var city = 0;

var preferredBoxWidth = 640;
var preferredBoxHeight = 370;

var divTxt = '';
var divTxt1 = '<iframe src="components/jw_video/jw_embed_partner.php?&ad_id=';
var divTxt2 = '" scrolling="no" bgcolor="#303030" frameborder="0" height="'+preferredBoxHeight+'" width="'+preferredBoxWidth+'"></iframe>';

function initAd(ad_id, city_id){
	showvideo = ad_id;
	city = city_id;
	divTxt = divTxt1 + showvideo + divTxt2;
	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');

	if(ie)		adDiv2=eval('document.all.sponsorAdDiv2.style');
	else if(ns)	adDiv2=eval('document.layers["sponsorAdDiv2"]');
	else if(w3)	adDiv2=eval('document.getElementById("sponsorAdDiv2").style');

	if(ie)		closeBx=eval('document.all.closeBtn.style');
	else if(ns)	closeBx=eval('document.layers["closeBtn"]');
	else if(w3)	closeBx=eval('document.getElementById("closeBtn").style');

	closeVideoBox();

	randAd=Math.ceil(Math.random()*chanceAd);

    if (ie||w3)
        adDiv.visibility="visible";
    else
        adDiv.visibility ="show";
		
	growAd();
	if(randAd==1) showAd();
	}
	
var increase = 0;
var increasey = 0;

function growAd() {
	if(increase > preferredBoxWidth) {
		increase = 0;
		increasey = 0;
		adDiv2.width = preferredBoxWidth+calunit;
		adDiv2.height =preferredBoxHeight+calunit;
		document.getElementById("sponsorAdDiv2").innerHTML = divTxt;
		setTimeout("finishBox()",10);
		}
	else {
		increase += 10;
		increasey += 10 * preferredBoxHeight / preferredBoxWidth;
		setTimeout("adSize()",5);
		}
	}
function adSize() {
	adDiv.width = increase+calunit;
	adDiv.height = increasey+calunit;
	growAd();
	}

function finishBox() {
	adDiv2.visibility="visible";
	closeBx.visibility="visible";
	//adDiv.background = "transparent";
	return;
	}
function showAd(){
	if(adCount<adTime*10){
		adCount+=1;
		if (ie){
			documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
			documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
			}
		else if (ns){
			documentWidth=window.innerWidth/2+window.pageXOffset-20;
			documentHeight=window.innerHeight/2+window.pageYOffset-20;
			}
		else if (w3){
			documentWidth=self.innerWidth/2+window.pageXOffset-20;
			documentHeight=self.innerHeight/2+window.pageYOffset-20;
			}
		adDiv.left=documentWidth-(preferredBoxWidth/2)+calunit;adDiv.top =documentHeight-(preferredBoxHeight/2)+calunit;
		setTimeout("showAd()",10);
		}
	else 
		closeAd();
	}
	
function closeAd(){
	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');

	if(ie)		adDiv2=eval('document.all.sponsorAdDiv2.style');
	else if(ns)	adDiv2=eval('document.layers["sponsorAdDiv2"]');
	else if(w3)	adDiv2=eval('document.getElementById("sponsorAdDiv2").style');

	if(ie)		closeBx=eval('document.all.closeBtn.style');
	else if(ns)	closeBx=eval('document.layers["closeBtn"]');
	else if(w3)	closeBx=eval('document.getElementById("closeBtn").style');
	
	//document.getElementById("sponsorAdDiv").innerHTML = " ";
	document.getElementById("sponsorAdDiv2").innerHTML = " ";

	increase = 0;
	increasey = 0;
	adDiv.visibility ="hidden";
	adDiv2.visibility="hidden";
	closeBx.visibility="hidden";
	adDiv.width = 0+calunit;
	adDiv.height =0+calunit;
	adDiv.left = 0+calunit;
	}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function closeVideoBox() {
	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');

	if(ie)		adDiv2=eval('document.all.sponsorAdDiv2.style');
	else if(ns)	adDiv2=eval('document.layers["sponsorAdDiv2"]');
	else if(w3)	adDiv2=eval('document.getElementById("sponsorAdDiv2").style');

	if(ie)		closeBx=eval('document.all.closeBtn.style');
	else if(ns)	closeBx=eval('document.layers["closeBtn"]');
	else if(w3)	closeBx=eval('document.getElementById("closeBtn").style');
	
	//document.getElementById("sponsorAdDiv").innerHTML = " ";
	document.getElementById("sponsorAdDiv2").innerHTML = " ";

	increase = 0;
	increasey = 0;
	adDiv.visibility="hidden";
	adDiv2.visibility="hidden";
	closeBx.visibility="hidden";
	adDiv.width = 0+calunit;
	adDiv.height =0+calunit;
	adDiv.left = 0+calunit;
	}

//onload=initAd;

