// JavaScript Document
function BuscarCEP()
{
	if(document.formCadastro.cep.value == "")
	{
		alert("Informe um CEP para consulta !");
		document.formCadastro.cep.focus();
	}
	else
	{
		SleepButton(document.formCadastro.BTCep, false, "Aguarde, pesquisando cep . . .");
		
		var oHTTPRequest2 = createXMLHTTP(); 
		oHTTPRequest2.open("post", "Execs_Ajax/BuscaCEP.asp", true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
		oHTTPRequest2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oHTTPRequest2.onreadystatechange = function()
		{
			if (oHTTPRequest2.readyState == 4)
			{	
				
				SleepButton(document.formCadastro.BTCep, true, "Buscar CEP !");
				
				if(oHTTPRequest2.responseText == "")
				{
					alert("CEP não econtrado !");
					document.formCadastro.cep.select();				
				}
				else
				{
					var iDados = new Array();
					iDados = oHTTPRequest2.responseText.split("|");
					
					if(iDados.length > 0)
					{					
						document.formCadastro.rua.value = iDados[0].toString();
						//document.formCadastro.bairro.value = iDados[1].toString();
						//document.formCadastro.cidade.value = iDados[2].toString();
						//document.formCadastro.estado.value = iDados[3].toString();	
						
						document.formCadastro.numero.focus();				
					}
					else
					{
						alert(oHTTPRequest2.responseText);
					}
					
				}
								
			}
		}
		
		var strVariaveisForm = "cep=" + document.formCadastro.cep.value;	
		oHTTPRequest2.send(strVariaveisForm);		
	}
}

function Enviar_CadastreEmail()
{	
	var ObjTextEmail = document.getElementById("cadastre_email");

	if(ObjTextEmail.value == "" || ObjTextEmail.value ==  "Digite seu e-mail")
	{
		alert("Informe seu email !");
		ObjTextEmail.focus();
	}
	else if(ObjTextEmail.value.indexOf("@",0) == -1 || ObjTextEmail.value.indexOf(".",0) == -1)
	{
		alert("Email inválido !");
		ObjTextEmail.select();
	}
	else
	{
	
		var oHTTPRequest2 = createXMLHTTP(); 
		oHTTPRequest2.open("post", "Execs/Cadastrar_Email.asp", true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
		oHTTPRequest2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oHTTPRequest2.onreadystatechange = function()
		{
			if (oHTTPRequest2.readyState == 4)
			{	
				document.getElementById("Output_CadastrarEmail").innerHTML = "<p class='txcadastrewhite'>" + oHTTPRequest2.responseText + "</p>";	
			}
		}
		
		var strVariaveisForm = "email=" + ObjTextEmail.value;	
		oHTTPRequest2.send(strVariaveisForm);		
		
		document.getElementById("Output_CadastrarEmail").innerHTML = "<p class='txcadastrewhite'>Aguarde, processando ...</p>";
	
	}
	
}
function abrirRadioweb(URL){ 
   window.open(URL,"janela1","width=320,height=320,scrollbars=NO") 
} 


function addFav(){
    var url      = "http://www.portaldaenfermagem.com.br";
    var title    = "Portal da Enfermagem";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

