﻿function validaNovidades(){

	d = document.frmNovidades;
	if (d.nome.value == "")
	{
		alert("Preencha o campo Nome!");
		d.nome.focus();
		return false;	
	}
    
	if (d.telResidencial.value == "")
	{
		alert("Preencha o campo Telefone!");
		d.telResidencial.focus();
		return false;	
	}
    
    	if (d.estadocivil.value == "")
	{
		alert("Preencha o campo Estado Civil!");
		d.estadocivil.focus();
		return false;	
	}
	
	
		var str = d.email.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   alert("Email Inválido!")
       	   d.email.focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Email Inválido!")
       	   d.email.focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Email Inválido!")
       	   d.email.focus();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Email Inválido!")
       	   d.email.focus();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Email Inválido!")
       	   d.email.focus();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Email Inválido!")
       	   d.email.focus();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Email Inválido!")
       	   d.email.focus();
		    return false
		 }
		 
		 
    if (d.cidade.value == "")
	{
		alert("Preencha o campo Cidade!");
		d.cidade.focus();
		return false;	
	}
	

	if (d.endereco.value == "")
	{
		alert("Preencha o campo Endereço!");
		d.endereco.focus();
		return false;	
	}

	if (d.idade.value == "")
	{
		alert("Preencha o campo Idade!");
		d.idade.focus();
		return false;	
	}
	
		if (d.bairro.value == "")
	{
		alert("Preencha o campo Bairro!");
		d.bairro.focus();
		return false;	
	}

	if (d.filhos.value == "")
	{
		alert("Preencha o campo Filhos!");
		d.filhos.focus();
		return false;	
	}

	if (d.celular.value == "")
	{
		alert("Preencha o campo Celular!");
		d.celular.focus();
		return false;	
	}
	
	

	else
		return true;
	
}

function mudaMenu(elemento){
    
    document.getElementById("menu"+elemento).style.background = "#81000D";
    document.getElementById("menu"+elemento).style.margin = "0px 0px 0px 0px";
    document.getElementById("menu-esq"+elemento).style.display = "block";
    document.getElementById("menu-dir"+elemento).style.display = "block";
    document.getElementById("menu-dir"+elemento).style.margin = "0px 2px 0px 0px";
    document.getElementById("menu-esq"+elemento).style.margin = "0px 0px 0px 2px";
}

function voltaMenu(elemento){
    
    document.getElementById("menu"+elemento).style.background = "";
    document.getElementById("menu"+elemento).style.margin = "0px 7px 0px 7px";
    document.getElementById("menu-esq"+elemento).style.display = "none";
    document.getElementById("menu-dir"+elemento).style.display = "none";
}

//function testeMenu(elemento){

//    document.getElementById("menu"+elemento).style.background = "#81000D";
//    document.getElementById("menu"+elemento).style.margin = "0px 0px 0px 0px";
//    document.getElementById("menu-esq"+elemento).style.display = "block";
//    document.getElementById("menu-dir"+elemento).style.display = "block";
//    document.getElementById("menu-dir"+elemento).style.margin = "0px 2px 0px 0px";
//    document.getElementById("menu-esq"+elemento).style.margin = "0px 0px 0px 2px";
//    document.getElementById("menu"+elemento).onmouseout = "";
//    
//}

