var canCallColor = 2;
var canCallContent = 1;
var currentContent = -1;

function ajaxFunction(url, obj)
{  
  var xmlHttp;
  url += "?sid=" + Math.random();
  try
  {    
    // Firefox, Opera 8.0+, Safari    
    xmlHttp=new XMLHttpRequest();    
  }
  catch (e)
  {
    // Internet Explorer    
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
  {
    /*
    State Description 
    0 The request is not initialized 
    1 The request has been set up 
    2 The request has been sent 
    3 The request is in process 
    4 The request is complete 
    */
	
    if(xmlHttp.readyState==4)
    {
       obj.innerHTML=xmlHttp.responseText;
		//	 xmlHttp.onreadystatechange=null;
		//	 xmlHttp.responseText=null;
		//	 xmlHttp=null;
			 canCallContent++;
			 delete xmlHttp.responseText;
			 delete xmlHttp.onreadystatechange;
			 delete xmlHttp;
    }
  }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}


function ajaxBackgroundFunction(url, obj)
{  
  var xmlHttp;
  url += "?sid=" + Math.random();
  try
  {    
    // Firefox, Opera 8.0+, Safari    
    xmlHttp=new XMLHttpRequest();    
  }
  catch (e)
  {
    // Internet Explorer    
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  
  xmlHttp.onreadystatechange=function()
  {
    /*
    State Description 
    0 The request is not initialized 
    1 The request has been set up 
    2 The request has been sent 
    3 The request is in process 
    4 The request is complete 
    */
	
    if(xmlHttp.readyState==4)
    {
       obj.bgColor=xmlHttp.responseText;
			 //xmlHttp.onreadystatechange=null;
			 //xmlHttp.responseText=null;
			 //xmlHttp=null;
			 canCallColor++;
			 delete xmlHttp.responseText;
			 delete xmlHttp.onreadystatechange;
			 delete xmlHttp;
    }
  }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function setContent(page, force)
{
	if(page == "" && force != 1) return;
	if(page == currentContent && force != 1) return;
	currentContent = page;

	if(canCallContent >= 1) 
	{
		canCallContent = 0;
		ajaxFunction('video.php?vid=' + page, document.getElementById('content'));
	}
}
