function isNumber(txtField){
  numExp = txtField.value;
  if (isNaN(numExp) || (numExp.length == 0))
    return (false);
  else
    return(true);
}

//  cnpj (cpf)
function e_cpf(gField) {
    var dig1=0  //digito 1
    var dig2=0  //digito 2    
    var mult1 = 10
    var mult2 = 11

    var valor = ""
    valor = gField.value;

/*
    valor = trim(valor);
    valor = deleteChars(valor, ".");
    valor = deleteChars(valor, "/");
    valor = deleteChars(valor, "-");
*/    
	if(valor.length>11)
		return false;
	
	if (valor=="11111111111")
		return false;

    for (var i=1; i<=9; i++) {
      dig1 += parseInt(valor.charAt(i-1)) * mult1;
      mult1--;
    }

    for (var i=1; i<=10; i++) {
      dig2 += parseInt(valor.charAt(i-1)) * mult2;
      mult2--;
    }

    dig1 = (dig1 * 10) % 11;
    dig2 = (dig2 * 10) % 11;
    
    if (dig1 == 10)
        dig1 = 0;
    if (dig2 == 10) 
        dig2 = 0;
    
    if (dig1 != parseInt(valor.charAt(9)) || dig2 != parseInt(valor.charAt(10)) )
        return false;
    
    return true;
}

// cgc
function e_cgc(gField){
    var mult1 = "543298765432"
    var mult2 = "6543298765432"
    var dig1=0  //digito 1
    var dig2=0  //digito 2    
    var valor = ""
    
    valor = gField.value;
/*    
    valor = trim(valor);
    valor = deleteChars(valor, ".");
    valor = deleteChars(valor, "/");
    valor = deleteChars(valor, "-"); 
*/    
    for (var i=1; i<=12; i++)
      dig1 += parseInt(valor.charAt(i-1)) * parseInt(mult1.charAt(i-1));

    for (var i=1; i<=13; i++)
      dig2 += parseInt(valor.charAt(i-1)) * parseInt(mult2.charAt(i-1));
    
    dig1 = (dig1 * 10) % 11;
    dig2 = (dig2 * 10) % 11;
    
    if (dig1 == 10)
        dig1 = 0;
    if (dig2 == 10) 
        dig2 = 0;
    
    if (dig1 != parseInt(valor.charAt(12)) || dig2 != parseInt(valor.charAt(13)) )
        return false;
    
    return true;
}


// email
function e_email(gField){
    var inputStr = gField.value;
    if (!(isEmpty(inputStr))){ 
       if ((countStr(inputStr,"@") != 1 ) ||
           (countStr(inputStr,".")  < 1 ) ||
           (countStr(inputStr,"/")  > 0 ) ||
           (countStr(inputStr,":")  > 0 ) ||
           (countStr(inputStr,"'")  > 0 ) ||
           (countStr(inputStr,"\"") > 0 ) ||
           (countStr(inputStr,"\\") > 0 ) ||
           (countStr(inputStr,"|")  > 0 ) ||
           (countStr(inputStr,"(")  > 0 ) ||
           (countStr(inputStr,")")  > 0 ) ||
           (countStr(inputStr,"*")  > 0 ) ||
           (countStr(inputStr,"+")  > 0 ) ||
           (countStr(inputStr,"`")  > 0 ) ||
           (countStr(inputStr,"%")  > 0 ) ||
           (countStr(inputStr,"#")  > 0 ) ||
           (countStr(inputStr,"!")  > 0 ) ||
           (countStr(inputStr,"$")  > 0 ) ||
           (countStr(inputStr,"&")  > 0 )) {
            gField.focus();
            gField.select();
            return false;
         }
    }
    return true;
}



// Para deixar entrar só numeros
function NumberOnly(e,txt) {

	
	var navegador = (navigator.appName == "Netscape") ? "NT" : "IE";
	
	var charCode = (navegador == "NT") ? e.which : e.keyCode;

	if (charCode == 8) { return true; }
	if ((charCode  < 48) || (charCode  > 57)){
		if (navegador=="NT"){
			return e.preventDefault(); 
		}else{
			e.returnValue = false;
		}
	}
		
    
}




	// ******   Recupera o Valor do Radio que estiver Checado dentro de um Form *********
	// ******   		Retorna 0 (zero) se não achar nada		    *********


	function FU_RecuperaValorRadio(pNome_Form, pNome_Radio) {
	   var strNome_Form  = pNome_Form
	   var strNome_Radio = pNome_Radio

	//   if(document.forms[strNome_Form].elements[strNome_Radio]!=undefined) {
		   var tam = document.forms[strNome_Form].elements[strNome_Radio].length;
		   if(tam>0){
			   for(var i=0;i<tam;i++){
				   if(document.forms[strNome_Form].elements[strNome_Radio][i].checked) {
					   return document.forms[strNome_Form].elements[strNome_Radio][i].value;
					   break;
				   }
			   }
		   } else {
			   if(document.forms[strNome_Form].elements[strNome_Radio].checked) {
				   return document.forms[strNome_Form].elements[strNome_Radio].value; 
			   }
		   }
	//   }
	   return 0;
	}