function showMediaPlayer(url)
{
	var win = window.open(url, "gaamediaplayer", "height=695,width=987,status=yes,toolbar=no,menubar=no,location=no,left=12,top=0");
	win.focus();
}


function changeHomeTab(id) 
{
	document.getElementById("home_news").style.display = "none";
	document.getElementById("home_football").style.display = "none";
	document.getElementById("home_hurling").style.display = "none";
	document.getElementById("home_av").style.display = "none";
	
	document.getElementById("home_news_tab").className = "";
	document.getElementById("home_football_tab").className = "";
	document.getElementById("home_hurling_tab").className = "";
	document.getElementById("home_av_tab").className = "";

	document.getElementById(id).style.display = "block"
	document.getElementById(id + "_tab").className = "on";
}


Sarissa.callRemote = function(sFromUrl, oTargetElement, callback, id, rating, skipCache) {
	try{
		//Sarissa.updateCursor(oTargetElement, "wait");
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET", sFromUrl, true);
		function _handler() {
			if (xmlhttp.readyState == 4) {
				if (callback) {
					if (xmlhttp.responseText != null) {
						callback(id, rating, xmlhttp.responseText);
					};
				};
			};
		};
		xmlhttp.onreadystatechange = _handler;
		if (skipCache) {
			 var oldage = "Sat, 1 Jan 2000 00:00:00 GMT";
			 xmlhttp.setRequestHeader("If-Modified-Since", oldage);
		};
		xmlhttp.send("");
	}
	catch(e){
		Sarissa.updateCursor(oTargetElement, "auto");
		throw e;
	};
};

function RatingVote(id)
{
	var el = document.getElementById(id+"dropdown");
	var ret = el.value;
	alert
	Sarissa.callRemote("http://www.rte.ie/dynamic/rating/playerratings.aspx?url=" + id + "&rating=" + ret, document.getElementById(id+"dropdownHolder"), UpdateResults, id, ret) ;
}

function initScore(id)
{
	Sarissa.callRemote("http://www.rte.ie/dynamic/rating/playerratings.aspx?url=" + id, document.getElementById(id+"dropdownHolder"), initResults, id, "0") ;
}

function initResults(id, rating, val)
{
	var el = document.getElementById(id+"Score");
	var a = val.split(",");	
	
	if(a && !isNaN(parseInt(a[0])) && !isNaN(parseInt(a[1]))) {
		el.innerHTML = Math.round(a[0]*10/a[1])/10;
	}
}

function UpdateResults(id, rating, val)
{
	var el = document.getElementById(id+"Score");
	var drop = document.getElementById(id+"dropdownHolder");
	var a = val.split(",");	
	
	if(a && !isNaN(parseInt(a[0])) && !isNaN(parseInt(a[1]))) {
		el.innerHTML = Math.round(a[0]*10/a[1])/10;
		drop.innerHTML = "Rating: "+rating;
	}
}
