//<!-- 

/////////////////////////////////////////////////////////////////
// VERIFICA SE TODOS OS CAMPOS FORAM PREENCHIDOS
function validaForm(form)
{	msg = "ok";
	for(i=0;i<form.length;i++)
		if((form[i].value == "") || (form[i].value.substring(0,1)==" "))
			msg = "Totos os campos são obrigatórios";
	if(msg!="ok")
	{	alert(msg);
		return false;
	}
} 

// COMPARA 2 CAMPOS
function validasenha(){
    if(document.form.senha.value!=document.form.confirmasenha.value){
		alert ("As Senhas digitadas não combinam. Tente novamente.");
		document.getElementById("confirmasenha").value='';
		document.form.senha.focus();
		return false;
	}
	return true;
}

function validaemail(){
    if(document.form.email.value!=document.form.confirmaemail.value){
		alert ("Os e-mails digitados não combinam. Tente novamente.");
		document.getElementById("confirmaemail").value='';
		document.form.confirmaemail.focus();
		return false;
	}
	return true;
}

// VERIFICA PROFUNDIDADE DA SENHA
function verifica() {
var texto = document.form.senha.value;
if(texto=="") {
document.getElementById("texto").style.background="white";
document.getElementById("texto").innerHTML="Preencha com sua senha";
return false;
}

var senha_num = 0;
var senha_let = 0;

for(var i = 0; i < texto.length; i++) {

if(isNaN(texto.substring(i, i+1))) {
	senha_let=senha_let+1;
	}
	else {
		senha_num=senha_num+1;
	}
		}
		if(senha_num==texto.length || senha_let==texto.length) {
			document.getElementById("texto").style.backgroundColor="yellow";
			document.getElementById("texto").innerHTML="Senha fraca";
			return false;
		}
		else if(senha_num!=texto.length || senha_let!=texto.length) {
		
		if(texto.length < 4) {
			document.getElementById("texto").style.backgroundColor="yellow";
			document.getElementById("texto").innerHTML="Senha fraca";
			return false;
		}
		else if(texto.length > 4 && texto.length < 7) {
			document.getElementById("texto").style.background="#EFE259";
			document.getElementById("texto").innerHTML="Senha regular";
			return false;
		}
		else if(texto.length > 6) {
			document.getElementById("texto").style.background="#BCEF95";
			document.getElementById("texto").innerHTML="Senha boa";
			return false;
		}
	}
} 

// FORMATA CAMPO DE CPF
function FormataCPF(Campo, teclapres)
{
	var tecla = teclapres.keyCode;
	
	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1;
	
	if (tecla != 9 && tecla != 8)
		{
		if (tam > 3 && tam < 7)
			Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
		if (tam >= 7 && tam <10)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
		if (tam >= 10 && tam < 12)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		}
		
}
/////////////////////////////////////////////////////////////////

function Formata_Telefone(objeto,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	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 <= 4 ) { 
			objeto.value = vr ;
		}
		if ( (tam > 4) && (tam <= 8) ) {
			objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
		if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}

/////////////////////////////////////////////////////////////////

function FormataCNPJ(Campo, teclapres)
{

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1 ;

	
	if (tecla != 9 && tecla != 8)
		{
		if (tam > 2 && tam < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}

}

/////////////////////////////////////////////////////////////////

function SaltaCampo(campo,prox,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = document.forms[0].elements[campo].value;
	
		
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108){
	   document.forms[0].elements[campo].value = vr.substr(0, vr.length - 1); }
	else
		{
		vr = vr.replace("-","");
		vr = vr.replace("/","");
		vr = vr.replace("/","");
		vr = vr.replace(",","");
		vr = vr.replace(".","");
		vr = vr.replace(".","");
		vr = vr.replace(".","");
		vr = vr.replace(".","");
		tam = vr.length;

		if (tecla != 0 && tecla != 9 && tecla != 16 )
			if ( tam == tammax )
				document.forms[0].elements[prox].focus();
		}

}
//////////////////////////////////////////////////////////////////

function LimpaCampo(sValor,iBase)
{
var tam = sValor.length
var saida = new String
for (i=0;i<tam;i++)
	if (!isNaN(parseInt(sValor.substr(i,1),iBase)))
		saida = saida + String(sValor.substr(i,1));
return (saida);		
}

/////////////////////////////////////////////////////////////////

function FormataData(Campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(Campo.value);
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	tam = vr.length + 1;
	
	if (tecla != 9 && tecla != 8) 
 		{
		if (tam > 2 && tam < 5)
			Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, tam);
		if (tam >= 5 && tam <=10)
			Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4);
		
		}
}
/////////////////////////////////////////////////////////////////
	
function FormataHora(Campo, teclapres) 
{
	var tecla = teclapres.keyCode;
	
	var vr = new String(Campo.value);
	vr = vr.replace(":", "");
	vr = vr.replace(":", "");

	tam = vr.length + 1;
	
	if (tecla != 9 && tecla != 8) {
		if (tam > 2 && tam < 5)
			Campo.value = vr.substr(0, 2) + ':' + vr.substr(2, tam);
		if (tam >= 5 && tam < 9)
			Campo.value = vr.substr(0,2) + ':' + vr.substr(2,2) + ':' + vr.substr(4,2);
		}
	}
/////////////////////////////////////////////////////////////////