// JavaScript Document
function esconde_div() {
	document.getElementById('divResultJanela').innerHTML='';
	document.getElementById('divJanela').style.visibility = 'hidden';
}

function createXMLHttpRequest() {
	/*
		Interface genérica para acesso ao conector remoto.
	*/
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   alert("XMLHttpRequest não suportado!");
   return null;
}

function recuperaPagina(pagina , divResultado, titulo)
{
	
	if(divResultado == 'divResultJanela'){		
		document.getElementById('divResultJanela').innerHTML='<div width=100% algin=center style=padding:2px;>Carregando...</div>';
		document.getElementById('divJanela').style.height = 'auto';
		document.getElementById('divJanela').style.width = 'auto';
		
		var margem = dd.getScrollY() + 20;
		document.getElementById('divJanela').style.top = margem + 'px';
		document.getElementById('divJanela').style.visibility = 'visible';
		
		ADD_DHTML('divJanela' + TRANSPARENT);
		if(titulo != ''){document.getElementById('divTituloJanela').innerHTML = titulo};
	}
	
	//criacao do objeto XMLHTTP
	oHTTPRequest = createXMLHttpRequest(); 
       
	//oHTTPRequest.open("get", pagina, true);
        //PULO DO GATO PARA EVITAR O CACHE DO IE ACRUZ
        var param ="";
        if (pagina.indexOf("?")== -1  && pagina.indexOf("=") == -1){
            param = "?sid=";
        }else{
            param = "&sid=";                 
        }
        oHTTPRequest.open("get", pagina+param+Math.random(), true);
	oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oHTTPRequest.onreadystatechange=function() {
		if (oHTTPRequest.readyState==4){
			document.getElementById(divResultado).innerHTML = oHTTPRequest.responseText;
			exeScript(oHTTPRequest.responseText);
		}
	}
	
	oHTTPRequest.send("");
	document.getElementById(divResultado).innerHTML = '<p id="carregando"><img src="imagem/carregando.gif" alt="Carregando" width="16" height="16" align="absbottom" />Carregando... Aguarde</p>';
}

function recuperaPaginaPost(pagina , divResultado)
{
	
	/*if(divResultado == 'divResultJanela'){		
		document.getElementById('divResultJanela').innerHTML='<div width=100% algin=center style=padding:2px;>Carregando...</div>';
		document.getElementById('divJanela').style.height = 'auto';
		document.getElementById('divJanela').style.width = 'auto';
		
		var margem = dd.getScrollY() + 20;
		document.getElementById('divJanela').style.top = margem + 'px';
		document.getElementById('divJanela').style.visibility = 'visible';
		
		ADD_DHTML('divJanela' + TRANSPARENT);
		if(titulo != ''){document.getElementById('divTituloJanela').innerHTML = titulo};
	}*/
	
	//criacao do objeto XMLHTTP4
	aHTTPRequest = createXMLHttpRequest(); 
		aHTTPRequest.open("POST", pagina, true);
		aHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
		var zona 	 	 = document.getElementById('zona').value;
		var nome 	 	 = document.getElementById('nome').value;
		var tEleitor 	 = document.getElementById('titulo').value;
		var email 	 	 = document.getElementById('email').value;
		var profissao 	 = document.getElementById('profissao').value;
		var escolaridade = document.getElementById('escolaridade').value;
		var telefone	 = document.getElementById('telefone').value;
		var endereco	 = document.getElementById('endereco').value;
		var comentario	 = document.getElementById('comentario').value;
	
		aHTTPRequest.send("zona="+zona+"&nome="+nome+"&titulo="+tEleitor+"&email="+email+"&profissao="+profissao+"&escolaridade="+escolaridade+"&telefone="+telefone+"&endereco="+endereco+"&comentario="+comentario);
		aHTTPRequest.onreadystatechange=function() {
			if (aHTTPRequest.readyState==4){
				document.getElementById(divResultado).innerHTML = aHTTPRequest.responseText;			
				exeScript(aHTTPRequest.responseText);
			}        
    }
	
//	aHTTPRequest.send("");
//	document.getElementById(divResultado).innerHTML = '<p id="carregando"><img src="imagem/carregando.gif" alt="Carregando" width="16" height="16" align="absbottom" />Carregando... Aguarde</p>';
}