// JavaScript Document
/************************************************************************ 
Author: Eric Simmons
Contact: info@jswitch.com
Website: http://www.jswitch.com
Version: 1.0 4/2005       
Browser Target: Mozilla 6+/FireFox Netscape 6+, IE 5.0+
Type : XP style sliding dropdown menus (aka Switch Menu II on Dynamicdrive.com)
Note: Modification by Dynamicdrive.com to dynamically determine sub menus widths

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT
ANY EXPRESS OR IMPLIED WARRANTIES, JSWITCH.COM
IS NOT RESPONSIBLE FOR ANY ADVERSE AFFECTS TO
YOUR COMPUTER OR SYSTEMS RUNNING THIS SCRIPT.

LICENSE:
YOU ARE GRANTED THE RIGHT TO USE THE SCRIPT
PERSONALLY OR COMMERCIALLY. THE AUTHOR, WEBSITE LINKS 
AND LICENSE INFORMATION IN THE HEADER OF THIS SCRIPT
MUST NOT BE MODIFIED OR REMOVED. 

v 1.0
XP style sliding Menu Bar
endereço do tutorial
http://www.dynamicdrive.com/dynamicindex1/switchmenu2.htm
***********************************************************************/

var TIMER_SLIDE = null;
var OBJ_SLIDE;
var OBJ_VIEW;
var PIX_SLIDE = 10; //this is the amount of slide/DELAY_SLIDE
var NEW_PIX_VAL;
var DELAY_SLIDE = 30; //this is the time between each call to slide
var DIV_HEIGHT = 22; //value irrelevant
var SUB_MENU_NUM =0;
var RE_INIT_OBJ = null;
var bMenu = document.getElementById("curMenu");
var MainDiv,SubDiv

//DD added code
document.write('<div id="tempcontainer" class="mainDiv" style="visibility: hidden; position: absolute"></div>')

function Init(objDiv)
{
    if (TIMER_SLIDE == null)
    {
        SUB_MENU_NUM = 0;
        MainDiv = objDiv.parentNode;
        SubDiv =  MainDiv.getElementsByTagName("DIV").item(0);
        SubDiv.onclick = SetSlide;
        
        OBJ_SLIDE = MainDiv.getElementsByTagName("DIV").item(1)
        OBJ_VIEW = OBJ_SLIDE.getElementsByTagName("DIV").item(0);

				document.getElementById("tempcontainer").innerHTML=MainDiv.getElementsByTagName("DIV").item(2).innerHTML //DD added code
				DIV_HEIGHT=document.getElementById("tempcontainer").offsetHeight //DD added code
        
        for (i=0;i<OBJ_VIEW.childNodes.length;i++)
        {
            if (OBJ_VIEW.childNodes.item(i).tagName == "SPAN")
            {
                SUB_MENU_NUM ++;
                OBJ_VIEW.childNodes.item(i).onmouseover= ChangeStyle;
                OBJ_VIEW.childNodes.item(i).onmouseout= ChangeStyle;
            }
        }   
        
              NEW_PIX_VAL = parseInt(MainDiv.getAttribute("state")); 
    }

}

function SetSlide()
{   
			if (window.TIMER_SLIDE) clearInterval(TIMER_SLIDE) //DD added code
      if (TIMER_SLIDE == null && this.parentNode == MainDiv)
            TIMER_SLIDE = setInterval('RunSlide()', DELAY_SLIDE);
      else
      {
          RE_INIT_OBJ = this;
          setTimeout('ReInit()', 200);
      }
}

function ReInit(obj)
{
    Init(RE_INIT_OBJ);
    TIMER_SLIDE = setInterval('RunSlide()', DELAY_SLIDE);
    RE_INIT_OBJ = null;
}

function RunSlide()
{

    if (OBJ_VIEW.getAttribute("state") == 0)
    {

        NEW_PIX_VAL += PIX_SLIDE;
        OBJ_SLIDE.style.height = NEW_PIX_VAL;

        if (NEW_PIX_VAL >= DIV_HEIGHT) //DD modified code
        {
            clearInterval(TIMER_SLIDE);
            TIMER_SLIDE = null;
            OBJ_VIEW.style.display = 'inline';
            OBJ_VIEW.setAttribute("state","1")
            MainDiv.setAttribute("state",NEW_PIX_VAL);
        }
    } else
    {
        OBJ_VIEW.style.display = 'none';
        NEW_PIX_VAL -= PIX_SLIDE;
        if(NEW_PIX_VAL > 0)OBJ_SLIDE.style.height = NEW_PIX_VAL;
        if (NEW_PIX_VAL <= 0)
        {
            NEW_PIX_VAL = 0;
            OBJ_SLIDE.style.height = NEW_PIX_VAL
            clearInterval(TIMER_SLIDE);
            TIMER_SLIDE = null;
            OBJ_VIEW.setAttribute("state","0")
            MainDiv.setAttribute("state",NEW_PIX_VAL);
        }
    }
}

