
/*
     * @copyright    Lognet Informática, 2008.
     * @since        Maio, 2008
     * @version      2.0
     * @access       public
     * @author       Rubén Miní Rodríguez
	 * @email        rmini83@hotmail.com
     */

/*Método habilitando o SWF*/
function flash(largura, altura, arquivo){
	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="transparent"/>');
	document.write('<param name="movie" value="'+arquivo+'?nada=<? echo rand (1,999);?>" /><param name="quality" value="best"/><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" 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>');
}

/*Método validando a Pesquisa*/
function valida_Pesquisar(forma){
 var flag = true;
 cadena = forma.descrip.value; 
 cadena = cadena.replace(/(^\s*)|(\s*$)/g,""); 
 if (cadena.length == 0){	
  alert("Digite um valor de pesquisa.");
  forma.descrip.focus();
  flag	= false;
  }else{
  if ( forma.descrip.value.length < 2 ){	
 alert("A pesquisa necessita de pelo menos 2 caracteres.");
 forma.descrip.focus();
 flag	= false;
 	}
}
if ( flag ){
     forma.submit();
	}
}

/* Método que acrescenta o valor do orçamento */
function calcularPreco(valorInicial){
	
 indice= document.frmProc.hd.selectedIndex;
 conteudo = document.frmProc.hd.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idb"+(indice-1);
 var valorHd=document.getElementById(indice).value;
}
else
valorHd=0;

 indice=document.frmProc.hd1.selectedIndex;
 conteudo = document.frmProc.hd1.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idb"+(indice-1);
 var valorHd1=document.getElementById(indice).value;
}
else
valorHd1=0;

 indice=document.frmProc.ram.selectedIndex;
 conteudo = document.frmProc.ram.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idd"+(indice-1);
   var valorRam=document.getElementById(indice).value;
}
else
valorRam=0;

indice=document.frmProc.ram1.selectedIndex;
 conteudo = document.frmProc.ram1.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idd"+(indice-1);
   var valorRam1=document.getElementById(indice).value;
}
else
valorRam1=0;

 indice=document.frmProc.video.selectedIndex;
 conteudo = document.frmProc.video.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "ide"+(indice-1);
   var valorVideo=document.getElementById(indice).value;
}
else
valorVideo=0;

 indice=document.frmProc.captura.selectedIndex;
 conteudo = document.frmProc.captura.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idp"+(indice-1);
   var valorCaptura=document.getElementById(indice).value;
}
else
valorCaptura=0;

 indice=document.frmProc.rede.selectedIndex;
 conteudo = document.frmProc.rede.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idf"+(indice-1);
   var valorRede=document.getElementById(indice).value;
}
else
valorRede=0;

 indice=document.frmProc.som.selectedIndex;
 conteudo = document.frmProc.som.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idg"+(indice-1);
   var valorSom=document.getElementById(indice).value;
}
else
valorSom=0;

 indice=document.frmProc.monitor.selectedIndex;
 conteudo = document.frmProc.monitor.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idh"+(indice-1);
   var valorMonitor=document.getElementById(indice).value;
}
else
valorMonitor=0;

indice=document.frmProc.gabinete.selectedIndex;
 conteudo = document.frmProc.gabinete.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idi"+(indice-1);
   var valorGabinete=document.getElementById(indice).value;
}
else
valorGabinete=0;

indice=document.frmProc.impressora.selectedIndex;
 conteudo = document.frmProc.impressora.options[indice].text;
   if (conteudo != "[Selecionar]" && conteudo != "--")  {
   indice = "idj"+(indice-1);
   var valorImpressora=document.getElementById(indice).value;
}
else
valorImpressora=0;

 indice=document.frmProc.otico.selectedIndex;
 conteudo = document.frmProc.otico.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idk"+(indice-1);
 var valorOtico=document.getElementById(indice).value;
}
else
valorOtico=0;

 indice=document.frmProc.energia.selectedIndex;
 conteudo = document.frmProc.energia.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idk1"+(indice-1);
 var valorEnergia=document.getElementById(indice).value;
}
else
valorEnergia=0;


 indice=document.frmProc.teclado.selectedIndex;
 conteudo = document.frmProc.teclado.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idl"+(indice-1);
 var valorTeclado=document.getElementById(indice).value;
}
else
valorTeclado=0;

 indice=document.frmProc.mouse.selectedIndex;
 conteudo = document.frmProc.mouse.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idm"+(indice-1);
 var valorMouse=document.getElementById(indice).value;
}
else
valorMouse=0;

 indice=document.frmProc.caixaSom.selectedIndex;
 conteudo = document.frmProc.caixaSom.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "idn"+(indice-1);
 var valorCaixaSom=document.getElementById(indice).value;
}
else
valorCaixaSom=0;

 indice=document.frmProc.placamae.selectedIndex;
 conteudo = document.frmProc.placamae.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "ida"+(indice-1);
 var valorPlacamae=document.getElementById(indice).value;
}
else
valorPlacamae=0;

 indice=document.frmProc.software.selectedIndex;
 conteudo = document.frmProc.software.options[indice].text;
 if (conteudo != "[Selecionar]" && conteudo != "--")  {
 indice = "ido"+(indice-1);
 var valorSoftware=document.getElementById(indice).value;
}
else
valorSoftware=0;


