var corDestaque = "#FCE3E3";


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 = "#f9f9f9";}
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "#FFFFFF";}
         }
      }
   }

}


function AjustaTamanhoDivConteudo()
{
	var obj = document.getElementById("divConteudo");
	var intAltura = parseInt(document.body.clientHeight);

	obj.style.height = (intAltura-288) + "px";
}


function AjustaTamanhoObjeto(_strObjeto)
{
    var intLargura = parseInt(document.body.clientWidth);
    var intAltura = parseInt(document.body.clientHeight);
    var obj = document.getElementById(_strObjeto);

    obj.style.width = intLargura + "px";
    obj.style.height = intAltura + "px";
}


function showHide(objeto, intTipo)
{
	if (document.getElementById(objeto).style.display == "none")
	{
		document.getElementById(objeto).style.display = "block";
		//if (intTipo == 1) {	document.getElementById("divGeral").className = "alpha"; }
	}
	else
	{
		document.getElementById(objeto).style.display = "none";
		//if(intTipo == 1) { document.getElementById("divGeral").className = ""; }
	}
}


function validaDadosLogin()
{
  var corDestaque = "#FBDDDD";
  var strLogin = document.getElementById("txtLogin");
  var strSenha = document.getElementById("txtSenha");

  strLogin.style.background = "";
  strSenha.style.background = "";

  if (strLogin.value.length == 0)
  {
	  alert("O campo LOGIN é obrigatório !");
	  strLogin.style.background = corDestaque;
	  strLogin.focus();
	  return (false);
  }

  if (strSenha.value.length == 0)
  {
	  alert("O campo SENHA é obrigatório !");
	  strSenha.style.background = corDestaque;
	  strSenha.focus();
	  return (false);
  }

  return (true);
}


function validaDadosContato()
{
	var strNome = document.getElementById("txtNome");
	var strEmpresa = document.getElementById("txtEmpresa");
	var strTelefone = document.getElementById("txtTelefone");
	var strEmail = document.getElementById("txtEmail");
	var strMensagem = document.getElementById("txtMensagem");

	strNome.style.background = "";
	strEmpresa.style.background = "";
	strTelefone.style.background = "";
	strEmail.style.background = "";
	strMensagem.style.background = "";

	if (strNome.value.length == 0)
	{
		alert("O campo NOME é obrigatório !");
		strNome.style.background = corDestaque;
		strNome.focus();
		return (false);
	}

	if (!(ehNome(strNome.value)))
	{
		alert("Por favor, preencha o campo NOME corretamente !");
		strNome.style.background = corDestaque;
		strNome.focus();
		return (false);
	}

	if (strEmpresa.value.length == 0)
	{
		alert("O campo EMPRESA é obrigatório !");
		strEmpresa.style.background = corDestaque;
		strEmpresa.focus();
		return (false);
	}

	if (strTelefone.value.length == 0)
	{
		alert("O campo TELEFONE é obrigatório !");
		strTelefone.style.background = corDestaque;
		strTelefone.focus();
		return (false);
	}

	if (strEmail.value.length == 0)
	{
		alert("O campo E-MAIL é obrigatório !");
		strEmail.style.background = corDestaque;
		strEmail.focus();
		return (false);
	}

	if (!(ehEmail(strEmail.value)))
	{
		alert("Por favor, preencha o campo E-MAIL corretamente.");
		strEmail.style.background = corDestaque;
		strEmail.focus();
		return (false);
	}

	/***
	if (strMensagem.value.length == 0)
	{
		alert("O campo MENSAGEM é obrigatório !");
		strMensagem.style.background = corDestaque;
		strMensagem.focus();
		return false;
	}
	***/

	return true;
}


function ehNome(Source)
{
	var Texto="";
	
	Texto=Source;
	if (Texto!="")
	{//EXISTE VALOR
		if (Texto.length<3)
		{// NOME MUITO PEQUENO
			return(false);
		}//if
		if ((Texto.charAt(0)==Texto.charAt(1)) && (Texto.charAt(1)==Texto.charAt(2)))
		{//TRES PRIMEIRAS LETRAS IGUAIS, NAO E' UM NOME
			return(false);
		}//if
	}//if

	return(true);
}


function ehEmail(Source)
{
	var Pos=0;		//POSICAO DOS SIMBOLOS
	var Texto="";	//VALOR A SER TESTADO

	Texto=Source;
	if (Texto!="")
	{//EXISTE VALOR	
		Pos=Texto.indexOf("@",0);
		if ((Pos<=0) || (Pos==Texto.length-1))
		{//NAO PODE SER EMAIL NAO TEM @ OU COMECA POR @ OU TERMINA POR @
			return(false);
		}//if
		Pos=Texto.indexOf("@",Pos+1);
		if (Pos!=-1)
		{//NAO PODE SER EMAIL TEM 2 @
			return(false);
		}//if
	}//if

	return(true);
}


function AbrePopup(arquivo, largura, altura){
	if (largura == null && altura == null){booResize = "yes";}else{booResize = "no";}

	popup = open(arquivo,"popup1","resizable=" + booResize  +",scrollbars=yes,status=no,width=" + largura + ",height=" + altura + ",top="+(window.screen.height-altura)/2+",left="+(window.screen.width-largura)/2+"");
	popup.focus();	
}


function scrollOver(strMarquee){
	strMarquee.scrollAmount = "0";
	strMarquee.style.cursor = "default";
}


function scrollOut(strMarquee){
	strMarquee.scrollAmount = "3";
}


function openDW()
{
	AbrePopup("popup.asp?intModulo=13",400,300);	
}


function SubMenu(teste,url)
{
	var Estado = teste;
	var Link = url;
	var div = document.getElementById("divSubMenu2");

	if (Estado == 'entrou') {
		div.style.display = "block";
	}
	
	if (Estado == 'saiu') {
		div.style.display = "none"; 
	}
}


function ValidaParceiro() {
	var email;
	var senha;

	email = document.getElementById("txtLogin");
	senha = document.getElementById("txtSenha");
	
	if (email.value == "") {
		alert("Digite seu e-mail");
		email.focus();
		return false;
	}
	
	if (senha != null ) {
		if (senha.value == "") {
			alert("Digite a senha");
			senha.focus();
			return false;
		}
	}
	
	return true	
}