function ChangeStyle()
{
    if (this.className == this.getAttribute("classOut"))
        this.className = this.getAttribute("classOver");
    else
        this.className = this.getAttribute("classOut");
}

/********************************************************************************************************************************
	Fim do Menu
*/

function foto_produto(ID){
	window.open('php/foto_produto.php?IDProduto='+ID,'fotos','toolbars=0,height=370px,width=350px,top=10,left=50');	
	void(0);
}

function pesquisa(){
	var strPesquisa=document.formulario_pesquisa.txtPesquisa.value;
	if(strPesquisa==""){
		alert("Informe o produto que você deseja pesquisar");
		return false;
	}
	else if(strPesquisa.length<2){
		alert("A pesquisa deve ter no mínimo 2 caracteres");
		return false;
	}
}

function newsletter(nform){
	if (nform.txtEmail.value=="") {
		alert("Por favor informe seu email.");
		nform.txtEmail.focus();
		return false;
	}
	else {
		prim = nform.txtEmail.value.indexOf("@")
		if(prim < 2) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("@",prim + 1) != -1) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf(".") < 1) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf(" ") != -1) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("zipmeil.com") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("hotmeil.com") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("yaho.com") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("yaho.com.br") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("yahooo.com") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("yahooo.com.br") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf(".@") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("@.") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf(".com.br.") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("/") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("[") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("]") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("(") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf(")") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
		if(nform.txtEmail.value.indexOf("..") > 0) {
			alert("O email informado parece não estar correto.");
			nform.txtEmail.focus();
			nform.txtEmail.select();
			return false;
		}
	}
	return true;
}

function maiusculo(nform){
	nform.value=nform.value.toUpperCase();
}

function minusculo(nform){
	nform.value=nform.value.toLowerCase();
}

function Numeros(evtKeyPress){
	if (evtKeyPress.keyCode) nTecla = evtKeyPress.keyCode; //internet explorer
	else if (evtKeyPress.which) nTecla = evtKeyPress.which; // mozilla firefox
	
	if (nTecla != 8 ){ // backspace
		if (nTecla > 47 && nTecla < 58) { // apenas números...
			return true; // números de 0 a 9
		}
		else if( nTecla == 46 || nTecla == 9){// ponto e tecla tab
			return true;
		}
		else { // qualquer caracter...
			return false;
		} 
	}
}

/*
	função para fazer as máscaras da entrada do formulário de acordo com o algaritimo que você quiser
	usar a função desta maneira, colocar o nome do formulario e o nome do campo
	onKeyPress="return mascara(this, '999-999999', event);"
*/
function mascara(objForm, sMask, evtKeyPress) {
     var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

     if (evtKeyPress.keyCode) nTecla = evtKeyPress.keyCode; //internet explorer
	else if (evtKeyPress.which) nTecla = evtKeyPress.which; // mozilla firefox

     sValue = objForm.value;

     // Limpa todos os caracteres de formatação que
     // já estiverem no campo.
     sValue = sValue.toString().replace( "-", "" );
     sValue = sValue.toString().replace( "-", "" );
     sValue = sValue.toString().replace( ".", "" );
     sValue = sValue.toString().replace( ".", "" );
     sValue = sValue.toString().replace( "/", "" );
     sValue = sValue.toString().replace( "/", "" );
     sValue = sValue.toString().replace( "(", "" );
     sValue = sValue.toString().replace( "(", "" );
     sValue = sValue.toString().replace( ")", "" );
     sValue = sValue.toString().replace( ")", "" );
     sValue = sValue.toString().replace( " ", "" );
     sValue = sValue.toString().replace( " ", "" );
     fldLen = sValue.length;
     mskLen = sMask.length;

	i = 0;
	nCount = 0;
	sCod = "";
	mskLen = fldLen;
	
	while (i <= mskLen) {
		bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
		bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
		
		if (bolMask) {
			sCod += sMask.charAt(i);
			mskLen++;
		}
		else {
			sCod += sValue.charAt(nCount);
			nCount++;
		}
		i++;
	}

	objForm.value = sCod;

	if (nTecla != 8) { // backspace
		if (sMask.charAt(i-1) == "9") { // apenas números...
			return ((nTecla > 47) && (nTecla < 58)); // números de 0 a 9
		} 
		else { // qualquer caracter...
			return false;
		} 
	}
	else {
		return true;
	}
}