conteudo = document.getElementById('disk');
if (conteudo.value == "Sim"){
	var valorDisk = 20;
	} 
	else {
	valorDisk =0;
	}
var subTotal = parseFloat(valorInicial)+parseFloat(valorPlacamae)+parseFloat(valorHd)+parseFloat(valorHd1)+ parseFloat(valorRam);
subTotal = subTotal+parseFloat(valorRam1)+parseFloat(valorVideo)+parseFloat(valorRede)+parseFloat(valorSom)+parseFloat(valorCaptura);
subTotal = subTotal + parseFloat(valorMonitor)+parseFloat(valorGabinete)+parseFloat(valorImpressora)+parseFloat(valorOtico);
subTotal = subTotal + parseFloat(valorEnergia)+parseFloat(valorTeclado)+parseFloat(valorMouse)+parseFloat(valorCaixaSom)+parseFloat(valorSoftware);
subTotal = subTotal + valorDisk;

var quantidadeParcelas = parseInt(subTotal/20);
if (quantidadeParcelas == 0){
	quantidadeParcelas =1;
}
else if(quantidadeParcelas > 10)
{ quantidadeParcelas = 10;
	
	}
	
var valorParcela = subTotal/quantidadeParcelas;

var subTotalDesconto = Math.round(subTotal - 8*subTotal/100);

var subTotalText = document.getElementById('subtotal');

var subtotalPHP = document.getElementById('subtotalPHP');

subtotalPHP.value = subTotal;

subTotalText.value = float2moeda(subTotal);

var subTotalDescontoText = document.getElementById('subTotalDesconto');

subTotalDescontoText.value = float2moeda(subTotalDesconto);

var total = document.getElementById('total');
var quantidadeParcelasText = document.getElementById('quantidadeParcelas');
quantidadeParcelasText.value = quantidadeParcelas;
var totalParcelaText = document.getElementById('totalParcela');
totalParcelaText.value = float2moeda(valorParcela);
}

function float2moeda(num) {
 x = 0;
 if(num<0) {
 num = Math.abs(num);
 x = 1;
} if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);
num = Math.floor((num*100+0.5)/100).toString();
if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'
+num.substring(num.length-(4*i+3)); ret = num + ',' + cents; if (x == 1) ret = ' - ' + ret;return ret;
}


/*Método para validar o processamento do Orçamento*/
function validaOrcamento() {
 var form = document.getElementById("frmProc");
 if (form.processador.value != "[Selecionar]"){
  form.action = "orcamento.process.php";
  form.submit();
 }
  else{
   alert ("Deve selecionar o processador");
   form.processador.focus();
  }
}

/*Método para validar o processamento do Orçamento*/
function imprimeOrcamento() {
 var form = document.getElementById("frmProc");
  if (form.processador.value != "[Selecionar]"){
  form.action = "imporcamento.php";
  form.submit();}
  else{
   alert ("Deve selecionar o processador");
   form.processador.focus();
  }
}

function carrinhoOrcamento() {
 var form = document.getElementById("frmProc");
  if (form.processador.value != "[Selecionar]"){
  form.action = "compra.php";
  form.submit();}
  else{
   alert ("Deve selecionar o processador");
   form.processador.focus();
  }
}

/* Método  mostrando a informação referente ao produto selecionado em Orçamento*/
function infoProduto(produto){
 if (produto.value!="[Selecionar]"){
  openWindowScroll('produtoInfo.php?idProduto='+produto.value,800,600, 'no');
}
}

/* Método mostrando o popup referente a indique a um amigo*/
function indiqueForm(idProduto){
 openWindow('indique.php?idProduto='+idProduto,450,365, 'no');
}

/* Método mostrando o popup referente a indique Twitter*/
function indiqueTwitter(){
 openWindow('indiqueTwitter.php',450,365, 'no');
}

/* Método mostrando o popup referente a alerta de preço*/
function alertForm(idProduto){
 openWindow('alertform.php?idProduto='+idProduto,450,400, 'no');
}

/* Método mostrando o popup referente ao Atendimento*/
function AtendForm(){
 openWindow('onchat/client_form.php',450,400, 'no');
}

