	

//mascara numeros
function txtBoxFormat( strField, sMask, evtKeyPress) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

      if(document.all) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(document.layers) { // Nestcape
        nTecla = evtKeyPress.which;
      }

      sValue = document.getElementById(strField).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++;
      }

      document.getElementById(strField).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 true;
        } }
      else {
        return true;
      }
    }
		





function validaCNPJ() {
                CNPJ = document.getElementById('cnpj').value;
                erro = new String;
				
				if (CNPJ.length == 0) return true;		
                 if (CNPJ.length < 14) erro = "CNPJ invalido! \n\n";
                 if ((CNPJ.charAt(2) == ".") || (CNPJ.charAt(6) == ".") || (CNPJ.charAt(10) == "/") || (CNPJ.charAt(15) == "-")){
                 if (erro.length == 0) erro = "CNPJ invalido! \n\n";
                }
                 
               var nonNumbers = /\D/;
               if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
               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 invalido!!";
               }
               if (erro.length > 0){
                       alert(erro);
					   document.getElementById('cnpj').value='';
                       return false;
               } else {
                       seila=2;
					  
               }
           return true;
   }

function validaLogin() {
                CNPJ = document.getElementById('login').value;
                erro = new String;
				
				if (CNPJ.length == 0) return true;		
                 if (CNPJ.length < 14) erro = "CNPJ invalido! \n\n";
                 if ((CNPJ.charAt(2) == ".") || (CNPJ.charAt(6) == ".") || (CNPJ.charAt(10) == "/") || (CNPJ.charAt(15) == "-")){
                 if (erro.length == 0) erro = "CNPJ invalido! \n\n";
                }
                 
               var nonNumbers = /\D/;
               if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
               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 invalido!!";
               }
               if (erro.length > 0){
                       alert(erro);
					   document.getElementById('login').value='';
					   document.getElementById('login').focus();
                       return false;
               } else {
                       seila=2;
					  
               }
           return true;
   }

function PopEmail(){
		MM_openBrWindow('index_ajax.php?secao=emailpop','','status=yes,width=400,height=160');
	
	}

function PopSenha(){
		MM_openBrWindow('index_ajax.php?secao=trocasenhapop','','status=yes,width=400,height=160');
	
	}


function ExcluirProduto(id){
	var id,nome;
	nome='at_qt['+id+']';
	
	document.getElementById(nome).value = '0';
	formatualiza.submit()
	
	}

function LimpaBusca(){

	
	document.getElementById("q").value = '';
	
	
	}

function FechaPedido(){
	
	//acao.php?secao=fechapedido
	
	
	ajaxHTML('divpedido','acao.php?secao=fechapedido&pagamento='+document.getElementById('pagamento').value+'&idCliente='+document.getElementById('idCliente').value);
	}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function NovaSenha(){
	var login,email;
	login=document.getElementById('flogin').value;
	email=document.getElementById('femail').value;
	ajaxHTML('divsenha','index_ajax.php?secao=novasenha&login='+login+'&email='+email);
	
	}
	
function MostraAjuda(id){
	var id;
	
	ajaxHTML('divajuda','index_ajax.php?secao=ajudaretorno&id='+id);
	
	
	}
	
function DetPedido(id){
	var id;
	
	ajaxHTML('divpedido','index_ajax.php?secao=detpedido&id='+id);
	
	
	}

function EnviaCurriculo(id_vaga){
	var id_vaga;
	
		MM_openBrWindow('index_ajax.php?secao=curriculo&id_vaga='+id_vaga,'','status=yes,width=400,height=160');
	
	}

function Zoom(cod){
	
	
	MM_openBrWindow('index_ajax.php?secao=zoom&codigo='+cod,'','status=yes,width=430,height=480');
	
	//ajaxHTMLoff('Zoom'+imagem,'index_ajax.php?secao=zoom&imagem='+imagem);
	
	
	}
function FechaZoom(imagem){
	
	
	ajaxHTMLoff('Zoom'+imagem,'clean.htm');
	
	}
	
function Preco(imagem){
	
	ajaxHTMLoff('Zoom'+imagem,'index_ajax.php?secao=loginpop&imagem='+imagem);
	
	
	}
function Login(div){
	
	ajaxHTMLoff('Zoom'+div,'index_ajax.php?secao=loginpop&imagem='+div);
	
	
	}

function Aviseme(imagem){
	
	ajaxHTMLoff('Zoom'+imagem,'index_ajax.php?secao=aviseme&imagem='+imagem);
	
	
	}

function Busca(evtKeyPress){

	 var i, nTecla;
	if(document.all) { // Internet Explorer
        nTecla = evtKeyPress.keyCode;
		 }
      else if(document.layers) { // Nestcape
        nTecla = evtKeyPress.which;
      }
	  
	  if (nTecla == 13){
	  	formbusca.submit();
	  }


}

function AdicionaProduto(cod){
	var cod,quantidade;
	
	
	
		quantidade = document.getElementById('qt_'+cod).value;
		meuInteger = parseInt(quantidade);
		
		if(isNaN(meuInteger) || meuInteger == 0 || meuInteger < 0){
			alert('Quantidade Invalida');
			//
		}else{
			ajaxHTMLoff('off','index_ajax.php?secao=carrinho&produto='+cod+'&quantidade='+meuInteger);
			alert('Produto incluido no carrinho de compras');
			document.getElementById('qt_'+cod).value='01';
			}
	
	}
//ENQUETE

function Resultado(){
		MM_openBrWindow('index_ajax.php?secao=resultado','','status=yes,width=400,height=160');
	
	}

function Votar(){
	var id;
	id = document.getElementById('meuvoto').value;
	
	ajaxHTML('off','index_ajax.php?secao=enquete&voto='+id);
	Resultado();
	
	}
function SetaVoto(id){
	var id;
	document.getElementById('meuvoto').value = id;
	
	}