function adicionar_carrinho(){
	document.form_carrinho.submit();
}

function cadastra_cliente(nform){
	// pegar o valor da pessoa que foi postado
	for (i=0; i<nform.txtTipo.length; i++){
		if (nform.txtTipo[i].checked) {
			tipoPessoa = nform.txtTipo[i].value;
		}
	}
	if(nform.txtEmail.value==""){
		alert("Por favor informe seu email");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".@")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@.")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(" ")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtSenha.value==""){
		alert("Por favor informe sua senha");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value.length<6){
		alert("Sua senha deve conter no mínimo 6 caracteres");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value.length>10){
		alert("Sua senha deve conter no máximo 10 caracteres");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value != nform.txtSenhaRepete.value){
		alert("As senha devem ser iguais");
		nform.txtSenhaRepete.select();
		return false;
	}
	else if(tipoPessoa=="Pessoa Física"){
		if(nform.txtTratamento.value==""){
			alert("Por favor informe a maneira que gostaria de ser tratado. Ex: Um apelido, Sr, Sra");
			nform.txtTratamento.select();
			return false;
		}
		if(nform.txtNome.value==""){
			alert("Por favor informe seu nome");
			nform.txtNome.select();
			return false;
		}
		if(nform.txtSobreNome.value==""){
			alert("Por favor informe seu sobrenome");
			nform.txtSobreNome.select();
			return false;
		}
		if(nform.txtCPF.value==""){
			alert("Por favor informe seu CPF");
			nform.txtCPF.select();
			return false;
		}
		if(CPF==00000000000 || CPF==11111111111 || CPF==22222222222 || CPF==33333333333 || CPF==44444444444|| CPF==55555555555 || CPF==66666666666 || CPF==77777777777 || CPF==88888888888 || CPF==99999999999){
			alert("CPF inválido");
			nform.txtCPF.select();
			return false;
		}
		if(nform.txtCPF.value!=""){
			var CPF = nform.txtCPF.value; // Recebe o valor digitado no campo
			CPF = CPF.replace(".","");
			CPF = CPF.replace(".","");
			CPF = CPF.replace("-","");
							
			// Aqui começa a checagem do CPF
			var POSICAO, I, SOMA, DV, DV_INFORMADO;
			var DIGITO = new Array(10);
			DV_INFORMADO = CPF.substr(9, 2); // Retira os dois últimos dígitos do número informado
			
			// Desemembra o número do CPF na array DIGITO
			for (I=0; I<=8; I++) {
			  DIGITO[I] = CPF.substr( I, 1);
			}
			
			// Calcula o valor do 10º dígito da verificação
			POSICAO = 10;
			SOMA = 0;
			   for (I=0; I<=8; I++) {
				 SOMA = SOMA + DIGITO[I] * POSICAO;
				 POSICAO = POSICAO - 1;
			   }
			DIGITO[9] = SOMA % 11;
			   if (DIGITO[9] < 2) {
				   DIGITO[9] = 0;
			}
			   else{
				  DIGITO[9] = 11 - DIGITO[9];
			}
			
			// Calcula o valor do 11º dígito da verificação
			POSICAO = 11;
			SOMA = 0;
			   for (I=0; I<=9; I++) {
				 SOMA = SOMA + DIGITO[I] * POSICAO;
				 POSICAO = POSICAO - 1;
			   }
			DIGITO[10] = SOMA % 11;
			   if (DIGITO[10] < 2) {
				   DIGITO[10] = 0;
			   }
			   else {
				   DIGITO[10] = 11 - DIGITO[10];
			   }
			
			// Verifica se os valores dos dígitos verificadores conferem
			DV = DIGITO[9] * 10 + DIGITO[10];
			  if (DV != DV_INFORMADO) {
				 alert('CPF inválido');
				 nform.txtCPF.select();
				 return false;
			   } 	
		}
		if(nform.txtRG.value==""){
			alert("Por favor informe seu RG");
			nform.txtRG.select();
			return false;
		}
		if(nform.txtNascimento.value.length<10){
			alert("Por favor informe a data completa do seu nascimento. Ex: dd/mm/aaaa");
			nform.txtNascimento.select();
			return false;
		}
		if(nform.txtSexo.value==""){
			alert("Por favor informe seu sexo");
			return false;
		}
		// Validação do endereço
		if(nform.txtTipoEndereco.value==""){
			alert("Por favor informe o tipo de endereço");
			return false;
		}
		if(nform.txtEndereco.value==""){
			alert("Por favor informe o endereço");
			nform.txtEndereco.select();
			return false;
		}
		if(nform.txtNumero.value==""){
			alert("Por favor informe o número");
			nform.txtNumero.select();
			return false;
		}
		if(nform.txtBairro.value==""){
			alert("Por favor informe o bairro");
			nform.txtBairro.select();
			return false;
		}
		if(nform.txtCidade.value==""){
			alert("Por favor informe a cidade");
			nform.txtCidade.select();
			return false;
		}
		if(nform.txtEstado.value==""){
			alert("Por favor informe o estado");
			return false;
		}
		if(nform.txtCEP.value==""){
			alert("Por favor informe o CEP");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtCEP.value.length<10){
			alert("O CEP deve conter 8 dígitos ex: 38.205-000");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtFone.value==""){
			alert("Por favor informe um telefone para contato");
			nform.txtFone.select();
			return false;
		}
		if(nform.txtFone.value.length<14){
			alert("Por favor informe o telefone completo com o DD. Ex. (xx) 3330-5595");
			nform.txtFone.select();
			return false;
		}
	}
	else if(tipoPessoa=="Pessoa Jurídica"){
		if(nform.txtRazaoSocial.value==""){
			alert("Por favor informe a Razão Social da empresa");
			nform.txtRazaoSocial.select();
			return false;
		}
		if(nform.txtNomeContato.value==""){
			alert("Por favor informe o nome da Pessoa para contato dentro da empresa");
			nform.txtNomeContato.select();
			return false;
		}
		if(nform.txtCNPJ.value==""){
			alert("Por favor informe o C.N.P.J da empresa");
			nform.txtCNPJ.select();
			return false;
		}
		if(nform.txtCNPJ.value!=""){
			CNPJ = nform.txtCNPJ.value;
			erro = new String;
			if (CNPJ.length < 18) erro += "É necessarios preencher corretamente o numero do CNPJ";
			if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
				if (erro.length == 0) erro += "CNPJ inválido";
			}
			//substituir os caracteres que nao sao numeros
			if(document.layers && parseInt(navigator.appVersion) == 4){
				x = CNPJ.substring(0,2);
				x += CNPJ.substring(3,6);
				x += CNPJ.substring(7,10);
				x += CNPJ.substring(11,15);
				x += CNPJ.substring(16,18);
				CNPJ = x;	
			}
			else {
				CNPJ = CNPJ.replace(".","");
				CNPJ = CNPJ.replace(".","");
				CNPJ = CNPJ.replace("-","");
				CNPJ = CNPJ.replace("/","");
			}
			var nonNumbers = /\D/;
			if (nonNumbers.test(CNPJ)) erro += "CNPJ inválido";	
			var a = [];
			var b = new Number;
			var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
			for (i=0; i<12; i++){
				a[i] = CNPJ.charAt(i);
				b += a[i] * c[i+1];
			}
			if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
			b = 0;
			for (y=0; y<13; y++) {
				b += (a[y] * c[y]); 
			}
			if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
			if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
				erro +="CNPJ inválido";
			}
			if (erro.length > 0){
				alert(erro);
				nform.txtCNPJ.select();
				return false;
			}
		}
		if(nform.txtIE.value=="" && nform.txtIE_isento.checked==""){
			alert("Por favor informe a Inscrição Estadual da empresa");
			nform.txtIE.select();
			return false;
		}
		if(nform.txtIE.value!="" && nform.txtIE_isento.checked!=""){
			alert("Por favor informe somente uma opção sobre a Inscrição Estadual");
			nform.txtIE.select();
			return false;
		}
		// Validação do endereço
		else if(nform.txtTipoEndereco.value==""){
			alert("Por favor informe o tipo de endereço");
			return false;
		}
		else if(nform.txtEndereco.value==""){
			alert("Por favor informe o endereço");
			nform.txtEndereco.select();
			return false;
		}
		else if(nform.txtNumero.value==""){
			alert("Por favor informe o número");
			nform.txtNumero.select();
			return false;
		}
		else if(nform.txtBairro.value==""){
			alert("Por favor informe o bairro");
			nform.txtBairro.select();
			return false;
		}
		else if(nform.txtCidade.value==""){
			alert("Por favor informe a cidade");
			nform.txtCidade.select();
			return false;
		}
		else if(nform.txtEstado.value==""){
			alert("Por favor informe o estado");
			return false;
		}
		else if(nform.txtCEP.value==""){
			alert("Por favor informe o CEP");
			nform.txtCEP.select();
			return false;
		}
		else if(nform.txtFone.value==""){
			alert("Por favor informe um telefone para contato");
			nform.txtFone.select();
			return false;
		}
		else if(nform.txtFone.value.length<14){
			alert("Por favor informe o telefone completo com o DD. Ex. (xx) 3330-5595");
			nform.txtFone.select();
			return false;
		}
	}
}