/* Método mostrando o popup referente ao Enquete*/
function showEnquete(numeroEnquete){
var i;
for (i=0;i<document.EnqueteForm.enqueteR.length;i++){
       if (document.EnqueteForm.enqueteR[i].checked){
  	    document.EnqueteForm.camposelect.value = document.EnqueteForm.enqueteR[i].value;
        break;}
    }

openWindow('resenquete.php?camposelect='+document.EnqueteForm.camposelect.value+'&idenquete='+numeroEnquete,600,200, 'no');
}

/* Método validando o popup referente a indique a um amigo*/
function validaIndique(forma,codigo){
 mensagemErro="Por favor preencha corretamente:";
 if (forma.nomeDestinatario.value == ""){
  mensagemErro+="\n\n . Nome do Destinatário";
 } 
 if ((forma.emailDestinatario.value == "") || (forma.emailDestinatario.value.indexOf("@")==-1) || (forma.emailDestinatario.value.indexOf(".")==-1)){
		mensagemErro+="\n\n . Email do Destinatário";
 } 
 if (forma.nomeRemitente.value == "") {
   mensagemErro+="\n\n . Nome do Remitente";
} 
 if ((forma.emailRemitente.value == "") || (forma.emailRemitente.value.indexOf("@")==-1) || (forma.emailRemitente.value.indexOf(".")==-1)){
  mensagemErro+="\n\n . Email do Remitente";
} 
 if  (mensagemErro== "Por favor preencha corretamente:"){
     forma.codigoProduto.value=codigo;
	 forma.submit();
}
 else{
   alert(mensagemErro);
}
}

/* Método para abrir uma janela com scroll*/
function openWindowScroll(url,largura,altura,status){
 var pagina		= url;
 var nomeJanela	= "popupNovo";
 window.open(url, nomeJanela, "top=10, left=100, width="+parseInt(largura)+", height="+parseInt(altura)+", maximized=no, toolbar=no, location=no, status="+status+", menubar=no, scrollbars=yes, scrolling=yes, resizebled=no");
}

/* Método para abrir uma janela sem scroll*/
function openWindow(url,largura,altura,status ){
 var pagina		= url;
 var nomeJanela	= "popupNovo";
 window.open(url, nomeJanela, "top=10, left=100, width="+parseInt(largura)+", height="+parseInt(altura)+", maximized=no, toolbar=no, location=no, status="+status+", menubar=no, scrollbars=no, scrolling=no, resizebled=no");
}

function concluirPedido(frete,rev){ 

 if (rev == 1){
	 alert('Clientes de revenda somente poderão consultar preços')	;
  }
   else { window.location.href='cfrete.php';}

	}

function validaEmail_Submit_Set(forma){ 

 if(forma.email.value.indexOf("@")==-1 || forma.email.value.indexOf(".")==-1){ 
		alert("O campo email não está preenchido corretamente!"); 
		forma.email.focus(); 
	} 
	else {
		forma.submit();
		}
} 

function validaEmailBlur(campo){
	if( (campo.value.indexOf("@")==-1 || campo.value.indexOf(".")==-1) && (campo.value !="")){ 
		campo.style.borderColor='#990000';
		campo.focus(); 
	} 
	else {
  	 campo.style.borderColor='#58AEF5';
		}
	}

function Mascara(objeto, evt, mask) {
var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var Numeros = '0123456789';
var Fixos  = '().-:/ '; 
var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
evt = (evt) ? evt : (window.event) ? window.event : "";
var value = objeto.value;
if (evt) {
 var ntecla = (evt.which) ? evt.which : evt.keyCode;
 tecla = Charset.substr(ntecla - 32, 1);
 if (ntecla < 32) return true;
 var tamanho = value.length;
 if (tamanho >= mask.length) return false;
 var pos = mask.substr(tamanho,1); 
 while (Fixos.indexOf(pos) != -1) {
  value += pos;
  tamanho = value.length;
  if (tamanho >= mask.length) return false;
  pos = mask.substr(tamanho,1);
 }
 switch (pos) {
   case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
   case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
   case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
   case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
   case '*' : objeto.value = value; return true; break;
   default : return false; break;
 }
}
objeto.value = value; 
return true;
}

/*Máscara para CEP*/
function MaskCEP(objeto, evt) { 
	return Mascara(objeto, evt, '##.###-###');
}

/*Máscara para Telefone*/
function MaskTelefone(objeto, evt) { 
	return Mascara(objeto, evt, '####-####');
}

/*Máscara Inscrição Estadual*/
function MaskInscEstadual(objeto, evt) { 
	return Mascara(objeto, evt, '###.###.###.###');
}

/*Máscara CPF*/
function MaskCPF(objeto, evt) { 
	return Mascara(objeto, evt, '###.###.###-##');
}

/*Máscara CNPJ*/
function MaskCNPJ(objeto, evt) { 
	return Mascara(objeto, evt, '##.###.###/####-##');
}

