// JavaScript Document
// Jadir Bento - jadir.bento@gmail.com
// 15/04/2010




//Ajax
	function httpRequest(url)
	{
		if(window.XMLHttpRequest) req = new XMLHttpRequest() 
		else if (window.ActiveXObject) req = new ActiveXObject("microsoft.XMLHTTP") 
		req.open("get",url,false)
		req.send(null)
		return req.responseText  
	} 
	
	//limpar o cache do navegador
	function limpaCache(url){
	   if(url.indexOf('?')>=0){
		  return url + '&rand=' + encodeURI(Math.random());
	   }else{
		  return url + '?randon=' + encodeURI(Math.random());
	   }
	}
	

	function Asynchronous_Javascript_And_XML(Url,AlvoObj,AlvoUrl)
	{  
		var xmlhttp
		var NewUrl	
		var retorno=''
		
		//instancia do obj	
		try	{xmlhttp = new XMLHttpRequest();}catch(ee){try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp = false;}}}//fim try
	
		//cria o Objeto
		 var objxmlhttp = null
		if (window.XMLhttpRequest){
			objxmlhttp = new XMLhttpRequest()
		}else if (window.ActiveXObject){
			objxmlhttp = new ActiveXObject("microsoft.XMLHTTP")
		}
		
		if(AlvoObj !='' && AlvoUrl !=''){
			var obj_write = document.getElementById(AlvoObj)
			obj_write.innerHTML = AlvoUrl
		}
		
		if(Url !=''){
			//limpa o cach do navegador
			NewUrl = limpaCache(Url)
			//window.open (NewUrl)		
			xmlhttp.open("POST", NewUrl, true)
			retorno = httpRequest(NewUrl)
		}else{
			retorno = 200
		}
		return retorno
	}