function envia_contato(nform){
	if(nform.txtObjetivo.value==""){
		alert("Por favor informe o Objetivo do seu contato");
		return false;
	}
	else if(nform.txtNome.value==""){
		alert("Por favor informe o seu nome");
		nform.txtNome.select();
		return false;
	}
	else if(nform.txtEmail.value==""){
		alert("Por favor informe seu email");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".@")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@.")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(" ")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtAssunto.value==""){
		alert("Por favor o assunto do seu email");
		nform.txtAssunto.select();
		return false;
	}
	else if(nform.txtMensagem.value==""){
		alert("Por favor escreva a mensagem");
		nform.txtMensagem.select();
		return false;
	}
}

function grava_frete(nform){
	if(nform.frete.value==""){
		alert("Escolha um local para o frete");
		return false;
	}
}

function confirma_deposito(nform){
	if(nform.txtNumPedido.value==""){
		alert("Informe o número do pedido a ser confirmado");
		nform.txtNumPedido.focus();
		return false;
	}
	else if(nform.agencia_deposito.value==""){
		alert("Informe o número da agência onde você fez o depósito");
		nform.agencia_deposito.focus();
		return false;
	}
	else if(nform.data_deposito.value==""){
		alert("Informe a data do depósito");
		nform.data_deposito.focus();
		return false;
	}
	else if(nform.data_deposito.value.length < 10){
		alert("Informe a data completa - Ex.: 25/12/2000");
		nform.data_deposito.focus();
		return false;
	}
	else if(nform.hora_deposito.value==""){
		alert("Informe a hora do depósito");
		nform.hora_deposito.focus();
		return false;
	}
	else if(nform.hora_deposito.value.length < 8){
		alert("Informe a hora completa - Ex.: 22-15-25");
		nform.hora_deposito.focus();
		return false;
	}
	else if(nform.valor_deposito.value==""){
		alert("Informe o valor do depósito");
		nform.valor_deposito.focus();
		return false;
	}
	else if(nform.num_deposito.value==""){
		if(confirm("Você não informou o número do depósito / transferência. Deseja confirmar o pagamento sem esta informação?")){
			return true;	
		}
		else{
			return false;	
		}
	}
}