/* Método para validar o envio da Mensagem em Contato pra Loja*/
function validaContato(forma){
 mensagemErro="Por favor preencha corretamente:";
 if (forma.assunto.value == "" || forma.assunto.value == "null"){
 mensagemErro+="\n\n . Assunto a tratar";
 } 
 if (forma.nome.value == "") {
		mensagemErro+="\n\n . Seu Nome";
 } 

 if ((forma.email.value == "") || (forma.email.value.indexOf("@")==-1) || (forma.email.value.indexOf(".")==-1)){
  mensagemErro+="\n\n . Seu Email";
} 
 if  (mensagemErro== "Por favor preencha corretamente:"){
	 forma.submit();
}
 else{
   alert(mensagemErro);
}
	}

/* Método para validar o envio da Mensagem em Cotação pra Loja*/
function validaCotacao(forma){
 mensagemErro="Por favor preencha corretamente:";
 if (forma.nomeEmpresa.value == "" || forma.nomeEmpresa.value == "null"){
 mensagemErro+="\n\n . Nome da empresa";
 } 
 if (forma.razaoEmpresa.value == "") {
		mensagemErro+="\n\n . Razão social da empresa";
 }
 
 if (forma.cnpjEmpresa.value == "") {
		mensagemErro+="\n\n . CNPJ da empresa";
 }
 
 if (forma.nomeContato.value == "") {
		mensagemErro+="\n\n . Nome para contato";
 }
 
 if (forma.funcaoContato.value == "") {
		mensagemErro+="\n\n . Função que ocupa na empresa";
 }
 
  if ((forma.emailContato.value == "") || (forma.emailContato.value.indexOf("@")==-1) || (forma.emailContato.value.indexOf(".")==-1)){
  mensagemErro+="\n\n . Email para contato";
} 

 if (forma.telefoneContato.value == "") {
		mensagemErro+="\n\n . Telefone para contato";
 }
 
 if (forma.mensagem.value == "") {
  mensagemErro+="\n\n . Detalhes de sua cotação";
 }

 if  (mensagemErro == "Por favor preencha corretamente:"){
	 forma.submit();
}
 else{
   alert(mensagemErro);
   forma.nomeEmpresa.focus();
}
	}	
	
	
/* Método para validar o envio da Mensagem em cadastro de Revenda*/
function validaCadRevenda(forma){
 mensagemErro="Por favor preencha corretamente:";
 if (forma.nomeEmpresa.value == "" || forma.nomeEmpresa.value == "null"){
 mensagemErro+="\n\n . Nome da empresa";
 } 
 if (forma.razaoEmpresa.value == "") {
		mensagemErro+="\n\n . Razão social da empresa";
 }
 
 if (forma.cnpjEmpresa.value == "") {
		mensagemErro+="\n\n . CNPJ da empresa";
 }
 
 if (forma.nomeContato.value == "") {
		mensagemErro+="\n\n . Nome para contato";
 }
 
 if (forma.funcaoContato.value == "") {
		mensagemErro+="\n\n . Função que ocupa na empresa";
 }
 if (forma.telefoneContato.value == "") {
		mensagemErro+="\n\n . Telefone para contato";
 } 
  if ((forma.emailContato.value == "") || (forma.emailContato.value.indexOf("@")==-1) || (forma.emailContato.value.indexOf(".")==-1)){
  mensagemErro+="\n\n . Email para contato";
} 

 if (forma.SENHA_CLI.value == "") {
		mensagemErro+="\n\n . Sua senha de acesso";
 }
	 
 if  (mensagemErro == "Por favor preencha corretamente:"){
	 forma.submit();
}
 else{
   alert(mensagemErro);
   forma.nomeEmpresa.focus();
}
	}	
	
function validarEmailClienteEnvio(campo){ 

	var retorno	= true;
	
	if(campo.value.indexOf("@")==-1 || campo.value.indexOf(".")==-1){ 
		alert("O campo email não está preenchido corretamente!"); 
		campo.focus();
		retorno = false;
	}

	return retorno;
}

function validarNomeEnvio(campo){ 

	var retorno	= true;
	
	if(campo.value == "" || campo.value == null){ 
		alert("O campo nome não está preenchido corretamente!"); 
		campo.focus();
		retorno = false;
		return
	}
	
	return retorno;
}	


function validarTelefoneEnvio(campo){ 

	var retorno	= true;
	
	if(campo.value == "" || campo.value == null){ 
		alert("O campo telefone não está preenchido corretamente!"); 
		campo.focus();
		retorno = false;
		return
	}
	
	return retorno;
} 	
	
