// JavaScript Document
var xmlhttp;

function ajaxFunction(){
if(window.ActiveXObject){
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   else if(window.XMLHttpRequest){
	   xmlhttp = new XMLHttpRequest();
   }
   else
   {
	   alert("Your Browser does not support the interactive function needed for CVM Television Website");
   }
}

function getSchedule(){
ajaxFunction();
if (xmlhttp){
showstuff("page_content");
hidestuff("pagehide");
hidestuff("pagehide2");
xmlhttp.open('GET', '/pages/schedule.php', false)
xmlhttp.send()
//alert("page changed");
embedpage(xmlhttp)
	}
}


function getProgramme(){
ajaxFunction();
if (xmlhttp){
showstuff("page_content");	
hidestuff("pagehide");
hidestuff("pagehide2");
xmlhttp.open('GET', '/pages/programme.php', false)
xmlhttp.send()
//alert("page changed");
embedpage(xmlhttp)
	}
}

function home(){
ajaxFunction();
if (xmlhttp){
showstuff("pagehide");
showstuff("pagehide2");
hidestuff("page_content");
//xmlhttp.open('GET', '/pages/topbanner.php', false)
//xmlhttp.send()

//alert("page changed");
embedpage(xmlhttp)
	}	
}

function embedpage(request){
	//alert(request.status);
	if (request.readyState == 4 && xmlhttp.status==200){
		var response = request.responseText;
		try
		{
		//alert("This point reached");	
		document.getElementById("page_content").innerHTML = response;
		}
	catch(e){
			//showstuff("home");
			alert(e.message);
				
			}

	}
}
function hidestuff(boxid){
   document.getElementById(boxid).style.display="none";
}

function showstuff(boxid){
   document.getElementById(boxid).style.display="block";
}


function setbackground(){
window.setTimeout( "setbackground()", 5000);
var index = Math.round(Math.random() * 9);
var ColorValue = "#E6A9EC";
if(index == 1)
ColorValue = "FFCCCC";
if(index == 2)
ColorValue = "CCAFFF";
if(index == 3)
ColorValue = "A6BEFF";
if(index == 4)
ColorValue = "99FFFF";
if(index == 5)
ColorValue = "D5CCBB";
if(index == 6)
ColorValue = "99FF99";
if(index == 7)
ColorValue = "FFFF99";
if(index == 8)
ColorValue = "FFCC99";
if(index == 9)
ColorValue = "CCCCCC";
document.bgColor=ColorValue;
}

function LoadVideoBar() {

    var videoBar;
    var options = {
        largeResultSet : !true,
        horizontal : true,
        autoExecuteList : {
          cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM,
          cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
          executeList : ["ytchannel:cvmtelevision"]
        }
      }

    videoBar = new GSvideoBar(document.getElementById("videoBar-bar"),
                              GSvideoBar.PLAYER_ROOT_FLOATING,
                              options);
    }
  
