ADstatus="Y";

function getCookie(theName){
	theName += "=";
	theCookie=document.cookie+";";
	start=theCookie.indexOf(theName);
	if (start!=-1){
		end=theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start+theName.length,end));
	}
	return false;
}

function setCookie(theName,theValue,theDay){
	if ((theName!=null) && (theValue!=null)){
		expDay="Wed, 01 Jan 2020 18:56:35 GMT";
		if (theDay!=null){
			theDay=eval(theDay);
			setDay=new Date();
			setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
			expDay=setDay.toGMTString();
		}
		document.cookie=theName+"="+escape(theValue)+";expires="+expDay;
		return true;
	}
	return false;
}

function AllAD(){
	document.write('<object ID="flashlayer" name="specialAD" ');
	document.write('classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write('codebase="http://active.macromedia.com/flash/cabs/swflash.cab#version=6,0,0,0" ');
	document.write('STYLE="POSITION: absolute" ');
	document.write('width="' + flash_width + '" height="' + flash_height + '">');
	document.write('<PARAM NAME="movie" VALUE="' + flash_file + '">');
	document.write('<param name="loop" value="true">');
	document.write('<param NAME="wmode" VALUE="transparent">');
	document.write('</OBJECT>');
	markX=0;
	markY=flash_y_pos;
	if (!document.all) document.all=document;
	if (!document.all.flashlayer.style) document.all.flashlayer.style=document.all.flashlayer;
	flayer=document.all.flashlayer.style;
	document.write('<DIV id="MarkImg" style="position:absolute;" align="center">');
	document.write('<a href="' + link_url + '" target="_blank">');
	document.write('<img src="' + mark_file + '" name="waterimg" border="0" width="' + mark_width + '" height="' + mark_height + '">');
	document.write('</a><br>');
	document.write('<a href="javascript:watchagain();"><img src="' + watchAgainPic + '" border="0" width=58 height=14></a>');
	document.write('</DIV>');
	markwW=mark_width;
	markwH=mark_height;
	markwX=-1000;
	markwY=mark_y_pos;
	if (!document.all.MarkImg.style) document.all.MarkImg.style=document.all.MarkImg;
	wMark=document.all.MarkImg.style;
	wMark.width=markwW;
	wMark.height=markwH;
	markMe();
}

markRefresh=10;
FlashStatueCheck=100;
navDOM=window.innerHeight;

function playstatus(){
	if (!document["specialAD"].IsPlaying()){
		markwX=100;
		ADstatus="N";
	}
	setVals();
}

function showstatus(){
	markwX=100;
	ADstatus="N";
	setVals();
}

function watchagain(){
	ADstatus="Y";
	flashCheck=setInterval("playstatus()",FlashStatueCheck);
	if (document["specialAD"].IsPlaying()){
		document["specialAD"].StopPlay();
		document["specialAD"].GotoFrame(1);
	}
	document["specialAD"].Play();
}

function setVals() {
	barW=0;
	barH=0;
	if (navDOM) {
		if (document.height>innerHeight) barW=20;
		if (document.width>innerWidth) barH=20;
	} else {
		innerWidth=document.body.clientWidth;
		innerHeight=document.body.clientHeight;
	}
	poswX=((innerWidth-markwW)-barW)*(markwX/100);
	poswY=180;
	if (ADstatus=="Y") {
		flayer.left=((innerWidth-barW)/2)-flash_x_shift;
		flayer.top=markY;
	}else if (ADstatus=="N"){
		flayer.left=-1400;
		flayer.top=markY;
	}
}

function wRefresh(){
	wMark.left=poswX+(navDOM?pageXOffset:document.body.scrollLeft);
	wMark.top=poswY+(navDOM?pageYOffset:document.body.scrollTop);
}

function markMe(){
	setVals();
	window.onresize=setVals;
	if (ADstatus=="Y")
		flashCheck=setInterval("playstatus()",FlashStatueCheck);
	else
		showstatus();
}

markID=setInterval("wRefresh()",markRefresh);

if (navigator.appName == "Microsoft Internet Explorer"){
	if (getCookie(cookie_name)){
		if (getCookie(cookie_name) == 1){
			tempnum = parseInt(getCookie(cookie_name));
			setCookie(cookie_name,tempnum+1,2);
		}	else {
			ADstatus = "N";
		}
	} else {
		setCookie(cookie_name,1,2);
	}
	AllAD();
}

