var xmlHttp = createXmlHttpRequestObject(); 
function createXmlHttpRequestObject()  
{ 
  var xmlHttp; 
  try 
  { 
       xmlHttp = new XMLHttpRequest(); 
  } 
  catch(e) 
  { 
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP"    ,
                                    "Microsoft.XMLHTTP");
	for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
    {
      try
      {
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      }
      catch (e) {}
    }
  }
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}

function processa(inputValue)
{
  if (xmlHttp)
  {
    try
    {
	  element = "centro2";
      xmlHttp.open("POST", "getfoto.php", true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
	  matricula = "foto="+inputValue;
	  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xmlHttp.send(matricula);
	}
    catch (e)
    {
    } 
  } 
} 

function handleRequestStateChange(){ 
if (xmlHttp.readyState < 4){
	myDiv = document.getElementById(element); 
    myDiv.innerHTML = '<img src="imagens/loading.gif" />&nbsp;'; 
}
	if (xmlHttp.readyState == 4)  
  { 
    if (xmlHttp.status == 200)  
    { 
      try 
      { 
        handleServerResponse(); 
      } 
      catch(e) 
      { 
        alert("Error reading the response: " + e.toString()); 
      } 
    }  
    else 
    { 
      alert("There was a problem retrieving the data:\n" +  
            xmlHttp.statusText); 
	  } 
  } 
} 

function handleServerResponse() 
{   myDiv = document.getElementById(element); 
  myDiv.innerHTML = xmlHttp.responseText; 
} 

function handleRequestStateChange2(){ 
if (xmlHttp.readyState < 4){
	myDiv = document.getElementById(element2); 
    myDiv.innerHTML = '<img src="imagens/loading2.gif" />&nbsp;'; 
}
	if (xmlHttp.readyState == 4)  
  { 
    if (xmlHttp.status == 200)  
    { 
      try 
      { 
        handleServerResponse2(); 
      } 
      catch(e) 
      { 
        alert("Error reading the response: " + e.toString()); 
      } 
    }  
    else 
    { 
      alert("There was a problem retrieving the data:\n" +  
            xmlHttp.statusText); 
	  } 
  } 
} 

function handleServerResponse2(){ 
  myDiv = document.getElementById(element2); 
  myDiv.innerHTML = xmlHttp.responseText; 
} 
function trocagaleria(galeria){
	
	  element2 = "thumbs";
	  var serverpage = 	"thumbs.php";
      xmlHttp.open("POST", serverpage , true);
      xmlHttp.onreadystatechange = handleRequestStateChange2;
	  data = "cat="+galeria;
	  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	  movetop();
	  xmlHttp.send(data);
}
function contato(email,nome,mensagem)
{
  if (xmlHttp)
  {
    try
    {
	  element = "CONTATO_FORM";
	  var serverpage = 	"contato_action.php";
      xmlHttp.open("POST", serverpage , true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
	  campos = "email="+email+"&nome="+nome+"&mensagem="+mensagem;
	  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xmlHttp.send(campos);
	}
    catch (e)
    {
    } 
  } 
} 

function catmenu(){
	  if (xmlHttp)
  {
    try
    {
	  element2 = "catmenu";
	  var serverpage = 	"catmenu.php";
      xmlHttp.open("GET", serverpage , true);
      xmlHttp.onreadystatechange = handleRequestStateChange2;
	  xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xmlHttp.send(null);
	}
    catch (e)
    {
    } 
  } 
}

function ensaioMenu(){
	  if (xmlHttp)
  {
    try
    {
	  element = "centro2";
	  document.getElementById('centro2').style.visibility='visible';
	  var serverpage = 	"ensaiomenu.php";
      xmlHttp.open("GET", serverpage , true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
	  xmlHttp.send(null);
	}
    catch (e)
    {
    } 
  } 
}

function loadEnsaio(ensaio){
	  if (xmlHttp)
  {
    try
    {
	  document.getElementById('xyzzy').style.display = 'none';
	  element = "centro2";
	  var serverpage = 	"ensaio_load.php?id_ensaio="+ensaio;
      xmlHttp.open("GET", serverpage , true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
      xmlHttp.send(null);
	}
    catch (e)
    {
    } 
  } 
}
function alertaID(f){
	alert(f);
	}