function altera_entrega(nform){
	if(nform.txt_endereco.value==""){
		alert("Informe o endereço para a entrega do pedido.");
		nform.txt_endereco.focus();
		return false;
	}
	else if(nform.txt_numero.value==""){
		alert("Informe o número do endereço de entrega do pedido");
		nform.txt_numero.focus();
		return false;
	}
	else if(nform.txt_bairro.value==""){
		alert("Informe o bairro do endereço de entrega.");
		nform.txt_bairro.focus();
		return false;
	}
	else if(nform.txt_cidade.value==""){
		alert("Informe a cidade da entrega do pedido.");
		nform.txt_bairro.focus();
		return false;
	}
	else if(nform.txt_estado.value==""){
		alert("Informe o estado da entrega do pedido.");
		return false;
	}
	else if(nform.txt_cep.value==""){
		alert("Informe o CEP da entrega do pedido.");
		nform.txt_cep.focus();
		return false;
	}
	else if(nform.txt_cep.value.length < 10){
		alert("Informe o CEP completo. Ex.: 31.120-120");
		nform.txt_cep.focus();
		return false;
	}
	else{
		if(confirm("Todos os dados fornecidos deverão estar corretos para que seu pedido seja entregue com eficiência.\nDeseja confirmar a alteração do Endereço de Entrega?")){
			return true;
		}	
		else{
			return false;
		}
	}
}

