var http = getHTTPObject();
var seqSchedNumber = 0; //ppv sequence page
var nottopstyle = false; //ppv sequence page
//-------------------------------------------------------------------------------------
  function getHTTPObject()
  {
    var xmlhttp;
    try{xmlhttp = new XMLHttpRequest(); /* e.g. Firefox */}
    catch(e)
    {
      try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */}
      catch (e)
      {
        try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */}
        catch (e)
        {
          xmlhttp = false;
        }
      }
    }
    return xmlhttp;
  }

function getPlayer(vars){
    var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var url="getPlayer.php" + "?rand=" + myRandom + vars;
    http.open("GET", url, true);
    http.onreadystatechange = showPlayer;
    http.send(null);
  }

 function showPlayer()
 {
 	if (http.readyState == 4){
	  document.getElementById("thePlayer").innerHTML = http.responseText;
    }
 }

//JAY//FOR PREVENTING DOUBLE CLICKING ON SUBMIT BUTTONS
var justHidden;
function submitOnce(obj){
	justHidden = obj;
	obj.style.visibility = "hidden";
	try{var loadingBar = document.getElementById("please_wait");loadingBar.style.visibility = "visible";}catch(e){/*continue*/}
}
function returnToNormal(){
	try{justHidden.style.visibility = "visible";}catch(e){/*continue*/}
	try{var loadingBar = document.getElementById("please_wait");loadingBar.style.visibility = "hidden";}catch(e){/*continue*/}
}
//JAY//

//JAY//FOR LISTING UNASSIGNED/ASSIGNED PROGRAMMES IN DROP DOWN MENU
function getMediaList(vars,divId){
	mediaListArea = divId;
    var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var url="/getMediaList.php" + "?rand=" + myRandom + vars;
    http.open("GET", url, true);
    http.onreadystatechange = showMediaList;
    http.send(null);
  }
  var mediaListArea = "";
 function showMediaList()
 {
 	if (http.readyState == 4){
	  document.getElementById(mediaListArea).innerHTML = http.responseText;
    }
 }//JAY//

//JAY//FOR LISTING UNASSIGNED/ASSIGNED PROGRAMMES IN DROP DOWN MENU
function getProgrammeForPpv(vars){
    var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var url="getProgrammeForPpv.php" + "?rand=" + myRandom + vars;
    http.open("GET", url, true);
    http.onreadystatechange = showProgrammeForPpv;
    http.send(null);
  }

 function showProgrammeForPpv()
 {
 	if (http.readyState == 4){
	  document.getElementById("programmeList").innerHTML = http.responseText;
    }
 }//JAY//

function getDuration(f,cli){
	var theDur = f.programmeSource.value;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster
	//alert("sending " + URLencode(theDur) + " " + cli);
	var url="/getDuration.php" + "?rand=" + myRandom + "&id=" + URLencode(theDur) + "&cid=" + cli;
	http.open("GET", url, true);
	http.onreadystatechange = setDurationsAlt;
	http.send(null);

  }

//JAY//MODIFIED FOR SUB-CLIENTS and Different QUALITIES
var thisquality;
 function getDuration1(f,cli,quality){
	thisquality = (quality!="undefined")? "programmeSource"+quality : "programmeSource";
	var theDur = document.getElementById(thisquality).options[document.getElementById(thisquality).selectedIndex].value;
	//var theDur = f.programmeSource.value;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var url="/getDuration1.php" + "?rand=" + myRandom + "&id=" + theDur + "&cid=" + cli;
	http.open("GET", url, true);
	http.onreadystatechange = setDurationsAlt;
	http.send(null);

  }//JAY//

 //JAY//MODIFIED FOR SUB-CLIENTS
 /*function getDuration1(f,cli){
	var theDur = f.programmeSource.value;
	var myRandom=parseInt(Math.random()*99999999);  // cache buster
	var url="/getDuration1.php" + "?rand=" + myRandom + "&id=" + theDur + "&cid=" + cli;
	http.open("GET", url, true);
	http.onreadystatechange = setDurationsAlt;
	http.send(null);

  }*///JAY//

