window.onload = function horizontal() {
 
   var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");
    
   for (var i=0; i< navItems.length; i++) {
      if(navItems[i].className == "submenu")
      {
         if(navItems[i].getElementsByTagName('ul')[0] != null)
         {
            navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "transparent";}
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "transparent";}
         }
      }
   }
 
}

function swapImage(id, imagem, largura, altura) {
	document.getElementById(id).src = imagem;
	document.getElementById(id).width = "145";
	document.getElementById(id).height = "58";
}

function verificaContato(){
		form = document.formContato;
		if(form.empresa.value.length==0){
			alert('Campo Empresa Obrigatório!');
			form.empresa.focus();
			return false;
		}
		if(form.nome.value.length==0){
			alert('Campo Nome Obrigatório!');
			form.nome.focus();
			return false;
		}
		if(form.telefone.value.length==0){
			alert('Campo Telefone Obrigatório!');
			form.telefone.focus();
			return false;
		}
		if(form.email.value.length==0){
			alert('Campo E-mail Obrigatório!');
			form.email.focus();
			return false;
		}
		if(form.chegou.value.length==0){
			alert('Campo "Como chegou até nós" Obrigatório!');
			form.chegou.focus();
			return false;
		}
		if(form.assunto.value.length==0){
			alert('Campo Assunto Obrigatório!');
			form.assunto.focus();
			return false;
		}
		if(form.mensagem.value.length==0){
			alert('Campo Mensagem Obrigatório!');
			form.telefone.focus();
			return false;
		}
		document.formContato.remetente.value = form.email.value;
}
function assineJa() {
	if(document.getElementById("aceito").checked == true){
		window.location='assine-ja-passo-2.php';
	}else{
		alert("É necessário aceitar o contrato.");
	}
}
function validaPasso2(){
	if (document.getElementById("sitedomain").value == "") {	
	 alert("Nome do Site preenchido incorretamente.\n");
	 document.getElementById("sitedomain").focus();
	 return false;
  }
  return true;
}

function validaPasso3() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";
  
  email = document.getElementById("email");
  // validações dos campos gerais
  if (document.getElementById("razao_social").value == "") {
	 passou = false; alerta += "- Razão Social / Nome preenchido incorretamente.\n";
  }
  /*if (document.getElementById("nome_fantasia").value == "") {
	 passou = false; alerta += "- Nome Fantasia preenchido incorretamente.\n";
  }*/
  if (document.getElementById("endereco").value == "") {
	 passou = false; alerta += "- Endereço preenchido incorretamente.\n";
  }
  if (document.getElementById("numero").value == "") {
	 passou = false; alerta += "- Número preenchido incorretamente.\n";
  }
  if (document.getElementById("bairro").value == "") {
	 passou = false; alerta += "- Bairro preenchido incorretamente.\n";
  }
  if (document.getElementById("cidade").value == "") {
	 passou = false; alerta += "- Cidade preenchido incorretamente.\n";
  }
  if (document.getElementById("estado").value == "") {
	 passou = false; alerta += "- Estado preenchido incorretamente.\n";
  }
  if (document.getElementById("cep").value == "") {
	 passou = false; alerta += "- CEP preenchido incorretamente.\n";
  }
  if (document.getElementById("nome").value == "") {
	 passou = false; alerta += "- Nome preenchido incorretamente.\n";
  }
  if (document.getElementById("telefone").value == "") {
	 passou = false; alerta += "- Telefone preenchido incorretamente. Utilize a forma: 00 00000000.\n";
  }
  if (document.getElementById("cnpj_cpf").value == "") {
	 passou = false; alerta += "- CNPJ / CPF preenchido incorretamente.\n";
  }
  if (email.value == "") {
     passou = false; alerta += "- E-mail preenchido incorretamente.\n";
  }else{
      if (!checkMail(email.value)) {
           passou = false; alerta += "- E-mail preenchido incorretamente.\n";
      }
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validaPasso4() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";
  
  // validações dos campos gerais
  if (document.getElementById("mensal_49").checked == false && document.getElementById("mensal_99").checked == false && document.getElementById("mensal_149").checked == false && document.getElementById("mensal_250").checked == false && document.getElementById("mensal_750").checked == false) {
	 passou = false; alerta += "- Escolha um Plano Profissional, de sua preferência.\n";
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validaPasso5() {
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";
  
  // validações dos campos gerais
  if (document.getElementById("boleto").checked == false && document.getElementById("tranferencia").checked == false) {
	 passou = false; alerta += "- Escolha a Forma de Pagamento.\n";
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validarEmail(email)
{
	var s = email;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}

function checkMail(mail){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
        if(typeof(mail) == "string"){
                if(er.test(mail)){ return true; }
        }else if(typeof(mail) == "object"){
                if(er.test(mail.value)){ 
                                        return true; 
                                }
        }else{
                return false;
                }
}

function chnum( caractere ){ 
	var strValidos = "0123456789" 
	if ( strValidos.indexOf( caractere ) == -1 ) 
		return false; 
	return true;  
}

function validanum(campo, event) { 
	var BACKSPACE= 8;   
	var key; 
	var tecla; 
	CheckTAB=true; 
	if(navigator.appName.indexOf("Netscape")!= -1) 
		tecla= event.which; 
	else 
		tecla= event.keyCode; 
	key = String.fromCharCode( tecla);   
	if ( tecla == 13 ) 
		return true;
	if ( tecla == 9 ) 
		return true; 
	if ( tecla == 32 ) 
		return true;
	if ( tecla == BACKSPACE ) 
		return true; 
	return ( chnum(key) ); 
}

//mascara data onkeyup="mdata(this)" onkeypress="return validanum(this, event)"
 function mdata(campo){
     if (campo.value.length > 2)
     	if (campo.value.charAt(campo.value.length - 1) == '/' && campo.value.charAt(campo.value.length - 2) == '/')
        	campo.value = campo.value.substr(0,campo.value.length - 2);
	 if (event.keyCode != 8)			   
     	if (campo.value.length == 2 || campo.value.length == 5)
    		campo.value += '/';
  }
//mascara cep onkeyup="mcep(this)" onkeypress="return validanum(this, event)"
 function mcep(campo){
	 if (campo.value.length == 5)
   	 	campo.value += "-";
  }
//mascara hora onkeyup="mhora(this)" onkeypress="return validanum(this, event)"
 function mhora(campo){
     if (campo.value.length > 2)
       if(campo.value.charAt(campo.value.length - 1) == ':' && campo.value.charAt(campo.value.length - 2) == ':')
          campo.value = campo.value.substr(0,campo.value.length - 2);
	 if (event.keyCode != 8)
   	  if (campo.value.length == 2 || campo.value.length == 5) 
	  	campo.value += ':';
  }
//mascara validade onkeyup="mdata(this)" onkeypress="return validanum(this, event)"
 function mvalidade(campo){
     if (campo.value.length == 2)
    	campo.value += '/';
  }

function validaNome(evento){
	(evento.keyCode) ? key = evento.keyCode : key = evento.which;
	//alert(key);
	var er = new RegExp(/^[a-z\u00C0-\u00ff A-Z]+$/);
	if(String.fromCharCode(key).match(/^[a-z\u00C0-\u00ff A-Z]+$/) || key==8 || key==9 || key==46 || key==37 || key==39){
		return true;
	}
	else {
		return false;
	}
}