function valida_cartao(nform){
	preencheu = false;
	botoes = nform.operadora_cartao.length;
	for (i=0;i<botoes;i++) {
		if (nform.operadora_cartao[i].checked) {
			preencheu = true;
			break;
		}
	}
	if (preencheu) {
		if(nform.nome_cartao.value==""){
			alert("Informe o nome que está escrito no seu Cartão de Crédito.");
			nform.nome_cartao.focus();
			return false;		
		}
		else if(nform.mes_validade_cartao.value==""){
			alert("Informe o mês da validade de seu Cartão de Crédito.");
			return false;		
		}
		else if(nform.ano_validade_cartao.value==""){
			alert("Informe até que ano seu Cartão de Crédito é valido.");
			return false;		
		}
		else if(nform.numero_cartao.value==""){
			alert("Informe o número do seu Cartão de Crédito.");
			nform.numero_cartao.focus();
			return false;		
		}
		else if(nform.id_cartao.value==""){
			alert("Informe o número de identificação do seu Cartão de Crédito.");
			nform.id_cartao.focus();
			return false;		
		}
		else{
			if(confirm("IMPORTANTE: Todos os dados deverão estar corretos para que seu pedido possa ser pago. Clique em OK para confirmar o pagamento.")){
				nform.submit();
			}
			else{
				return false;
			}
		}
	}
	else {
		alert("Informe a operadora do seu Cartão de Crédito");
		return false;
	}
}

function seja_fornecedor(nform){
	if(nform.txtContato.value==""){
		alert("Informe o nome da pessoa para contato na empresa.");
		nform.txtContato.focus();
		return false;
	}
	else if(nform.txtNome.value==""){
		alert("Informe o nome da empresa.");
		nform.txtNome.focus();
		return false;
	}
	else if(nform.txtAtuacao.value==""){
		alert("Informe o ramo de atuação da empresa.");
		nform.txtAtuacao.focus();
		return false;
	}
	else if(nform.txtEmail.value==""){
		alert("Informe um email para contato.");
		nform.txtEmail.focus();
		return false;
	}
	else if(nform.txtEndereco.value==""){
		alert("Informe o endereco da empresa.");
		nform.txtEndereco.focus();
		return false;
	}
	else if(nform.txtNumero.value==""){
		alert("Informe o número do endereço da empresa.");
		nform.txtNumero.focus();
		return false;
	}
	else if(nform.txtBairro.value==""){
		alert("Informe o bairro do endereço da empresa.");
		nform.txtBairro.focus();
		return false;
	}
	else if(nform.txtCidade.value==""){
		alert("Informe a cidade onde a empresa está sediada.");
		nform.txtCidade.focus();
		return false;
	}
	else if(nform.txtEstado.value==""){
		alert("Informe o estado onde a empresa está sediada");
		return false;
	}
	else if(nform.txtCEP.value.length < 10){
		alert("Inform o CEP de onde a empresa está sediada. Ex.: 32.112-152");
		nform.txtCEP.focus();
		return false;
	}
	else if(nform.txtFone.value.length < 14){
		alert("Informe o telefone da empresa. Ex.: (31) 3112-5152");
		nform.txtFone.focus();
		return false;
	}
	else if(nform.txtMensagem.value==""){
		alert("Informe o que sua empresa tem interesse em comercializar.");
		nform.txtMensagem.focus();
		return false;
	}
}

