var timer;
var h = -750;	// set this to the same value of the top property for the pa div in the style sheet
var w = 425;	// 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 t = 50;	// set this to the actual pixel distance from the top where you want the pa div to be at the end of the descent
var blnClose = false;

function OpenRadio() {
    if (blnClose == false) {
        window.open ("radio.aspx","Radio","menubar=0,resizable=0,width=618,height=523");
        document.getElementById("pa").style.display = "none"
    }
}        

function OpenRadio1() {
    window.open ("radio.aspx","Radio","menubar=0,resizable=0,width=278,height=264");
    document.getElementById("pa").style.display = "none"
}        
    
function startAp() {

    //if (readCookie('radio') == 'no')
    //    return;

	setLeft();

	if (document.layers) document.layers.pa.display = "block";
	else if (document.all) document.all.pa.style.display = "block";
	else if (document.getElementById) document.getElementById("pa").style.display = "block";
	showAp();
}

function hideAp() { 
    blnClose = true;
	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';
}

function StopShowingAp() {
    blnClose = true;
    createCookie('radio', 'no', 31);
    hideAp()
}

function showAp() { 
	state=typeof tPos;
	if(state=='undefined') tPos = h;
	if(tPos < t) { 
		tPos+=5;
		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) - (w / 2))+"px";
	else if (document.all) document.all.pa.style.left = ((document.body.offsetWidth / 2) - (w / 2))+"px";
	else if (document.getElementById) document.getElementById("pa").style.left = ((window.innerWidth / 2) - (w / 2))+"px";
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	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(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
