function cadastrar() {
	if (document.formNews.nome.value == "") {
		window.alert("Digite seu nome.");
		document.formNews.nome.focus();
	} else if (document.formNews.email.value == "") {
		window.alert("Digite o seu e-mail.");
		document.formNews.email.focus();
	} else if (!validateEmail(document.formNews.email, "E-mail")) {
	} else {
		document.formNews.acao.value = "javascript:window.close();";
		document.formNews.botao.value = "fechar_gr.jpg";
        document.formNews.operacao.value="cadastro_simples";
        document.formNews.idOperacaoNewsletter.value="1";
        window.open("",document.formNews.target,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=450,height=280,top=155,left=225');
        document.formNews.submit();
        window.open(document.formNews.url_final.value,"_self");
	}
}

//================== FUNÇÃO CONTEÚDO

tXHR=0;   
divId="";

function XMLHTTPRequest() {   
if (window.XMLHttpRequest) {   
	a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)   
else {   
  try {   
	 a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)   
  }     
  catch(e) {   
	try {   
	   a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)   
	}     
	catch(e) { /* O navegador não tem suporte */   
	   a=false;   
	}   
  }   
}   
return a;   
}   

function recebeResultado() {
  if (!tXHR) {
	  return false;
  }
  else {
	  if (tXHR.readyState == 4) {
		  if (tXHR.status == 200) {
			  document.getElementById(divId).innerHTML = tXHR.responseText;
		  }   
		  else {   
			  document.getElementById(divId).innerHTML = 'Erro! "'+ tXHR.statusText +'" (erro '+ tXHR.status +')';   
		  }   
	  }       
  }   
}   

function acaoConteudo(div,action) {
  divId = div;
  tXHR=XMLHTTPRequest();   
  if (tXHR) {
	  document.getElementById(divId).innerHTML = 
          "<table align='center' valign='center'>"+
          	"<tr>"+
           		"<td align='center'>"+
				
               		"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br /><br />"+
               		"<img src='imagens/loader.gif' /><br />"+
                 	"<font color='#153170' size='2' face='Verdana, Arial, Helvetica, sans-serif'>Carregando...</font>"+
                    	"<br/><br/><br/><br/><br/><br/><br/>"+
                       	"</td>"+
                "</tr>"+
          "</table>";
	  tXHR.open("POST", action, true);
	  //tXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	  tXHR.onreadystatechange=recebeResultado;   
	  tXHR.send(null);   
  }   
}

function enviar_agende(){
    
    var nome = document.agende.nome.value;
    var email = document.agende.email.value;    
    var comentario = document.agende.comentario.value;
    
    if( (nome == "") || (email == "") || (comentario == "") ) {
        window.alert('Os campos "Nome, Email e Comentário devem ser preechidos!"');
    } else if (!validateEmail(document.agende.email, document.agende.email.name)) {
        
    } else {
        window.alert('Mensagem enviada com Sucesso!');
        document.agende.submit();
    }
    
}

function enviar_corretor(){
    
    var nome = document.corretor.nome.value;
    var email = document.corretor.email.value;    
    var comentario = document.corretor.comentario.value;
    var corretora = document.corretor.corretora.value;
    
    if( (nome == "") || (email == "") || (comentario == "") || (corretora == "") ) {
        window.alert('Os campos "Nome, Email, Corretora e Comentário devem ser preechidos!"');
    } else if (!validateEmail(document.corretor.email, document.corretor.email.name)) {
        
    } else {
        window.alert('Mensagem enviada com Sucesso!');
        document.corretor.submit();
    }
    
}

function enviar_contato(){
    var nome = document.contato.nome.value;
    var email = document.contato.email.value;    
    var comentario = document.contato.comentario.value;
    var endereco = document.contato.endereco.value;    
    
    if( (nome == "") || (email == "") || (endereco == "") || (comentario == "") ) {
        window.alert('Os campos "Nome, Email, Endereço e Comentário devem ser preechidos!"');
    } else if (!validateEmail(document.contato.email, document.contato.email.name)) {
        
    } else {
        window.alert('Mensagem enviada com Sucesso!');
        document.contato.submit();
    }   
        
}