//JAY//For ppv sequence page
function addProgramme(progNo,isAdvert)
{
  seqSchedNumber += 1;
  var ni = document.getElementById('currentList');
  var currentProgramme = document.getElementById('progItem_' + progNo);
  
  //check if rating is different
	//the prog in question
	var progRating = document.getElementsByName(progNo + '_rating')[0].value;
	//now iterate thru other prog ratings
	var frm = document.formPPV;
	var j = 0;
	for (i = 0; i <= frm.elements.length -1; i++)
	{
		//check rating are the same
		if(frm.elements[i].name == "progRatings[]")
		{
			if(frm.elements[i].value != progRating){
				alert("This programme has a different rating to the others already in the sequence. You can only have programmes with the same rating as programmes already in the sequence.");
				return false;
			}else{
				//continue
			}
	  	}
	   	
	 }
  
  
  
  
  
  var newdiv = document.createElement('div');
  //We have to make a parent or it crashes trying to delete itself
  var divIdName = 'parentCurrProgItem_' + seqSchedNumber + '_' + progNo;
  newdiv.setAttribute('id',divIdName);

  //  newdiv.setAttribute('onClick','');
  ni.appendChild(newdiv);

  newdiv.style.cssText = "margin: 0px; padding: 0px;";

  var childdiv = document.createElement('div');
  var divIdName = 'currProgItem_' + seqSchedNumber + '_' + progNo;
  childdiv.setAttribute('id',divIdName);

  var backgroundColor = (isAdvert == 0) ? '11FF11' : 'FF0000';

  //Handle double borders
  if(nottopstyle)
  {
	var style = "border-left: 2px solid #000; border-right: 2px solid #000; border-bottom: 2px solid #000; height:40px; margin:0px; padding:23px 0px 0px 3px; font-size:10px; background-color:#" + backgroundColor + ";"
  }
  else
  {
	 var style = "border: 2px solid #000; height:40px; margin:0px; padding:23px 0px 0px 3px; font-size:10px; background-color:#" + backgroundColor + ";"
	 nottopstyle = true;
  }
 // childdiv.setAttribute('style',style);
  newdiv.appendChild(childdiv);

  //Have to do document.getElement as ie doesn't like setAttribute for Style.
  var childStyle = document.getElementById(divIdName)
  childStyle.style.cssText = style;

  //Stick in the content now:

  var curTitleDiv = document.createElement('div');
  var curTitleDivClass = 'progItemName';
  curTitleDiv.setAttribute('class',curTitleDivClass);

  //IE Hack
  curTitleDiv.setAttribute('className',curTitleDivClass);
  curTitleDiv.innerHTML = document.getElementById('progItemName_' + progNo).innerHTML;
  childdiv.appendChild(curTitleDiv);

  var curLengthDiv = document.createElement('div');
  var curLengthDivClass = 'progItemLength';
  curLengthDiv.setAttribute('class',curLengthDivClass);
  //IE Hack
  curLengthDiv.setAttribute('className',curLengthDivClass);
  curLengthDiv.innerHTML = document.getElementById('progItemLength_' + progNo).innerHTML;
  childdiv.appendChild(curLengthDiv);

  var curLengthDiv = document.createElement('div');
  var curLengthDivClass = 'progItemDelete';
  curLengthDiv.setAttribute('class',curLengthDivClass);
  //IE Hack
  curLengthDiv.setAttribute('className',curLengthDivClass);
  curLengthDiv.innerHTML = '<a href="#return" style="" onClick="removeProgramme(\'' + seqSchedNumber + '_' + progNo + '\',\'current\');">X</a>';
  childdiv.appendChild(curLengthDiv);

  var inputtype = document.createElement('input');
  inputtype.setAttribute('type','hidden');
  inputtype.setAttribute('name','progIds[]');
  inputtype.setAttribute('value',progNo);
  childdiv.appendChild(inputtype);

  var inputProgName = document.createElement('input');
  inputProgName.setAttribute('type','hidden');
  inputProgName.setAttribute('name','progNames[]');
  var progName = document.getElementsByName(progNo + '_name');
  inputProgName.setAttribute('value',progName[0].value);
  childdiv.appendChild(inputProgName);

  var inputProgDesc = document.createElement('input');
  inputProgDesc.setAttribute('type','hidden');
  inputProgDesc.setAttribute('name','progDescs[]');
  var progDesc = document.getElementsByName(progNo + '_desc');
  inputProgDesc.setAttribute('value',progDesc[0].value);
  childdiv.appendChild(inputProgDesc);

  var inputProgDuration = document.createElement('input');
  inputProgDuration.setAttribute('type','hidden');
  inputProgDuration.setAttribute('name','progDurations[]');
  var progDuration = document.getElementsByName(progNo + '_duration');
  inputProgDuration.setAttribute('value',progDuration[0].value);
  childdiv.appendChild(inputProgDuration);

  var inputProgRating = document.createElement('input');
  inputProgRating.setAttribute('type','hidden');
  inputProgRating.setAttribute('name','progRatings[]');
  var progRating = document.getElementsByName(progNo + '_rating');
  inputProgRating.setAttribute('value',progRating[0].value);
  childdiv.appendChild(inputProgRating);


  rebuildTitles();

}