/* Método para validar o envio do Orçamento pra Loja*/
function validaEnvio(formulario){
 var frmEnvio	= document.getElementById(formulario);
  if(validarEmailClienteEnvio(formEnvioOrcamento.emailCliente) ){
	if(validarNomeEnvio(formEnvioOrcamento.nomeRemetente) ){
  	 if(validarTelefoneEnvio(formEnvioOrcamento.telefoneRemetente)){
		formEnvioOrcamento.submit();
   		 }
		}	
	}
}

//FORMATAR DATA
function FormataData(campo) {
    var data = new String( campo.value );
    var wData = '';
	var cont = 0;
    for (i=0; i< data.length ; i++) {
	  if (i <= 1) {
		  if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' )	{
			  	wData += data.charAt(i);
	  	  }
	  }
	  if (i == 2) {	  
		  if ( data.charAt(i) == '/' )	{
			  	wData += data.charAt(i);
	  	  }	  
		  else {
			  if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' )	{
			  		wData += '/';
				  	wData += data.charAt(i);
			  }
			  else {
			  		wData += '/';			  
			  }
	  	  }
	  }

	  if (i > 2 && i <= 4) {
		  if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' )	{
			  	wData += data.charAt(i);
	  	  }
	  }	  
	  
	  if (i == 5) {	  
		  if ( data.charAt(i) == '/' )	{
			  	wData += data.charAt(i);
	  	  }	  
		  else {
			  if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' )	{
			  		wData += '/';
				  	wData += data.charAt(i);
			  }
			  else {
			  		wData += '/';			  
			  }
	  	  }
	  }

	  if (i > 5 && i <= 9) {
		  if ( data.charAt(i) >= '0' && data.charAt(i) <= '9' )	{
			  	wData += data.charAt(i);
	  	  }
	  }	  	  
    }

    // Atualiza o campo 
    campo.value = wData;
}

function validaFuncionario(obj,pagina){
 passou = 0;
	if (obj.email.value == "" || obj.email.value == null || obj.email.value.indexOf("@")==-1 || obj.email.value.indexOf(".")==-1){
		alert("O campo email não está preenchido corretamente!");
		obj.email.focus();
		return false;		
		}else if(obj.senha.value == "" || obj.senha.value == null || obj.senha.value.length < 6){
			alert("Campo Senha em branco, Inválido ou Menor de 6 Caracteres  !");
			obj.senha.focus();
			return false;		
			}else{
				passou = 1;
				obj.submit();
			}
}

function validaAltClienteSite(obj){ 

   if(obj.EMAIL_CLI.value == "" || obj.EMAIL_CLI.value == null){
    alert("Campo Email em branco ou Inválido  !");
    obj.EMAIL_CLI.focus();
    return false;
	
    }else if(obj.SENHA_CLI.value == "" || obj.SENHA_CLI.value == null || obj.SENHA_CLI.value.length < 6){
	alert("Campo Senha em branco, Inválido ou Menor de 6 Caracteres  !");
	obj.SENHA_CLI.focus();
	return false;
	
	}else if(obj.RESENHA_CLI.value == "" || obj.RESENHA_CLI.value == null || obj.RESENHA_CLI.value != obj.RESENHA_CLI.value){
	alert("Campo Confirme Senha em branco, Inválido ou Diferente do Campo Senha !");
	obj.RESENHA.focus();
	return false;
	
	}else if (obj.NOME_CLI.value == "" || obj.NOME_CLI.value == null){
	alert("Campo Nome em branco ou Inválido !");
	obj.NOME_CLI.focus();
	return false;
   
    }else if(obj.CPF_CLI.value == "" || obj.CPF_CLI.value == null || obj.CPF_CLI.value.length < 6){
    alert("Campo CPF / CNPJ em branco ou Inválido  !");
    obj.CPF_CLI.focus();
    return false;
    
    }else if(obj.DATANASC_CLI.value == "" || obj.DATANASC_CLI.value == null){
    alert("Campo Data Nascimento em branco ou Inválido  !");
    obj.DATANASC_CLI.focus();
    return false;
    
    }else if(obj.TELEFONE_CLI.value == "" || obj.TELEFONE_CLI.value == null){
    alert("Campo Telefone em branco ou Inválido  !");
    obj.TELEFONE_CLI.focus();
    return false;
    
	}else if(obj.ENDERECO_CLI.value == "" || obj.ENDERECO_CLI.value == null){
	alert("Campo Endereço em branco ou Inválido  !");
	obj.ENDERECO_CLI.focus();
	return false;

	}else if(obj.BAIRRO_CLI.value == "" || obj.BAIRRO_CLI.value == null){
	alert("Campo Bairro em branco ou Inválido  !");
	obj.BAIRRO_CLI.focus();
	return false;
	
	}else if(obj.CEP_CLI.value == "" || obj.CEP_CLI.value == null){
	alert("Campo CEP em branco ou Inválido  !");
	obj.CEP_CLI.focus();
	return false;
	
	}else if(obj.CIDADE_CLI.value == "" || obj.CIDADE_CLI.value == null){
	alert("Campo Cidade em branco ou Inválido  !");
	obj.CIDADE_CLI.focus();
	return false;
	
	}else if(obj.sel_estado.value == "" || obj.sel_estado.value == null){
	alert("Campo Estado em branco ou Inválido  !");
	obj.sel_estado.focus();
	return false;
	
	}else{
		obj.submit();
	}
}
    
   function validaConsultaCEP(form){
    if (form.cep.value != ""){
		alert (form.cep.value);
     form.submit();
    }
	}
    
  function atualizar(id) {
   var formulario = document.getElementById('formcarrinho');
   var campoFormularioId = document.getElementById('id');
   var campoFormularioQuantidade = document.getElementById('quantidade');
   var campo = "valorQuantidade"+id;
   campoFormularioId.value = id;
   campoFormularioQuantidade.value = document.getElementById(campo).value;
   formulario.submit();
 }
 
 function excluir(id) {
  var formulario = document.getElementById('formExcluirP');
  var campoFormulario1 = document.getElementById('idExcluir');
  campoFormulario1.value = id;
  formulario.submit();
 }    
 
 function rachurarLinha(objetoId, cor){
   var obj = document.getElementById(objetoId);
  obj.style.backgroundColor	= cor;	//Seta a linha com a cor escolhida
}

