// JavaScript Document

var xmlHttp = createXmlHttpRequestObject(); 
var DHTML = document.getElementById;

function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

// MENU
function openMenuVideo(bntId)
{
  // proceed only if the xmlHttp object isn't busy
  bntTemp = bntId;
  
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
  		// execute the .php page from the server
		url = "?bntPlay=" + bntId;
		page = "templates/menuDireita.php"+url
		divId = 'list_item';
		
		xmlHttp.open("GET", page , true);  
		// define the method to handle server responses		
		xmlHttp.onreadystatechange = handleServerResponse;		 
		// make the server request
		xmlHttp.send(null);
  }
  else
    setTimeout('openMenuVideo(bntTemp)', 1000);     // if the connection is busy, try again after one second   
}

function handleServerResponse() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState==1)
  {
	document.getElementById(divId).innerHTML="Carregando Dados..."				
  }
   
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      xmlResponse = xmlHttp.responseText;
	  //PlayVideo(xmlResponse)
  	  document.getElementById(divId).innerHTML = xmlResponse;
	} 
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}


function titulo_video(titulo)
{
    document.getElementById('vid_txt').innerHTML = titulo;
}


function titulo_menu(titulo)
{
    document.getElementById('list_top_txt').innerHTML = titulo;
}