function removeProgramme(progNo,type)
{
	var d = document.getElementById('parentCurrProgItem_' + progNo);
	var olddiv = document.getElementById("currProgItem_" + progNo);
	olddiv.innerHTML = '</div><a id="return"></a><div>';
	d.removeChild(olddiv);
	rebuildTitles();
}

function rebuildTitles()
{
	var titleOption = document.getElementById('selectTitle');
	titleOption.options.length=0
	titleOption.options[0] = new Option("Select Programme","NaN");
	var hiddenfields = new Array();
	var hiddenfieldIds = new Array();
	
	var ratingsValue = 0;
	var frm = document.formPPV;
	var j = 0;
	for (i = 0; i <= frm.elements.length -1; i++)
	{
    	//check rating are the same
    	if(frm.elements[i].name == "progRatings[]")
		{
			if(ratingsValue==0){ratingsValue = frm.elements[i].value;}
    		if(frm.elements[i].value != ratingsValue){
    			alert("A programme has a different rating to the others. You can only have programmes with the same rating in the same sequence.");
    		}else{
    			//continue search
    		}
      	}
    	
    	if(frm.elements[i].name == "progIds[]")
		{
    		hiddenfieldIds[j] = frm.elements[i].value;
      	}
	   	if(frm.elements[i].name == "progNames[]")
	   	{
	   		hiddenfields[j] = frm.elements[i].value;
	   		++j;
	   	}
	   	
	 }

//	alert(dump(hiddenfields));
	for(i=0;i<(hiddenfields.length);i++) {
	//	alert(hiddenfields[i]);
		titleOption.options[i+1] = new Option(hiddenfields[i],hiddenfieldIds[i]);
		if((arguments[0]) && (hiddenfieldIds[i] == defaultProgramme))
		{
			titleOption.options[i+1].selected = true;
		}
		else if(hiddenfieldIds[i] == defaultProgramme)
		{
			titleOption.options[i+1].selected = true;
		}
	}
}

