// JavaScript Document

function roundAccuracy(num, acc)
{

	var factor = Math.pow(10,acc);
    return Math.round(num*factor)/factor;
}

function populateParentOptions(id, option) {
	var list = $(option);
	list[list.length] = new Option("Page", id);
	var children = $(id).getElementsByTagName('div');
	for (i = 0; i < children.length; i++) {
		list[list.length] = new Option(children[i].id, children[i].id);
	}
}

function OpenListenLive(){
	var mypage = "mediaplayer.php";
	var w = 743;
	var h = 265;
	var myname = "iPlayer";
	var winl = 100; //(screen.width-w)/2;
	var wint = 100; //(screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
	win=window.open(mypage,myname,settings)
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function OpenMusicRatings(id){
	var mypage = "mediaplayer_musicratings.php?id="+id;
	var w = 743;
	var h = 265;
	var myname = "iPlayer";
	var winl = 100; //(screen.width-w)/2;
	var wint = 100; //(screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
	win=window.open(mypage,myname,settings)
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


function logout() {
	var xmlHttp = new Ajax.Request("checklogin.php", 
	{method: "post",
		onComplete: function(request) {
			$("usr_box").innerHTML = request.responseText;
			location.href="index.php";
		}
	});
}

function login() {
	if((!$F("uname")) || $F("uname").match(/\d+/g)) {
		$("uname").value = "";
		//Effect.Shake('loginbox');
	} else {
		var xmlHttp = new Ajax.Request("checklogin.php", 
		{method: "post",
			postBody: "login_nm="+$F('uname')+"&login_pw="+$F('pwd'),
			onComplete: function(request) {
				//alert(request.responseText);
				$('usr_box').innerHTML = request.responseText;
				location.href="index.php";

			}
		});
	}
};

function getClientWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}