var t;
var p;
var tm;

function stSwa() {
	if(gCook() <= 2) {
		sLft();
		shSwa();
		//var w = window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth: null;
		var h = window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight: null;

		if(h > 450) setInterval("keepUp()",50);
	}
}

function shSwa() {
	t = 100;
	mvUp(100000);
	fd(0);
}

function gCook() {
	var cn = "adshown=";
	var ca = document.cookie.split(';');
	var shw = 0;

	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(cn) == 0) shw = parseInt(c.substring(cn.length,c.length));
	}

	shw++;
	if(shw <= 2) document.cookie = "adshown="+shw+"; path=/;";

	return shw;
}

function hdSwa() {
	t = 0;
	fd(100);
}

function fd(amt) {
	if((t == 100 && amt <= t) || (t == 0 && amt >= t)) sFd(amt);
	if(amt == t && t==0) mvUp(-1);

	amt += (t > 0)? 20:-20;

	if(tm!=null) clearInterval(tm);
	tm = setTimeout("fd("+amt+")", 10);
}

function sFd(amt) {
	var obj;
	
	if (document.layers) obj = document.layers.swa;
	else if (document.all) obj = document.all.swa;
	else if (document.getElementById) obj = document.getElementById("swa");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";

	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;

	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}

function sLft() {
	var w = 450;

	if (document.layers) document.layers.swa.left = ((window.innerWidth / 2) - (w / 2))+"px";
	else if (document.all) document.all.swa.style.left = ((document.body.offsetWidth / 2) - (w / 2))+"px";
	else if (document.getElementById) document.getElementById("swa").style.left = ((window.innerWidth / 2) - (w / 2))+"px";
}

function mvUp(amt) {
	if (document.layers) document.layers.swa.zIndex = amt;
	else if (document.all) document.all.swa.style.zIndex = amt;
	else if (document.getElementById) document.getElementById("swa").style.zIndex = amt;
}

function keepUp() {
	var obj = (document.all)? document.all.swa:document.getElementById("swa");
	var iebody = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
	var dsoctop = document.all? iebody.scrollTop : pageYOffset;

	if (document.all || document.getElementById) {
		obj.style.top = dsoctop+75+"px";
	}
}
