
var xmlHttp=false;

function criaRequest(){
  		if(window.XMLHttpRequest){
			xmlHttp=new XMLHttpRequest();
		}else if (window.ActiveXObject){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}else{
			alert("O Browser não suporta Ajax")
			return false;
		}
}
  
 
  function teste(){
	  
		alert("oh!");
		return false;
	}
  
  
  function executaRequest(formulario,campo1,campo2,div){
	  
  	//ver funcao em cima
  	if (criaRequest()!=false){ 
		
		
		var sParams="";
		with(formulario){
			var input1=campo1.value;
			var input2=campo2.value;
		}
		
		
		
		
		//ver funcao em baixo
		sParams= criaParamsPost(sParams,"loja",input1);
		sParams= criaParamsPost(sParams,"pais",input2);
		
	
		xmlHttp.open("POST", "inclusoes/devolveLojas.asp", true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		// em princípio deve ser a página no servidor que deve ter especificada a codificação do output (ver exemplos php e asp anexos)
		xmlHttp.setRequestHeader("Encoding", "ISO-8859-1"); 
		
		document.getElementById(div).innerHTML="<img src='Imagens/PecasAux/loading.gif'/>";
		
 		 xmlHttp.onreadystatechange=function(){
  			
  			if(xmlHttp.readyState==4){
				document.getElementById(div).innerHTML=xmlHttp.responseText;
			}
  		}
		xmlHttp.send(sParams);
		
	return false;
	}
  }

function criaParamsPost(sParams, nome, valor){

	if(sParams.length>0){
		sParams+="&";
	}
	return sParams + encodeURIComponent(nome)+"="+encodeURIComponent(valor);
}
  