function detectTitleChange(option)
{
	var customTitle = document.getElementById("customTitle");
	var Title = document.getElementsByName(option.value + "_name")[0].value;
	var customDesc = document.getElementById("customDesc");
	var Desc = document.getElementsByName(option.value + "_desc")[0].value;
	customTitle.value = Title;
	customDesc.value = Desc;
	defaultProgramme = option.value;
}
//JAY//
//JAY//
function highlightColour(theel,colour) {
	if(colour!=null){
		theel.style.backgroundColor=colour;
	}else{
		theel.style.backgroundColor='#fff';
	}
}
function unhighlightColour(theel,colour) {
	if(colour!=null){
		theel.style.backgroundColor=colour;
	}else{
		theel.style.backgroundColor='';
	}
}
//JAY//

 function URLencode(sStr) {
    return escape(sStr)
       .replace(/\+/g, '%2B')
          .replace(/\"/g,'%22')
             .replace(/\'/g, '%27');
  }


function setDurationsAlt() {
	if(http.readyState == 4){
		//alert("ok so set the durations now with " + http.responseText);
		thisduration = http.responseText;
		var theForm = document.forms['mainForm'];
		//var thePath = theForm.programmeSource.value;
		//var thePath = theForm.thisquality.value;
		var thePath = document.getElementById(thisquality).options[document.getElementById(thisquality).selectedIndex].value;
		var ind = thePath.lastIndexOf('\\');
		var pathPart = thePath.substring(0,ind);
		var theFilename = thePath.substring(ind+1,thePath.length);
		//alert("path " + thePath + " last index = " + ind + " file " + theFilename);
		//JAY//theForm.pathExt.value = pathPart;
		//JAY//theForm.fileName.value = theFilename;
		if (thisduration != undefined)
		{
			theForm.durat.value = thisduration;
			timeparts = thisduration.split(":");
			theForm.hours.selectedIndex = timeparts[0];
			theForm.minutes.selectedIndex = timeparts[1];
			theForm.seconds.selectedIndex = timeparts[2];
			setHyperlink(theForm);
		}
		else
		{
			theForm.durat.value = "00:00:00";
			thisduration = "00:00:00";
			timeparts = thisduration.split(":");
			theForm.hours.selectedIndex = timeparts[0];
			theForm.minutes.selectedIndex = timeparts[1];
			theForm.seconds.selectedIndex = timeparts[2];
		}
	}else{
		/*do nothing*/
	}
}


function setSubs(id)
{
	//go fetch child channels from database
	var myRandom=parseInt(Math.random()*99999999);  // cache buster
	  var url='checkSubChannels.php?id=' + id + "&rand=" + myRandom;
    http.open("GET", url, true);
    http.onreadystatechange = setSubValues;
    http.send(null);
}

  function setSubValues(){
    if (http.readyState == 4){
  	  var obArr = new Array();
	  var inStr = http.responseText;
	  obArr = inStr.split(",");
	  for (i=0;i<obArr.length;i++)
	  {
		var theob;
		theOb = document.forms[0].getElementById(obArr[i]);
		theOb.checked = true;
	  }
	  //alert (obArr.length + " " + obArr[0]);
    }
  }

var tabs = new Array("channels","schedule","features","search","myaccount");

var channelstab = 0;
var scheduletab = 0;
var featurestab = 0;
var searchtab = 0;
var myaccounttab = 0;

function checkclient(f) {
	if(!f.clientFirstName.value)  {
		alert("Please enter a first name.");
		return false;
	}
	if(!f.clientLastName.value) {
		alert("Please enter a last name.");
		return false;
	}
	if(!f.clientCompany.value) {
		alert("Please enter the company name.");
		return false;
	}
	return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function checksubscription(f)
{
	if (!f.subsName.value)
	{
		alert("The package must have a name.");
		return false;
	}

	if ((!f.subsAmt.value) || (!IsNumeric(f.subsAmt.value)))
	{
		alert("The cost cannot be blank and must be numeric.");
		return false;
	}

	return true;
}

function deleteme(f,whichone) {
	if(confirm("Are you sure you want to delete this entry?")) {
		f.deletethis.value=whichone;
		f.submit();
	}else{
		returnToNormal();
	}
}

function preview(whichone) {
	var w=window.open("preview.php?id=" + whichone,"preview","width=640, height=480, status=0, menunbar=0, menu=0");
	w.focus();
}

//JAY
function previewNEW(whichone) {
	var w=window.open("previewNEW.php?id=" + whichone,"preview","width=640, height=480, status=0, menunbar=0, menu=0");
	w.focus();
}
function previewppvNEW(whichone) {
	var w=window.open("preview.ppvNEW.php?id=" + whichone,"preview","width=640, height=480, status=0, menunbar=0, menu=0");
	w.focus();
}

function previewppv(whichone) {
	var w=window.open("preview.ppv.php?id=" + whichone,"preview","width=640, height=480, status=0, menunbar=0, menu=0");
	w.focus();
}
//JAY END

function help() {
	var w=window.open("http://help.gdbtv.com","help","width=800, height=600, status=1, menunbar=0, menu=0, scrollbars=1,resizable=1");
	w.focus();
}

function previewsched(f,thevar) {
	var theid = f[thevar].value;
	var w=window.open("preview.php?id=" + theid,"preview","width=640, height=480, status=0, menunbar=0, menu=0");
	w.focus();
}

function schedule(thedate,thetime,edit) {
	var w=window.open("insertprogramme.php?date=" + thedate + "&time=" + thetime + "&edit=" + edit,"schedule","width=540, height=300, status=0, menubar=0, menu=0, scrollbars=0");
	w.focus();
}

function viewSchedule(theid){
	var w=window.open("viewSched.php?id=" + theid,"schedule","width=850, height=680, status=0, menubar=0, menu=0, scrollbars=0");
	w.focus();
}

function viewPpvOrder(theid){
	var w=window.open("viewPpvOrder.php?id=" + theid,"ppvorder","width=570, height=270, status=0, menubar=0, menu=0, scrollbars=0");
	w.focus();
}

function reloadPage()
{
	window.location.reload();
}

function schedulenew(thedate,thetime,edit) {
	var w=window.open("insertprogrammenew.php?date=" + thedate + "&time=" + thetime + "&edit=" + edit,"schedule","width=540, height=300, status=0, menubar=0, menu=0, scrollbars=0");
	w.focus();
}

function copySch(f,whichone,hasSch) {
		if (hasSch)
			{
				if (confirm("Are you sure you want to overwrite the existing schedule?"))
				{
				f.upd.value=whichone;
				f.submit();
				}
			} else {
				f.upd.value=whichone;
				f.submit();
			}
}

function setchosenprogramme(theid,f,thetable,theel,thefield) {
	//alert("setting prog to " + theid);
	var rows = document.getElementById(thetable).getElementsByTagName("tr");
	var isselected;
	for(i=0;i<rows.length;i++) {
		var cells = rows[i].getElementsByTagName("td");
		if(rows[i]==theel) {
			if(cells[1].style.backgroundColor) {
				//alert(cells[1].style.backgroundColor);
				isselected = (RGBtoHex(cells[1].style.backgroundColor)=='316ac5') ? true : false;
				if(!isselected){isselected = (cells[1].style.backgroundColor=='#316ac5') ? true : false;}
				var col = RGBtoHex(cells[1].style.backgroundColor);
			}
		}
	    for(j=0;j<cells.length;j++) {
	    	cells[j].style.backgroundColor = '#ffffff';
			cells[j].style.color = '#000000';
		}
	}
	var cells = theel.getElementsByTagName("td");
    for(i=0;i<cells.length;i++) {
    	cells[i].style.backgroundColor = (isselected==true) ? '#ffffff' : '#316ac5';
		cells[i].style.color = isselected ? '#000000' : '#ffffff';
	}
	document.getElementById(thefield).value = isselected ? 0 : theid;
	//JAY//f[thefield].value = isselected ? 0 : theid; THIS LINE SCREWS UP ON AJAX
}

//  multiple select version of the above function
function setchosenprogrammes(theid,f,thetable,theel,thefield) {
	f[thefield].value = theid;
	var rows = document.getElementById(thetable).getElementsByTagName("tr");
	var isselected;
	for(i=0;i<rows.length;i++) {
		var cells = rows[i].getElementsByTagName("td");
		if(rows[i]==theel) {
			if(cells[1].style.backgroundColor) {
				isselected = (RGBtoHex(cells[1].style.backgroundColor)=='316ac5') ? true : false;
				var col = RGBtoHex(cells[1].style.backgroundColor);
			}
		}
	    for(j=0;j<cells.length;j++) {
			cells[j].style.backgroundColor = '#ffffff';
			cells[j].style.color = '#000000';
		}
	}

	var cells = theel.getElementsByTagName("td");
    for(i=0;i<cells.length;i++) {
    	cells[i].style.backgroundColor = isselected ? '#ffffff' : '#316ac5';
		cells[i].style.color = isselected ? '#000000' : '#ffffff';
	}
}

// Used to set the programme durations when adding/editing a programme entry
function setDurations(f) {
	thisduration = durations[f.programmeSource[f.programmeSource.selectedIndex].value];
	if (thisduration != undefined)
	{
	f.durat.value = thisduration;
	//alert("change duration to " + thisduration);
	timeparts = thisduration.split(":");
	f.hours.selectedIndex = timeparts[0];
	f.minutes.selectedIndex = timeparts[1];
	f.seconds.selectedIndex = timeparts[2];
	setHyperlink(f);
	}
	else
	{
	f.durat.value = "00:00:00";
	thisduration = "00:00:00";
	timeparts = thisduration.split(":");
	f.hours.selectedIndex = timeparts[0];
	f.minutes.selectedIndex = timeparts[1];
	f.seconds.selectedIndex = timeparts[2];
	}
}


function setHyperlink(f) {
	//f.programmeHyperlink.value="";
}

function setFilename(f,cli) {
	/*f.programmeSource.selectedIndex=0;
	f.durat.value = "00:00:00";
	thisduration = "00:00:00";
	timeparts = thisduration.split(":");
	f.hours.selectedIndex = timeparts[0];
	f.minutes.selectedIndex = timeparts[1];
	f.seconds.selectedIndex = timeparts[2];*/
	/*var theLink = f.programmeHyperlink.value;
	getDuration1(f,cli);
	f.programmeHyperlink.value = theLink;*/
}

// converts RGB values to hex values for the programme select boxes (setchosenprogramme())
function RGBtoHex(RGB) {
	var parts = makeColor(RGB);
//	return trim(parts[0])+trim(parts[1])+trim(parts[2]);
	return toHex(parts[0])+toHex(parts[1])+toHex(parts[2]);
}

function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789abcdef".charAt((N-N%16)/16)
      + "0123456789abcdef".charAt(N%16);
}

// creates an RGB value from the format 'rgb(255,255,255)'
function makeColor(thecolor) {
 thecolor = thecolor.substring(4);
 thecolor = thecolor.substr(0,thecolor.length-1);
 var parts = thecolor.split(",");
 return parts;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function checkPPV(f) {
	if(f.scheduleProgrammeId.value==0) {
		alert("Please select a programme.");
		return false;
	}
	if ((f.theChannelCert.value < f.theProgrammeCert.value) && (f.theChannelCert.value != 7))
	{	
		if(confirm("You have chosen to add content rated higher than the current channel rating, continuing will increase the channel rating.")==true)
			return true;
		else
			return false;
	}
	return true;
}

function checkPPVsequence(f) {
	var progIds = document.getElementsByName('progIds[]');
	var selectTitle = document.getElementById('selectTitle');
	var countProg = 0;
	var frm = document.formPPV;
	for (i = 0; i <= frm.elements.length -1; i++)
	{
    	if(frm.elements[i].name == "progIds[]")
		{
    		countProg++;
      	}
	 }
	if(countProg < 1)
	{
		alert("Please select at least 1 programme.");
		return false;
	}
	else if(selectTitle.options[selectTitle.options.selectedIndex].value == "NaN")
	{
		alert("Please select a default programme.");
		return false;
	}
	else
	{
		return true;
	}
}

function doBuffering(end) {
	document.getElementById("buffer").style.visibility = hidden;
	document.getElementById("buffer").style.zIndex = 500;
}

function doBuffering(start) {
	document.getElementById("buffer").style.visibility = "visible";
	document.getElementById("buffer").style.zIndex = 0;
}

function imgOn(imgName,ext) {
	//ext = (ext == "") ? ext = "gif" : ext;
	if (document.images) {
		document[imgName].src = "images/" + imgName + "_on." + ext;
	}
}

function imgOff(imgName,ext) {
	//ext = (ext == "") ? ext = "gif" : ext;
	if (document.images) {
		document[imgName].src = "images/" + imgName + "_off." + ext;
		for(var i=0; i<tabs.length;i++) {
		if(eval(tabs[i] + "tab")==1) {
			document[tabs[i]].src = "images/" + tabs[i] + "_on." + ext;
		} else {
			document[tabs[i]].src = "images/" + tabs[i] + "_off." + ext;
		}
		}
	}
}

function channelpage() {
	window.frames[0].location.href="f.channels.php";
	channelstab = 1;
	scheduletab = 0;
	featurestab = 0;
	searchtab = 0;
	myaccounttab = 0;
}

function schedule() {
	window.frames[0].location.href="frame.schedule.php";
}

function schedulepage() {
	window.frames[0].location.href="f.schedule.php";
	scheduletab = 1;
	channelstab = 0;
	featurestab = 0;
	searchtab = 0;
	myaccounttab = 0;
}


function dosearch() {
	window.frames[0].location.href="f.search.php";
	searchtab = 1;
	channelstab = 0;
	featurestab = 0;
	scheduletab = 0;
	myaccounttab = 0;

}

function featurespage() {
	window.frames[0].location.href="f.features.php";
	featurestab = 1;
	scheduletab = 0;
	channelstab = 0;
	searchtab = 0;
	myaccounttab = 0;
}

function dowatch(ppvHash) {
	parent.document.location.href = "player.php?h=" + ppvHash;
}

function refreshto(theurl) {
	document.location.href = theurl;
}


function channelpagelist(thechannel) {
	document.location.href="f.channel.php?id=" + thechannel;
}

function schedulepagelist(thechannel) {
	document.location.href="f.schedule.php?schId=" + thechannel;
}

function subchannellist(thechannel) {
	document.location.href="f.channels.php?parentId=" + thechannel;
}

function startSchedule(src) {
	//alert(src);
	// grab the relevant source for this piece of content, and play it
	var player = top.document.getElementById("mediaplayer1");
	//alert(src);
	player.URL = src;
	// Play the media item.
	player.controls.play();
}

function highlight(theel) {
	theel.style.backgroundColor='#fff';
}


function unhighlight(theel) {
	theel.style.backgroundColor='';
}

function ffwd() {
	document.mediaplayer1.controls.fastForward();
}

function rwd() {
	document.mediaplayer1.controls.fastReverse();
}

function stop() {
	document.mediaplayer1.controls.pause();
}

function play() {
	document.mediaplayer1.controls.play();
}


var theevent;
function fullScreen() {
	window.name='player';
	var k = window.open("timer.php","timer","width=250, height=100, scrolling=0, scrollbars=0, status=0, location=0");
	k.moveTo((screen.availWidth/2)-125,(screen.availHeight/2)-50);
	k.focus();
}

function goFullScreen() {
	var player = document.getElementById("mediaplayer1");
	if (player.playState == 3) { // check wmplayer status
		player.fullScreen = true;
	}
//	return false;
}

function checkWatch(ppvHash,channelId,ppvid,ppvamt,mob,subs,login,portal,url)
{
	if ((login==1) || (ppvamt > 0))
	{
		document.location.href = "https://secure.gdbtv.com/" + url + "/checkLogin.php?h=" + ppvHash + "&channelId=" + channelId + "&ppvId=" + ppvid + "&ppvamt=" + ppvamt + "&mob=" + mob + "&s=" + subs + "&por=" + portal;
	} else {
		//just play it
		document.location.href = "f.ppvDetail.php?h=" + ppvHash;
	}
}