function altera_cadastro_cliente(nform){
	if(nform.txtEmail.value==""){
		alert("Por favor informe seu email");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".")<1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(".@")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf("@.")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}
	else if(nform.txtEmail.value.indexOf(" ")>1){
		alert("O email informado parece não estar correto");
		nform.txtEmail.select();
		return false;
	}else if(nform.txtSenha.value==""){
		alert("Por favor informe sua senha");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value.length<6){
		alert("Sua senha deve conter no mínimo 6 caracteres");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value.length>10){
		alert("Sua senha deve conter no máximo 10 caracteres");
		nform.txtSenha.select();
		return false;
	}
	else if(nform.txtSenha.value != nform.txtSenhaRepete.value){
		alert("As senha devem ser iguais");
		nform.txtSenhaRepete.select();
		return false;
	}	
	else if(nform.tipo.value=="Pessoa Física"){
		// Validação do endereço
		if(nform.txtTipoEndereco.value==""){
			alert("Por favor informe o tipo de endereço");
			return false;
		}
		if(nform.txtEndereco.value==""){
			alert("Por favor informe o endereço");
			nform.txtEndereco.select();
			return false;
		}
		if(nform.txtNumero.value==""){
			alert("Por favor informe o número");
			nform.txtNumero.select();
			return false;
		}
		if(nform.txtBairro.value==""){
			alert("Por favor informe o bairro");
			nform.txtBairro.select();
			return false;
		}
		if(nform.txtCidade.value==""){
			alert("Por favor informe a cidade");
			nform.txtCidade.select();
			return false;
		}
		if(nform.txtEstado.value==""){
			alert("Por favor informe o estado");
			return false;
		}
		if(nform.txtCEP.value==""){
			alert("Por favor informe o CEP");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtCEP.value.length<10){
			alert("O CEP deve conter 8 dígitos ex: 38.205-000");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtFone.value==""){
			alert("Por favor informe um telefone para contato");
			nform.txtFone.select();
			return false;
		}
		if(nform.txtFone.value.length<14){
			alert("Por favor informe o telefone completo com o DD. Ex. (xx) 3330-5595");
			nform.txtFone.select();
			return false;
		}
	}
	else if(nform.tipo.value=="Pessoa Jurídica"){
		if(nform.txtNomeContato.value==""){
			alert("Por favor informe o nome da Pessoa para contato dentro da empresa");
			nform.txtNomeContato.select();
			return false;
		}
		// Validação do endereço
		if(nform.txtTipoEndereco.value==""){
			alert("Por favor informe o tipo de endereço");
			return false;
		}
		if(nform.txtEndereco.value==""){
			alert("Por favor informe o endereço");
			nform.txtEndereco.select();
			return false;
		}
		if(nform.txtNumero.value==""){
			alert("Por favor informe o número");
			nform.txtNumero.select();
			return false;
		}
		if(nform.txtBairro.value==""){
			alert("Por favor informe o bairro");
			nform.txtBairro.select();
			return false;
		}
		if(nform.txtCidade.value==""){
			alert("Por favor informe a cidade");
			nform.txtCidade.select();
			return false;
		}
		if(nform.txtEstado.value==""){
			alert("Por favor informe o estado");
			return false;
		}
		if(nform.txtCEP.value==""){
			alert("Por favor informe o CEP");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtCEP.value.length<10){
			alert("O CEP deve conter 8 dígitos ex: 38.205-000");
			nform.txtCEP.select();
			return false;
		}
		if(nform.txtFone.value==""){
			alert("Por favor informe um telefone para contato");
			nform.txtFone.select();
			return false;
		}
		if(nform.txtFone.value.length<14){
			alert("Por favor informe o telefone completo com o DD. Ex. (xx) 3330-5595");
			nform.txtFone.select();
			return false;
		}
	}
}

function foca_id(id){
	if(id==1){
		document.getElementById('primeira').checked = true;
		return true;
	}
	else{
		document.getElementById('cliente').checked = true;
		return true;
	}
}

function flash(largura, altura, arquivo, transparencia){
 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
 document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="'+transparencia+'" /><param name="menu" value="false" />');
 document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="'+transparencia+'" menu="false" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
 document.write('</object>');
}


//************************************************************************************************************************
// Javasript Pamplona

function animastatus() {
	texto="Ambiente Solução - O seu shopping de informática - Notebboks, Câmeras Digitais e toda a linha de Computadores.";
	i=0;
	status=texto.substring(0,i);
	i++;
	if(i>texto.length) i = 0;
	setTimeout('animastatus()',100);
}
/*
function SymError(){
  return true;
}

window.onerror = SymError;

function SymError(){
  return true;
}

window.onerror = SymError;

function valida(){
	if(frm1.regiao.selectedIndex==0){
		alert("Escolha sua região");
		return false;
	}
	if(frm1.processador.selectedIndex==0){
		alert("Escolha um processador");
		return false;
	}
}

function SymError(){
  return true;
}

window.onerror = SymError;

function btdireito(){
	if(event.button==2)
}*/
