// JavaScript Document
var xmlHttp
var id
function MakeXmlHttpObject(){
	var xmlHttp=null;
	try{
		// XmlHttpRequest para Firefox,Opera, Safari e derivados.
		xmlHttp = new XMLHttpRequest();
	}
	catch (e){
		// XmlHttpRequest para InternetExplorer.
		try{
			// Internet Explorer 6.0+
			xmlHttp = new
			ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			// Internet Explorer.
			xmlHttp = new
			ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function stateChanged() {
	if (xmlHttp.readyState==4)
	{
		document.getElementById("divRetorno").innerHTML="";
		if (xmlHttp.responseText =='E-mail cadastrodo com sucesso!')
		{
			alert("E-mail cadastrado com sucesso! \n\n Enviamos uma mensagem de confirmaçao para seu e-mail. \n\n Verifique se chegou corretamente e caso tenha caído na lixeira pedimos, por gentileza, que marque nosso e-mail como confiável. Obrigado");
		}
		else
		{
			
			alert(xmlHttp.responseText);
		}
		document.getElementById("btcadastro").style.cursor="pointer";
	}
}

function showHint(doc){

   var a = document.getElementById('email').value; //email
   var b = "";//nome
	 var c = ""; //nascimento
	 var d = ""; //cidade
	 var e = ""; //uf
	 var f = ""; //ddd
	 var g = ""; //telefone
	 
	 document.getElementById("divRetorno").innerHTML= '<img src="images/loadingAnimationn.gif" >';
	 document.getElementById("btcadastro").style.cursor="default";
	xmlHttp=MakeXmlHttpObject()
	if (xmlHttp==null){
		alert ("O browser nao suporta AJAX!");
	return ;
	}	
	rand=Math.floor(Math.random( ) * (999999999+1));
	var pedido=doc+".php"+"?email="+a+"&NomeCadastro="+b+"&nascimento="+c+"&cidade="+d+"&uf="+e+"&ddd="+f+"&telefone="+g+"&rand="+rand;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",pedido,true);
	xmlHttp.send(null);
}
