var timer;
var aph = -450;	// set this to the same value of the top property for the pa div in the style sheet
var apw = 350;	// set this to the same value of the width property for the pa div in the style sheet, smaller to move it to the right, larger to move it to the left
var apt = 100;	// set this to the actual pixel distance from the top where you want the pa div to be at the end of the descent

function startAp() {
	setLeft();
	
	if (document.cookie.indexOf('woadcookie=') == -1)
	    setTimeout('showAp()', 30000);
}

function hideAp() { 
	if (document.layers) document.layers.pa.visibility = 'hide';
	else if (document.all) document.all.pa.style.visibility = 'hidden';
	else if (document.getElementById) document.getElementById("pa").style.visibility = 'hidden';
	
	document.cookie = 'woadcookie=1';
}

function showAp() { 
    document.getElementById('pa').style.display = 'block';
	state=typeof tPos;
	if(state=='undefined') tPos = aph;
	if(tPos < apt) { 
		tPos+=25;
		if (document.layers) document.layers.pa.top = tPos+"px";
		else if (document.all) document.all.pa.style.top = tPos+"px";
		else if (document.getElementById) document.getElementById("pa").style.top = tPos+"px";
	}

	if(timer!=null) clearInterval(timer);
	timer = setTimeout("showAp()",10);
}

function getoPos() {
	if (document.layers) alert(document.layers.pa.top);
	else if (document.all) alert(document.all.pa.style.top);
	else if (document.getElementById) alert(document.getElementById("pa").style.top);
}

function setLeft() {
	if (document.layers) document.layers.pa.left = ((window.innerWidth / 2) - (apw / 2))+"px";
	else if (document.all) document.all.pa.style.left = ((document.body.offsetWidth / 2) - (apw / 2))+"px";
	else if (document.getElementById) document.getElementById("pa").style.left = ((window.innerWidth / 2) - (apw / 2))+"px";
}

function addLoadEvent(func) { 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function() { 
      if (oldonload) { 
        oldonload(); 
      } 
      func(); 
    } 
  } 
} 
	 
addLoadEvent(startAp); 
