//<input name="data" type="text" id="data" maxlength="10" onKeypress="return Ajusta_Data(this, event);"> 
//<input name="hora" type="text" id="hora" maxlength="5" onKeypress="return Ajusta_Hora(this, event);">   
//<input name="cep" type="text" id="cep" maxlength="9" onKeypress="return Ajusta_Cep(this, event);">   
//<input name="numero" type="text" id="numero" maxlength="20" onKeypress="return Bloqueia_Caracteres(event);"">   
//
/*
function Valida(){   
    if(document.formulario.nome.value == ""){   
        alert("Preencha o nome da pessoa");   
    }   
    if(Verifica_Data("data_nascimento", 1) == false){ return false }   
    if(Verifica_Hora("hora_compromisso", 1) == false){ return false }   
    if(Verifica_Cep("cep", 0) == false){ return false }   
    if(Verifica_Email("email", 0) == false){ return false }   
    if(Verifica_Email("descricao", 4000) == false){ return false }   
} 
*/
//Verifica qual o browser do visitante e armazena na variável púbica clientNavigator,   
//Caso Internet Explorer(IE) outros (Other)   
if (navigator.appName.indexOf('Microsoft') != -1){   
    clientNavigator = "IE";   
}else{   
    clientNavigator = "Other";   
}   
//
function Bloqueia_Caracteres(evnt){   
//Função permite digitação de números   
    if (clientNavigator == "IE"){   
        if (evnt.keyCode < 48 || evnt.keyCode > 57){   
            return false   
        }   
    }else{   
        if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){   
            return false   
        }   
    }   
}   
//
function Ajusta_Cep(input, evnt){   
//Ajusta máscara de CEP e só permite digitação de números   
   if (input.value.length == 2){   
        if(clientNavigator == "IE"){   
            input.value += ".";   
        }else{   
            if(evnt.keyCode == 0){   
                input.value += ".";   
            }   
        }   
    }   
    if (input.value.length == 6){   
        if(clientNavigator == "IE"){   
            input.value += "-";   
        }else{   
            if(evnt.keyCode == 0){   
                input.value += "-";   
            }   
        }   
    }   
//Chama a função Bloqueia_Caracteres para só permitir a digitação de números   
    return Bloqueia_Caracteres(evnt);   
}
//
function Ajusta_Fone(input, evnt){   
//Ajusta máscara de CEP e só permite digitação de números   
   if (input.value.length == 0){   
        if(clientNavigator == "IE"){   
            input.value += "(";   
        }else{   
            if(evnt.keyCode == 0){   
                input.value += "(";   
            }   
        }   
    }   
    if (input.value.length == 3){   
        if(clientNavigator == "IE"){   
            input.value += ")";   
        }else{   
            if(evnt.keyCode == 0){   
                input.value += ")";   
            }   
        }   
    }   
	if (input.value.length == 8){   
        if(clientNavigator == "IE"){   
            input.value += "-";   
        }else{   
            if(evnt.keyCode == 0){   
                input.value += "-";   
            }   
        }   
    }   
    return Bloqueia_Caracteres(evnt);   
}
//
function Verifica_Email(email, obrigatorio){
//Se o parâmetro obrigatório for igual à zero, significa que elepode estar vazio, caso contrário, não
	//var email = document.getElementById(email);
	if((obrigatorio == 1) || (obrigatorio == 0 && email.value != "")){
		if(!email.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi)){			
			return false
		}
	}
}
//
function Verifica_Cep(cep, obrigatorio){
//Se o parâmetro obrigatório for igual à zero, significa que elepode estar vazio, caso contrário, não
	//var cep    = document.getElementById(cep);
	var strcep = cep.value;
	if((obrigatorio == 1) || (obrigatorio == 0 && strcep != "")){
		if (strcep.length != 10){			
			return false
		}else{
			if (strcep.indexOf("-") != 6){				
				return false
			}else{
				if (isNaN(strcep.replace("-","0"))){					
					return false
				}
			}
		}
	}	  
}
//// moeda
////<input name="campo2" id="campo2" onkeyup="mascara(this,mreais);soma();"  size="20"  />
function mreais(v){
    v=v.replace(/\D/g,"")                        
    v=v.replace(/(\d{2})$/,",$1")             
    v=v.replace(/(\d+)(\d{3},\d{2})$/g,"$1.$2")     
    return v
}
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}
function Ajusta_moeda(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}
////moeda
function Verificar_Numero(V)
{	
	var numeromoeda;
	numeromoeda = parseFloat(V);	
	if (isNaN(numeromoeda)){		
		return false;
	} else {			
		return true;
	}
}
//criticar cpf
function valida_cpf(cpf)
{
var numeros, digitos, soma, i, resultado, digitos_iguais;
digitos_iguais = 1;
if (cpf.length < 11)
	return false;
for (i = 0; i < cpf.length - 1; i++)
	if (cpf.charAt(i) != cpf.charAt(i + 1))
		  {
		  digitos_iguais = 0;
		  break;
		  }
if (!digitos_iguais)
	{
	numeros = cpf.substring(0,9);
	digitos = cpf.substring(9);
	soma = 0;
	for (i = 10; i > 1; i--)
		  soma += numeros.charAt(10 - i) * i;
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(0))
		  return false;
	numeros = cpf.substring(0,10);
	soma = 0;
	for (i = 11; i > 1; i--)
		  soma += numeros.charAt(11 - i) * i;
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(1))
		  return false;
	return true;
	}
else
	return false;
}
//
//validacao cnpj
function valida_cnpj(cnpj)
{
var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
digitos_iguais = 1;
if (cnpj.length < 14 && cnpj.length < 15)
	return false;
for (i = 0; i < cnpj.length - 1; i++)
	if (cnpj.charAt(i) != cnpj.charAt(i + 1))
		  {
		  digitos_iguais = 0;
		  break;
		  }
if (!digitos_iguais)
	{
	tamanho = cnpj.length - 2
	numeros = cnpj.substring(0,tamanho);
	digitos = cnpj.substring(tamanho);
	soma = 0;
	pos = tamanho - 7;
	for (i = tamanho; i >= 1; i--)
		  {
		  soma += numeros.charAt(tamanho - i) * pos--;
		  if (pos < 2)
				pos = 9;
		  }
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(0))
		  return false;
	tamanho = tamanho + 1;
	numeros = cnpj.substring(0,tamanho);
	soma = 0;
	pos = tamanho - 7;
	for (i = tamanho; i >= 1; i--)
		  {
		  soma += numeros.charAt(tamanho - i) * pos--;
		  if (pos < 2)
				pos = 9;
		  }
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(1))
		  return false;
	return true;
	}
else
	return false;
} 
//////Saindo do Sistema
function Saindo(){
	if (confirm('Deseja Sair?')){
		location.href='logoff.php';
	}
}
///////