function Limpar(valor, validos) { 
// retira caracteres inválidos da string 
var result = ""; 
var aux; 
for (var i=0; i < valor.length; i++) { 
aux = validos.indexOf(valor.substring(i, i+1)); 
if (aux>=0) { 
result += aux; 
} 
} 
return result; 
} 

function Formata(campo,tammax,teclapres,decimal) { 
 var tecla = teclapres.keyCode; 
 vr = Limpar(campo.value,"0123456789"); 
 tam = vr.length; 
 dec=decimal 
if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; } 
if (tecla == 8 ) 
{ tam = tam - 1 ; } 
if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) 
{ 
if ( tam <= dec ) 
{ campo.value = vr ; } 
if ( (tam > dec) && (tam <= 5) ){ 
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 6) && (tam <= 8) ){ 
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 
} 
if ( (tam >= 9) && (tam <= 11) ){ 
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 12) && (tam <= 14) ){ 
campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 
if ( (tam >= 15) && (tam <= 17) ){ 
campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;} 
} 
}

function teste(){
var FArray = new Array(100);
for (i=1; i<100; i++){
 FArray[i]=i;
}
return FArray;
}

/* Método validando o popup referente a alerta de preço*/
function validaAlertForm(forma,codigo){
 mensagemErro="Por favor preencha corretamente:";
 if (forma.preco.value == ""){
  mensagemErro+="\n\n . Preço Sugerido";
 } 
 if ((forma.email.value == "") || (forma.email.value.indexOf("@")==-1) || (forma.email.value.indexOf(".")==-1)){
		mensagemErro+="\n\n . Endereço Email";
 } 

if  (mensagemErro== "Por favor preencha corretamente:"){
     forma.codigoProduto.value=codigo;
	 forma.submit();
}
else{
   alert(mensagemErro);
}
}

/* Método setando campo de extraFrm em produto*/
function setExtraFrm(codigo){
 document.getElementById("extraProduto").value = codigo;
 var forma = document.getElementById("extraFrm");
 forma.submit();
}

/* Método setando campo de bFrm em produto*/
function setBFrm (codigo){
 document.getElementById("bProduto").value = codigo;
 var forma = document.getElementById("bFrm");
 forma.submit();
}

/* Método para passar de um edit para outro em CEP e validar números*/

function passa(){
 var objeto = document.getElementById("cep");
 var cep = objeto.value;
 if(cep.length == 5){
 document.getElementById("cep2").focus();
 return false;
 }
}

/* Método simples para ir para a página principal*/
function homepage(){
var aceitaEntrar = window.confirm("Cancelar o registo?");
if (aceitaEntrar) {
 window.location.href='../';}
}

/* Método para trabalhar com a estrelinha*/
function workOut(id,num){
 document.getElementById(id).src = "img/star_w.gif"
 document.getElementById("fieldVote").value = "";
}

function workOver(id,num){
 for (i=num;i>0;i--){
  document.getElementById('v'+i).src = "img/star_a.gif"
 }

 switch (id){
  case "v1": {
   document.getElementById("fieldVote").value = "Péssimo";
   break;
  }
  case "v2": {
   document.getElementById("fieldVote").value = "Ruim";
   break;
  }
  case "v3": {
   document.getElementById("fieldVote").value = "Regular";
   break;
  }
  case "v4": {
   document.getElementById("fieldVote").value = "Bom";
   break;
  }
  case "v5": {
   document.getElementById("fieldVote").value = "Ótimo";
   break;
  }
  default: document.getElementById("fieldVote").value = "Ótimo";
	  
	  }
}

