var xmlHttp;
var setRefT;
var activePopup = new Array;

if (dom){
	document.onmousedown = hide();
	document.oncontextmenu = function () {
	return false;
	} 
	window.onmousedown = hide();
	window.oncontextmenu = function () {
	return false;
	}
}

function hide(){
	return false;
}

function stateChanged() 
{ 
	var loadstat='<img src="modules/SpotTVR/admin/loading.gif" alt="Loading..." title="Loading..."><br/><b>Loading.....</b>';
	if (xmlHttp.readyState==4 && xmlHttp.status == 200){ 
		getElementIDFix("playerArea").innerHTML=xmlHttp.responseText;
		evalAjaxContent(xmlHttp.responseText);
	} else if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3){ 
		getElementIDFix("playerArea").innerHTML=loadstat;
	}
}

function popupStateChanged() 
{ 
	var loadstat='<img src="modules/SpotTVR/admin/loading.gif" alt="Loading..." title="Loading..."><br/><b>Loading.....</b>';
	if (xmlHttp.readyState==4 && xmlHttp.status == 200){ 
		getElementIDFix("popup_playerArea").innerHTML=xmlHttp.responseText;
		evalAjaxContent(xmlHttp.responseText);
	} else if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3){ 
		getElementIDFix("popup_playerArea").innerHTML=loadstat;
	}
}

function evalAjaxContent(content) { 
  while(true) {
    var sindex = content.indexOf('<script type="text/javascript">');
    if(sindex < 0) break;
	content = content.substring(sindex);
    var eindex = content.indexOf("</script>");
    eval(content.substring(content.indexOf('>')+1,eindex));
    content = content.substring(eindex+9, content.length);
  }     
}

/***********************************************************************************/


function showPlayer(url)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 

	showBox('playerArea');
	closePopup();

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 


function popupPlayer(path, title, w, h){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width='+w+',height='+h+',top='+wint+',left='+winl;
	
	closePopup();
	var newWindow=window.open(path, title, winprops);
	activePopup.push(newWindow);
	if (window.focus) {newWindow.focus()}
}

function closePopup(){
	for(var x=0; x<activePopup.length; x++){
		win = activePopup[x];
		if (win && win.open && (!win.closed)){
			win.close();
			activePopup.splice(x,1);
		}
	}
}

function showPopUpPlayer(url)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 

	showBox('popup_playerArea');
	xmlHttp.onreadystatechange=popupStateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
