// JavaScript Document
function verRepresentante(pId){
	debugger;
	var obj = document.getElementById('list-text-'+pId);
	if(obj.style.display == 'none'){
		obj.style.display = '';
	}else{
		obj.style.display = 'none';
	}
}
function verAmostra(pPedra){
	if(pPedra != ''){
			window.open('amostra.php?a='+pPedra, 'pedra', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,width=440,height=505,top=0,left=0');
	}
}

function valida() {
    if (document.form.fantasia.value.length < 5) {
	    window.alert("C A M P O - D E - PREENCHIMENTO - O B R I G A T Ó R I O");
		document.form.fantasia.focus(); 
		return false;
	}
	if (document.form.endereco.value.length < 5) {
	    window.alert("C A M P O - D E - PREENCHIMENTO - O B R I G A T Ó R I O");
		document.form.endereco.focus(); 
		return false;
	}
	if (document.form.bairro.value.length < 3) {
	    window.alert("C A M P O - D E - PREENCHIMENTO - O B R I G A T Ó R I O");
		document.form.bairro.focus(); 
		return false;
	}
	if (document.form.municipio.value.length < 5) {
	    window.alert("C A M P O - D E - PREENCHIMENTO - O B R I G A T Ó R I O");
		document.form.municipio.focus(); 
		return false;
	}
	if (document.form.cep.value.length < 5) {
	    window.alert("C A M P O - D E - PREENCHIMENTO - O B R I G A T Ó R I O");
		document.form.cep.focus(); 
		return false;
	}
	if (document.form.cep.telefone.length < 5) {
	    window.alert("NOS INFORME PELO MENOS UM TELEFONE DE CONTATO.");
		document.form.telefone.focus(); 
		return false;
	}
//e-mail
	if(document.form.mail.value.indexOf("@")==-1 || document.form.mail.value.indexOf(".")==-1){ 
	window.alert("O campo email não está preenchido corretamente!"); 
	document.form.mail.focus(); 
	return false; 
	}
     
    return true;
}

  /*** 
    * Descrição.: formata um campo do formulário de 
    * acordo com a máscara informada... 
    * Parâmetros: - objForm (o Objeto Form) 
    * - strField (string contendo o nome 
    * do textbox) 
    * - sMask (mascara que define o 
    * formato que o dado será apresentado, 
    * usando o algarismo "9" para 
    * definir números e o símbolo "!" para 
    * qualquer caracter... 
    * - evtKeyPress (evento) 
    * 
    * Uso.......: <input type="textbox" 
    * name="xxx"..... 
    * onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);"> 
    * Observação: As máscaras podem ser representadas 
    * como os exemplos abaixo: 
    * CEP -> 99999-999 
    * CPF -> 999.999.999-99 
    * CNPJ -> 99.999.999/9999-99 
    * C/C -> 999999-! 
    * Tel -> (99) 9999-9999 
    ***/ 
    function txtBoxFormat(objForm, 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 = objForm[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++; 
      } 

      objForm[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; 
      } 
    } 