function showBox (){
    var sendbutton = document.getElementById("sEnviar");
	var showbutton = document.getElementById("bcoment");
	
   document.getElementById("mensagem").style.display = (document.getElementById("mensagem").style.display == 'none') ? '' : 'none';
   sendbutton.style.display = (sendbutton.style.display == 'none') ? '' : 'none';
    if (showbutton.value == "Abrir ->"){
	showbutton.value= "Fechar <-"; 
	 }
	 else
	 showbutton.value= "Abrir ->"; 
    document.getElementById("mensagem").focus();
}

function showCel (){
	
   document.getElementById("phone").style.display = (document.getElementById("phone").style.display == 'none') ? '' : 'none';
   document.getElementById("cellabel").style.display = (document.getElementById("cellabel").style.display == 'none') ? '' : 'none';
      document.getElementById("cellabel").focus();
}

function showSocket (){
var idcategoria = document.getElementById('Categoria').value;
	if (idcategoria == '7' || idcategoria == '9'){
      document.getElementById("Socket").style.display = 'block';
      document.getElementById("Socket").focus();} else
	  
	  {
		document.getElementById("Socket").style.display = 'none';  
		  }
}

function showRelForm (){
   document.getElementById("RelField").style.display = (document.getElementById("RelField").style.display == 'none') ? '' : 'none';

}


function validaSendComent(forma){
 if (document.getElementById("mensagem").value != ""){
  forma.submit();
 }
 else {
  alert("Deve escrever um comentário.");
  document.getElementById("mensagem").focus();
 }
}

function focusName(campo){
campo.className="inputNewsFoc";
if (campo.value == "Seu nome..."){
 campo.value="";}
}

function blurName(campo){
campo.className="inputNews";
campo.value = campo.value.replace(/(^\s*)|(\s*$)/g,"");	
if (campo.value == ""){
 campo.value="Seu nome...";}
}

function focusMail(campo){
campo.className="inputNewsFoc";
if (campo.value == "Meu email..."){
 campo.value="";}
}
	
		

function blurMail(campo){
	if ((campo.value.indexOf("@")==-1 || campo.value.indexOf(".")==-1) && (campo.value !="")){
		campo.style.borderColor='#990000';
		campo.focus(); 
		}
		else {
		 campo.style.borderColor='#58AEF5';	
			}
campo.className="inputNews";
campo.value = campo.value.replace(/(^\s*)|(\s*$)/g,"");	
if (campo.value == ""){
 campo.value="Meu email...";}
}

function focusEmailLogin(campo){
campo.className="inputEmailFoc";
}

function blurEmailLogin(campo){
 campo.className="inputEmail";
}

function focusSearch(campo){
campo.className="inputFoc";
}

function blurSearch(campo){
 campo.className="input";
}

function focusSenha(campo){
 campo.className="inputSenhaFFoc";
}

function blurSenha(campo){
 campo.className="inputSenhaF";
}

function focusPhone(campo){
 campo.className="inputPhoneFocus";
}

function blurPhone(campo){
 campo.className="inputPhone";
}

function setList(forma){

 if (forma.seeAsBtn.value != "Lista"){
  forma.list.value = "0";
  forma.submit();}
 else {
  forma.list.value = "1";
  forma.submit();
	 }
 }
 
function validaRelatorio(comando){

  if (comando == 'mes_ac'){
   document.RelatForm.comando.value="ativa";
  }
  else if (comando == 'total'){
   document.RelatForm.comando.value="total";
  }
  else if (comando == 'espec'){
    document.RelatForm.comando.value="dactiva";
  }
     document.RelatForm.submit();
 }
	
function validaRelatorioNotAtiva(forma){
 forma.comando.value="notativa";
 forma.submit();
}

function validaRelatorioNotAtiva(forma){
 forma.comando.value="notativa";
 forma.submit();
}

function mudarCorFoc(elemento){
 elemento.style.backgroundColor ='#dfe9fe';
 elemento.style.color = '#0000FF';
}

function mudarCorBlur(elemento){
 elemento.style.backgroundColor='#FFFFFF';
 elemento.style.color='#000000';
}


