/*
FUNÇÃO QUE CRIA O XMLHTTP
*/
function http()
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
return xmlhttp

}

/*
FUNÇÃO 
url: endereço da ágina
parametros: dados a ser enviados para a página
tipo: 0=GET; 1=POST
element: Nome do elemento a ser alterado
update: 0=Não atualiza; 1:Atualiza
refr: refresh na página
*/
function Ajax(url, parametros, tipo, element, update, refr){
var xmlhttp=new http();
var response;
if (parametros=='null')
{
	parametros ='null='+escape(null)
}
if (tipo==0)
{
	xmlhttp.open("GET", url +"?h="+ Date()+'&'+parametros,true);
}
else{
	xmlhttp.open("Post", url+"?h="+ Date(),true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.setRequestHeader('Content-length', parametros.length);
}
xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4)
  {  	
  	 response = xmlhttp.responseText;
	 if (refr==1)
	 {
		 document.location.reload( true );
	 }
	 else{
		 if (update!=0)
		 {
			 //alert(document.getElementsById(element)[0].innerHTML);
			 
			 document.getElementById(element).innerHTML = response;
		 }
	 }
  }	
}
if (tipo==0)
{
xmlhttp.send(null);
}
else{
xmlhttp.send(parametros);
}
}