function colorFade(id,element,start,end,steps,speed) {
  var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;
  var target = document.getElementById(id);
  steps = steps || 20;
  speed = speed || 20;
  clearInterval(target.timer);
  endrgb = colorConv(end);
  er = endrgb[0];
  eg = endrgb[1];
  eb = endrgb[2];
  if(!target.r) {
    startrgb = colorConv(start);
    r = startrgb[0];
    g = startrgb[1];
    b = startrgb[2];
    target.r = r;
    target.g = g;
    target.b = b;
  }
  rint = Math.round(Math.abs(target.r-er)/steps);
  gint = Math.round(Math.abs(target.g-eg)/steps);
  bint = Math.round(Math.abs(target.b-eb)/steps);
  if(rint == 0) { rint = 1 }
  if(gint == 0) { gint = 1 }
  if(bint == 0) { bint = 1 }
  target.step = 1;
  target.timer = setInterval( function() { animateColor(id,element,steps,er,eg,eb,rint,gint,bint) }, speed);
}

function animateColor(id,element,steps,er,eg,eb,rint,gint,bint) {
  var target = document.getElementById(id);
  var color;
  if(target.step <= steps) {
    var r = target.r;
    var g = target.g;
    var b = target.b;
    if(r >= er) {
      r = r - rint;
    } else {
      r = parseInt(r) + parseInt(rint);
    }
    if(g >= eg) {
      g = g - gint;
    } else {
      g = parseInt(g) + parseInt(gint);
    }
    if(b >= eb) {
      b = b - bint;
    } else {
      b = parseInt(b) + parseInt(bint);
    }
    color = 'rgb(' + r + ',' + g + ',' + b + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
    target.r = r;
    target.g = g;
    target.b = b;
    target.step = target.step + 1;
  } else {
    clearInterval(target.timer);
    color = 'rgb(' + er + ',' + eg + ',' + eb + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
  }
}

function colorConv(color) {
  var rgb = [parseInt(color.substring(0,2),16), 
    parseInt(color.substring(2,4),16), 
    parseInt(color.substring(4,6),16)];
  return rgb;
}


function __loadEsconde(){
 var objLoader				    = document.getElementById("carregador_pai");
 objLoader.style.display		= "none";
 objLoader.style.visibility	    = "hidden";
 var objShow = document.getElementById("shower");
 objShow.style.display		= "block";
 objShow.style.visibility	    = "visible";
}


function validaSeloCad(forma){
 mensagemErro="Por favor preencha corretamente:";
 var NomeClienteC = forma.NomeClienteC.value.replace(/(^\s*)|(\s*$)/g,"");
 var SobreNomeClienteC = forma.SobreNomeClienteC.value.replace(/(^\s*)|(\s*$)/g,"");
 var NomeProdutoC1 = forma.NomeProdutoC1.value.replace(/(^\s*)|(\s*$)/g,"");
 var NumeroVendaC = forma.NumeroVendaC.value.replace(/(^\s*)|(\s*$)/g,"");
 
if (NomeClienteC == "") {
		mensagemErro+="\n\n . Nome do cliente";
 }
 
 if (SobreNomeClienteC == "") {
		mensagemErro+="\n\n . Sobrenome do cliente";
 }
 
 if (NomeProdutoC1 == "") {
		mensagemErro+="\n\n . Nome do produto";
 }

 if  (mensagemErro == "Por favor preencha corretamente:"){
	 forma.submit();
	 

}
 else{
   alert(mensagemErro);
   forma.NomeClienteC.focus();
}
	}	
	
	function enableCliente(){
		document.cadForm.NomeClienteC.style.backgroundColor = '#FFFFFF';
		document.cadForm.SobreNomeClienteC.style.backgroundColor = '#FFFFFF';
		document.cadForm.NomeClienteC.value='';
		document.cadForm.SobreNomeClienteC.value='';
		document.cadForm.NomeClienteC.focus();
	}
		
function showHideHelp(){
	 document.getElementById("mostrarHelp").style.display = (document.getElementById("mostrarHelp").style.display == 'none') ? '' : 'none';
	}		

function borderImageS(field){
	field.style.borderColor = '#FF9900';
	}
	
function borderImageH(field){
	field.style.borderColor = '#FFFFFF';
	}
	
 function borderImageSG(field){
	field.style.borderColor = '#009966';
	}
	
 function borderImageHG(field){
	field.style.borderColor = '#CCCCCC';
}
	
function setImageS(field){
	field.style.borderColor = '#FF9900';
}
	
function setImageH(field){
		field.style.borderColor = '#FFFFFF';
	}
	
function setImage(thumbName){

	document.getElementById('mainImage').src = thumbName;


}


// ProductViewPhotosTagLogic

var qtdeImages;
var aryImages;
var baseUrlProductView;
function loadProductPictures(arrayImages, baseUrl) {
	qtdeImages = arrayImages.length;
	aryImages = arrayImages;
	baseUrlProductView = baseUrl;

	for (i=0; i < aryImages.length; i++) {
		var preload = new Image();
		preload.src = aryImages[i];
	}
	if (qtdeImages > 1)
		swap(0);
}