/**
 * @author Anderson Peixoto
 * @version 1.01, 2004
 * PROTÓTIPOS:
 * método String.lpad(int pSize, char pCharPad)
 * método String.trim()
 *
 * String unformatNumber(String pNum)
 * String formatCpfCnpj(String pCpfCnpj, boolean pUseSepar, boolean pIsCnpj)
 * String dvCpfCnpj(String pEfetivo, boolean pIsCnpj)
 * boolean isCpf(String pCpf)
 * boolean isCnpj(String pCnpj)
 * boolean isCpfCnpj(String pCpfCnpj)
 */
alerta = 3
errou = 5


function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit);
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="Limite: "+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}


function abrirJanela(URL, NAME, OPTIONS) {
window.open(URL, NAME, OPTIONS)
}

//==================================================//
//Função Aceitou Termos Sim Não
//====================================================
function aceitouTermos(campo,destino)
{
    if (document.form[campo].checked) {
	    //window.alert("Favor Preencher o campo: " + campo);
		//document.form[campo].value = 0;				
		//document.form[destino].style.backgroundColor = ""; // cinza className 
		//document.form[destinon].style.backgroundColor = ""; // cinza className 
		document.form[destino].disabled = false;
		//document.form[destinon].disabled = true;		
		//document.form[destino].select();
		//document.form[destino].focus();		
   		//document.form[alterar].style.backgroundColor = "#FCD1D1"; //vermelho
		return true;
	}
	else
	{
 	//document.form[alterar].style.backgroundColor = "#EEEDEF"; // cinza
	//document.form[campo].value = 1;	
	document.form[destino].disabled = true;
	//document.form[destino].disabled = true;	
	//document.form[destino].value = "";
	//document.form[destinon].focus();
	return false;
	}
}

//==================================================//
//Função COPIAR ENDEREÇO
//====================================================
function cendereco(campo)
{
    if (document.form[campo].checked) {
		document.form.enderecoEmpresa.value = document.form.endereco.value;
		document.form.numeroEmpresa.value = document.form.numero.value;		
		document.form.complementoEmpresa.value = document.form.complemento.value;
		document.form.bairroEmpresa.value = document.form.bairro.value;		
		document.form.cidadeEmpresa.value = document.form.cidade.value;		
		document.form.cepEmpresa.value = document.form.cep.value;
		document.form.estadoEmpresa.value = document.form.estado.value;	

		// document.form.destino.readonly = true;
		return true;
	}
	else
	{
		//document.form.alterar.style.backgroundColor = "#EEEDEF"; // cinza
		document.form.enderecoEmpresa.value = "";
		document.form.numeroEmpresa.value = "";		
		document.form.complementoEmpresa.value = "";
		document.form.bairroEmpresa.value = "";		
		document.form.cepEmpresa.value = "";
		document.form.enderecoEmpresa.focus();
		return false;
	}
}


//==================================================//
//Função COPIAR EMAIL
//====================================================
function cemail(campo)
{
    if (document.form[campo].checked) {
		document.form.emailEmpresa.value = document.form.email.value;
		// document.form.destino.readonly = true;
		return true;
	}
	else
	{
		//document.form.alterar.style.backgroundColor = "#EEEDEF"; // cinza
		document.form.emailEmpresa.value = "";
		document.form.emailEmpresa.focus();
		return false;
	}
}

//==================================================//
//Função ISENTO
//====================================================
function isento(campo,destino,txt)
{
    if (document.form[campo].checked) {
	    //window.alert("Favor Preencher o campo: " + campo);
		//document.form[campo].value = 0;				
		//document.form[destino].style.backgroundColor = ""; // cinza className 
		//document.form[destinon].style.backgroundColor = ""; // cinza className 
		 document.form[destino].value = txt;
		// document.form[destino].readonly = true;
		return true;
	}
	else
	{
		//document.form[alterar].style.backgroundColor = "#EEEDEF"; // cinza
		document.form[destino].value = "";	
		document.form[destino].disabled = false;
		document.form[destino].focus();
		return false;
	}
}

//==================================================//
//Função Preencher dados Empresa Sim Não
//====================================================
function verificaEmpresa(campo,destino,destinon)
{
    if (document.form[campo].checked) {
	    //window.alert("Favor Preencher o campo: " + campo);
		document.form[campo].value = 0;				
		document.form[destino].style.backgroundColor = ""; // cinza className 
		document.form[destinon].style.backgroundColor = ""; // cinza className 
		document.form[destino].disabled = false;
		//document.form[destinon].disabled = true;		
		//document.form[destino].select();
		//document.form[destino].focus();		
   		//document.form[alterar].style.backgroundColor = "#FCD1D1"; //vermelho
		return true;
	}
	else
	{
 	//document.form[alterar].style.backgroundColor = "#EEEDEF"; // cinza
	document.form[campo].value = 1;	
	document.form[destinon].disabled = false;
	//document.form[destino].disabled = true;	
	document.form[destino].value = "";
	document.form[destinon].focus();
	return false;
	}
}
//===============================================
//TRANSFORMA EM MÍNUSCULAS
//===============================================
function letrasMinusculas(campo) {
var texto;
texto = document.form[campo].value;
texto = texto.toLowerCase();
document.form[campo].value = texto;
}
//================================================
//VALIDAR FORMULÁRIO
//================================================
function validarFormulario(pEvent, pForm) {
var val = document.form.cpf.value;
var base = val.substring(0, val.length-2);
//if ( vRG == true  && vEmail == true && vSexo == true && vNome == true)
//{
	if (isCpf(val) && vNome && vEmail && vData && vSexo && vRG && vEndereco && vBairro && vCidade && vEstado && vCEP && vTelefone && vCelular && vSenha && !empresa && vInfocelula && vDownload || isCpf(val) && vNome && vEmail && vData && vSexo && vRG && vEndereco && vBairro && vCidade && vEstado && vCEP && vTelefone && vCelular && vSenha && vRazaoSocial && vNomeFantasia && vEmailEmpresa && vEnderecoEmpresa && vBairroEmpresa && vEstadoEmpresa && vCidadeEmpresa && vCEPEmpresa && vFaxEmpresa && vCargo && vTelefoneEmpresa && vInfocelula && vDownload) 
		{
			if (document.form.email.value.length < 5)
			{
				//window.alert("Favor Preencher seu e-mail corretamente!");
				return false;
			}
			else
			{
				var email = form.email.value;
				return checkEmail(email);
			}
			if (document.form.nome.value.length < 10) {
				//window.alert("Favor entrar com um e-mail válido.");
				return false;
			}
			if (document.form.email.value.length < 6) {
				//window.alert("E-mail incorreto.");
				return false;
			}
		}
		else
		{
		window.alert("Caro usuário, \n\nFavor PREENCHER TODOS os CAMPOS DO FORMULÁRIOS corretamente antes de enviar!\n\n Campo em BRANCO indica campo vazio, VERMELHO indica preenchimento incorreto, VERDE indica que os dados foram aceitos.\n\n Obrigado.");
		
		//window.alert( "Nome: " + vNome + "\nEmail: " + vEmail + "\nData Nascimento: " + vData + "\nCPF: " + vCPF + "\nSexo: " + vSexo  + "\nRG: " + vRG  + "\nEndereço: " + vEndereco  + "\nBairro: " + vBairro  + "\nCidade: " + vCidade  + "\nEstado: " + vEstado  + "\nCEP: " + vCEP + "\nTelefone: " + vTelefone + "\nCelular: " + vCelular + "\nEmpresa: " + vEmpresa  + "\nNome Fantasia: " + vNomeFantasia  + "\nRazão Social: " + vRazaoSocial  + "\nCNPJ: " + vCNPJ  + "\nSenha: " + vSenha + "\nEndereço Empresa: " + vEnderecoEmpresa + "\nBairro: " + vBairroEmpresa + "\nCEP: " + vCEPEmpresa + "\nTelefone: " + vTelefoneEmpresa + "\nFax: " + vFaxEmpresa);
		
		return false;
		}
//	}
} 
// Fim validar formulario



//=============================================
// Função Verifica Download
//============================================= 
function verificaDownload(campo,destino)
{
    if (document.form[campo].value == 0) {
		alerta = alerta + 1;
		if (alerta > errou) 
		{
			//window.alert(" ATENÇÃO! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor preencher o campo: '" + campo + "' CORRETAMENTE!!"); 
			alerta = 0;
		}		
		document.form[campo].value = "";
		//document.form[campo].focus();
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{
		document.form[campo].style.backgroundColor = "#D7FED6"; // Atribuindo cor ok para campo verificado 
		document.form[destino].disabled = false;	//ligando próximo campo
		document.form[destino].style.backgroundColor = ""; // Atribuindo Nenhuma cor
		//document.form[destino].focus();	//movendo focus para próximo campo
		//abrirJanela('termosAreaDownload.asp','Telecelula','width=700,height=520,status=no,scrollbars=yes,top=0,left=0');
		return true;
	}
}


//=============================================
// Função Verifica Estado
//=============================================
function verificaEstado(campo,destino)
{
    if (document.form[campo].value == 0) {
		alerta = alerta + 1;
		if (alerta > errou) 
		{
			//window.alert(" ATENÇÃO! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor preencher o campo: '" + campo + "' CORRETAMENTE!!"); 
			alerta = 0;
		}		
		document.form[campo].value = "";
		//document.form[campo].focus();
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{
		document.form[campo].style.backgroundColor = "#D7FED6"; // Atribuindo cor ok para campo verificado 
		document.form[destino].disabled = false;	//ligando próximo campo
		document.form[destino].style.backgroundColor = ""; // Atribuindo Nenhuma cor
		//document.form[destino].focus();	//movendo focus para próximo campo
	return true;
	}
}


//============================================
// FUNÇÃO CPF
//============================================
function validarCPF(pEvent, campo, destino)
{
	var val = document.form[campo].value;
	var base = val.substring(0, val.length-2);
    if (document.form[campo].value.length > 0) {
		if (isCpf(val))
		{
		document.form[campo].style.backgroundColor = "#D7FED6"; // Atribuindo cor ok para campo verificado 
		document.form[destino].disabled = false;	//ligando próximo campo
		document.form[destino].style.backgroundColor = ""; // Atribuindo Nenhuma cor
		//document.form[destino].focus();	//movendo focus para próximo campo
		return true;	
		}
		else
		{		
		//alert("Prezado usuário, o CPF digitado não é válido, favor verificar");
		alerta = alerta + 1;
		if (alerta > errou) 
		{
			window.alert(" Prezado Usuário, \n O número: " + document.form[campo].value + " não é um número de CPF válido! \n Favor verificar seus dados e preencher o campo: '" + campo + "' corretamente!"); 
			alerta = 0;
		}		
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		document.form[campo].value = "";
		//document.form[campo].select();
		//document.form[campo].focus();
		/*alert("CPF:"
				+ "\nDesformatado = " + unformatNumber(val)
				+ "\nFormatado = " + formatCpfCnpj(val, true)
				+ "\nDVs = " + dvCpfCnpj(base, false)
				+ "\nVálido = " + isCpf(val));
		*/
		return false;
		}
	}
} //Fim Validar CPF




//============================================
// FUNÇÃO CNPJ
//============================================
function validarCNPJ(campo, destino, chave)
{
	var val = document.form[campo].value;
	var base = val.substring(0, val.length-2);
    if (document.form[campo].value.length > 13 && vEmpresa) 
	{
		if (isCnpj(val))
		{
		document.form[campo].style.backgroundColor = "#D7FED6"; // Atribuindo cor ok para campo verificado 
		document.form[destino].disabled = false;	//ligando próximo campo
		document.form[destino].style.backgroundColor = ""; // Atribuindo Nenhuma cor
		//document.form[destino].focus();	//movendo focus para próximo campo
		//document.form[chave].disabled = true;
		return true;	
		}
		else
		{
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				window.alert(" Prezado Usuário, \n O número: " + document.form[campo].value + " não é um número de CNPJ válido! \n Favor verificar seus dados e preencher o campo: '" + campo + "' corretamente!\n ATENÇÃO: CASO NÃO TENHA CNPJ DESMARQUE A OPÇÃO 'Vou Preencher Meus Dados Empresariais Agora!' \n PARA CONTINUAR"); 
				alerta = 0;
			}		
			document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
			document.form[campo].value = "";
			//document.form[campo].select();
			//document.form[campo].focus();
			return false;
		}
	}
} //Fim Validar CNPJ




//==========================================
//-----------------------Função Campo Vazio
//==========================================
function CampoVazio(campo,destino,tamanho)
{
    if (document.form[campo].value.length < tamanho) {
	    //window.alert("Favor Preencher o campo: " + campo);
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				//window.alert(" Caro Usuário! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor verificar os dados digitados e preencher o campo: '" + campo + "' corretamente!"); 
				alerta = 0;
			}		
			document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
			document.form[campo].value = "";
			//document.form[campo].select();
			//document.form[campo].focus();
			return false;				
		document.form[campo].value = "";
		//document.form[campo].select();
		//document.form[campo].focus();		
   		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{
 	document.form[campo].style.backgroundColor = "#D7FED6"; //verde
	document.form[destino].style.backgroundColor = "#FFFFFF"; // cinza className 
 	//document.form[alterar].className = "TextoPadraoVermelho"
	//document.form[destino].disabled = false;	
	//document.form[destino].focus();
	return true;
	}
}


//==========================================
//-----------------------Função Campo Vazio
//==========================================
function CampoVazio1(campo,destino,tamanho)
{
    if (document.form[campo].value.length < tamanho) {
	    //window.alert("Favor Preencher o campo: " + campo);
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				//window.alert(" Caro Usuário! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor verificar os dados digitados e preencher o campo: '" + campo + "' corretamente!"); 
				alerta = 0;
			}		
			document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
			document.form[campo].value = "";
			//document.form[campo].select();
			//document.form[campo].focus();
			return false;				
		document.form[campo].value = "";
		//document.form[campo].select();
		//document.form[campo].focus();		
   		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{
 	document.form[campo].style.backgroundColor = "#D7FED6"; //verde
	document.form[destino].style.backgroundColor = "#FFFFFF"; // cinza className 
 	//document.form[alterar].className = "TextoPadraoVermelho"
	document.form[destino].disabled = false;	
	document.form[destino].focus();
	return true;
	}
}




//==========================================
//-----------------------Função Campo Mínimo
//==========================================
function CampoMinimo(campo,destino,tamanho)
{
    if (document.form[campo].value.length < tamanho) {
	    //window.alert("Favor Preencher o campo: " + campo);
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				//window.alert(" Caro Usuário! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor verificar os dados digitados e preencher o campo: '" + campo + "' corretamente!"); 
				alerta = 0;
			}		
			document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
			document.form[campo].value = "";
			//document.form[campo].select();
			//document.form[campo].focus();
			return false;				
		document.form[campo].value = "";
		//document.form[campo].select();
		//document.form[campo].focus();		
   		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{
 	document.form[campo].style.backgroundColor = ""; //verde"#D7FED6"
	//document.form[destino].style.backgroundColor = "#FFFFFF"; // cinza className 
 	//document.form[alterar].className = "TextoPadraoVermelho"
	//document.form[destino].disabled = false;	
	//document.form[destino].focus();
	return true;
	}
}


//==========================================
//-----------------------Função Campo Senha
//==========================================
function CampoSenha(campo,tamanho)
{   var senhaText;
	var teste;
 	senhaText = document.form[campo].value;
//	teste = senhaText.search(" ");
//	alert("Resposta: " + teste);
//alert(senhaTxt.search(/w3schools/))
    if  (
		document.form[campo].value.length < tamanho) 
/*		(senhaText.search(";") >= 0) ||
	    (senhaText.search(",") >= 0) ||
	    (senhaText.search(".") >= 0) ||
	    (senhaText.search("/") >= 0) ||
	    (senhaText.search("'") >= 0) ||
	    (senhaText.search("^") >= 0) ||
	    (senhaText.search("`") >= 0) ||
	    (senhaText.search("~") >= 0) ||
	    (senhaText.search("ç") >= 0) ||
	    (senhaText.search("´") >= 0) ||		
		(document.form[campo].value == "123456") || 
		(document.form[campo].value == "1234567890") || 
		(document.form[campo].value == "543210")  || 
		(document.form[campo].value == "654321") || 		
		(document.form[campo].value == "123456789") ||
		(document.form[campo].value == "987654321") || 
		(document.form[campo].value == "1234567") || 
		(document.form[campo].value == "12345678") || */
		{
	    	//window.alert("Favor Preencher o campo: " + campo);
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				window.alert(" Caro Usuário! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor verificar os dados digitados e preencher uma senha válida.\n M&iacute;nimo de 6 e Máximo de 10 caracteres  dentre números e letras."); 
				alerta = 0;
			}		
		document.form[campo].value = "";
		//document.form[campo].select();
		//document.form[campo].focus();		
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
		}
		else
		{
			document.form[campo].style.backgroundColor = "#D7FED6"; //verde
			return true;
		}
}




//==============================================
//FUNÇÃO EMAIL/
//==============================================
function validarEmail(campo,destino) {
	var email = document.form[campo].value;
//	if (validarNome){
	if (checkEmail(email,campo))
		{
			document.form[campo].style.backgroundColor = "#D7FED6"; //verde
			document.form[destino].style.backgroundColor = ""; // cinza className 
		 	//document.form[alterar].className = "TextoPadraoVermelho"
			document.form[destino].disabled = false;	
			//document.form[destino].focus();	
			return true;
		}
		else
		{
			alerta = alerta + 1;
			if (alerta > errou) 
			{
				window.alert("ATENÇÃO! \n" + document.form[campo].value  + " NÃO é um e-mail VÁLIDO!. Por favor, Preencha SEU E-MAIL CORRETAMENTE!!"); 
				alerta = 0;
			}		
			document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
			document.form[campo].value = "";
			//document.form[campo].select();
			//document.form[campo].focus();
			return false;		
		}
//	}
} // Fim validar eMAIL


//======================================= 
//          CHECAR E-MAIL
//=======================================
function checkEmail(EmailText,campo)
{
	/*var varResult = EmailText.search(/\./i) - (EmailText.search(/@/i) + 1)	*/ 
	if ((EmailText.search(/;/i) == -1) &&
	    (EmailText.search(/,/i) == -1) &&
	    (EmailText.indexOf("..") == -1) &&
	    (EmailText.indexOf(".@") == -1) &&
	    (EmailText.indexOf("@.") == -1) &&
	    (EmailText.search(/ /i) == -1) &&
	    (EmailText.search(/"/i) == -1) &&
	    (EmailText.search(/'/i) == -1) &&
	    (EmailText.indexOf("^") == -1) &&
	    (EmailText.search(/`/i) == -1) &&
	    (EmailText.search(/~/i) == -1) &&
	    (EmailText.search(/ç/i) == -1) &&
	    (EmailText.indexOf("#") == -1) &&
		(EmailText.indexOf("%") == -1) &&
		(EmailText.indexOf("+") == -1) &&
		(EmailText.indexOf("*") == -1) &&
		(EmailText.indexOf("@@") == -1) &&
		(EmailText.indexOf("/") == -1) &&
		(EmailText.indexOf("\\") == -1) &&
		(EmailText.indexOf(".") > -1) && /*Tem que ter pelo menos 1 ponto*/
	    (EmailText.length != 0) &&
	    (EmailText.search(/@/i) >= 1) &&
	    (EmailText.substr(0,1) != ".") && /*Não pode começar com ponto*/
	    (EmailText.substr(EmailText.length-1) != ".") && /*Não pode terminar com ponto*/
	    (EmailText.indexOf("hotmail.com.br") == -1) &&
	    (EmailText.indexOf("@gmail.com.br") == -1))
		return true;
	else if (EmailText.indexOf("hotmail.com.br") >= 0)
		{
		alert("Atenção: O E-mail HOTMAIL não termina com .BR\nFavor corrigir!");
		document.form[campo].value = EmailText.replace("hotmail.com.br", "hotmail.com");
		//document.form[campo].focus();
		//document.form[campo].select();
		return false;
		}
	else if (EmailText.indexOf("gmail.com.br") >= 0)
		{
		alert("Atenção: O E-mail GMAIL não termina com .BR\nFavor corrigir!");
		document.form[campo].value = EmailText.replace("gmail.com.br", "gmail.com");
		//document.form[campo].focus();
		return false;
		}
	else if (EmailText.indexOf(" ") >= 0)
		{
		//alert("Atenção: O E-mail não deve conter espaços em branco\nEle será automaticamente corrigido");
		while(EmailText.indexOf(" ") >= 0)
		EmailText= EmailText.replace(" ", "");
		document.form[campo].value = EmailText ;
//		document.form[campo].focus();
		return false;
		}
	else
	    {
//		window.alert("Formato do endereço de E-mail Incorreto!");
//		document.form[campo].select();
//		document.form[campo].focus();
		return false; 
	    }
} // fim função e-mail


//======================================
// FUNÇÃO ACEITA APENAS NÚMEROS NO CAMPO
//======================================
function Numero(e)
{
	navegador = /msie/i.test(navigator.userAgent);
	if (navegador)
		var tecla = event.keyCode;
	else
		var tecla = e.which;
	
	if(tecla > 47 && tecla < 58 || tecla ==13 || tecla ==9 ) // numeros de 0 a 9
		return true;
	else
		{
		if (tecla != 8) // backspace
			return false;
		else
			return true;
		}
}


/*==========================================
FUNÇÃO ACEITA APENAS LETRAS NO CAMPO
==========================================*/
function Letras(e)

{
	navegador = /msie/i.test(navigator.userAgent);
	if (navegador)
		var tecla = event.keyCode;
	else
		var tecla = e.which;
	//if ((tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123) || (tecla > 128 &&  tecla < 165 ) || (tecla > 180 &&  tecla < 184 ) || (tecla > 197 &&  tecla < 200 ) || (tecla > 209 &&  tecla < 217 ) || (tecla > 225 &&  tecla < 238 ) || tecla == 39 || tecla == 94 || tecla == 96 || tecla == 126 || tecla == 239 || tecla == 255) // letras de 0 a 9
	if (tecla > 40 && tecla < 65 || tecla > 90 && tecla < 94|| tecla > 58 && tecla < 65 || tecla > 33 && tecla < 47 ||tecla > 14 && tecla < 27 ||  tecla > 166 && tecla < 192)
		return false;
	else
		return true;
}

/*
FUNÇÃO ACEITA APENAS LETRAS e NUMEROS NO CAMPO e a tabulações
*/
function LetrasNumeros(e)
{
	navegador = /msie/i.test(navigator.userAgent);
	if (navegador)
		var tecla = event.keyCode;
	else
		var tecla = e.which;
	//if ((tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123) || (tecla > 128 &&  tecla < 165 ) || (tecla > 180 &&  tecla < 184 ) || (tecla > 197 &&  tecla < 200 ) || (tecla > 209 &&  tecla < 217 ) || (tecla > 225 &&  tecla < 238 ) || tecla == 39 || tecla == 94 || tecla == 96 || tecla == 126 || tecla == 239 || tecla == 255) // letras de 0 a 9
	if (tecla > 40 && tecla < 65 || tecla > 0 && tecla < 10 || tecla > 33 && tecla < 48 ||tecla > 14 && tecla < 27 ||  tecla > 166 && tecla < 192)
	{
			if (tecla > 47 && tecla < 58) 
			return true;
				else
			return false;
	}
	else
		return true;

}

//FUNÇÃO ACEITA APENAS LETRAS e NUMEROS NO CAMPO e a tabulações

function soLetrasNumeros(e)
{
	navegador = /msie/i.test(navigator.userAgent);
	if (navegador)
		var tecla = event.keyCode;
	else
		var tecla = e.which;
	//if ((tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123) || (tecla > 128 &&  tecla < 165 ) || (tecla > 180 &&  tecla < 184 ) || (tecla > 197 &&  tecla < 200 ) || (tecla > 209 &&  tecla < 217 ) || (tecla > 225 &&  tecla < 238 ) || tecla == 39 || tecla == 94 || tecla == 96 || tecla == 126 || tecla == 239 || tecla == 255) // letras de 0 a 9
	if (tecla > 47 && tecla < 58 || tecla > 64 && tecla < 91 || tecla > 96 && tecla < 124)
	{
	if (tecla >64 && tecla <91)
		{
			alert("Favor usar somente letras minúsculas e números para preencher o campo senha!");
			return false;
		}
	else
		{
			return true;
		}
	}
	else
		return false;

}

//MOEDA
function Moeda(teclapres) 
{
	navegador = /msie/i.test(navigator.userAgent);
	if (navegador)
		var tecla = event.keyCode;
	else
		var tecla = e.which;
	
	if(tecla > 45 && tecla < 58 || tecla ==13) // numeros de 0 a 9
		return true;
	else
		{
		if (tecla != 8) // backspace
			return false;
		else
			return true;
		}

}


//FORMATAR TELEFONE
function FormataTelefone(campo, teclapres) 
{
		var tecla = teclapres.keyCode;
		vr = document.form[campo].value;
		vr = vr.replace( ".", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		tam = vr.length + 1;
		if ( tecla != 9 && tecla != 8 && tecla != 40 && tecla != 14 && tecla != 15 && tecla!=48 )
		{
			if ( tam < 2 )		
					document.form[campo].value = '(' + vr;		
			if ( tam > 3 && tam < 5 )
				document.form[campo].value = vr.substr( 0, tam - 1  ) + ')' ;
			if ( tam > 8 && tam < 10 )
				document.form[campo].value = vr.substr( 0, tam - 1  ) + '-' ;
		}


}

// DATA FORMATA E VERIFICA DATA

function FormataData(campo, teclapres) 
{
		var tecla = teclapres.keyCode;
		vr = document.form[campo].value;
		vr = vr.replace( ".", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		tam = vr.length + 1;
		if ( tecla != 9 && tecla != 8 )
		{
			if ( tam > 2 && tam < 5 )
				document.form[campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam);
			if ( tam >= 5 && tam <= 10 )
				document.form[campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
		}
}

var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;
var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
var reDate = reDate4;

function VerificarData(campo, pFmt, destino)
{
	var pStr = document.form[campo].value;
	eval("reDate = reDate" + pFmt);
	if (reDate.test(pStr)) 
	{
//		window.alert(pStr + " é uma data válida.");
 		document.form[campo].style.backgroundColor = "#D7FED6"; //verde
		document.form[destino].style.backgroundColor = ""; // cinza className 
 		//document.form[alterar].className = "TextoPadraoVermelho"
		//document.form[destino].disabled = false;	
		//document.form[destino].focus();
		//if (login == false) {
 		//usuario = usuario + pStr.substring(0,2);// pega apenas o primeiro caracter	
		//alert(usuario);
		//this.document.form.usuario.value = usuario;
		login = true;
		//}
		return true;
	} 
	else if (pStr != null && pStr != "") 
		{
		alerta = alerta + 1;
		if (alerta > errou) {
		window.alert("ATENÇÃO! \n" + pStr + " NÃO é uma data válida. Por favor, Preencha uma data VÁLIDA!!"); 
		alerta = 0;
		}
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
//		document.form[campo].style.borderColor = "#FF0000"; //vermelho
		//document.form[campo].select();		
		document.form[campo].value = "";
		//document.form[campo].focus();			
		return false;
		}
} // Verificar Data



//Iniciar formulário	
function iniciarFormulario(campo)
{		
	document.form[campo].focus();
}
//=====================================================
//VERIFICA SEXO
//=====================================================
function verificaSexo(campo, destino)
{		
	if(document.form[campo].value == "M" || document.form[campo].value == "F")
	{
 	document.form[campo].style.backgroundColor = "#D7FED6"; //verde
	document.form[destino].style.backgroundColor = ""; // cinza className 
	document.form[destino].disabled = false;	
	//document.form[destino].focus();
	return true;
	}
	else
	{		
	//document.form[campo].focus();
	document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
	return false;
	}
   /* if (document.form[campo].value == 0) {
		alerta = alerta + 1;
		if (alerta > errou) 
		{
			window.alert(" ATENÇÃO! \n A entrada: " + document.form[campo].value + " não é uma entrada válida! \n Favor preencher o campo: '" + campo + "' CORRETAMENTE!!"); 
			alerta = 0;
		}		
		document.form[campo].value = 0;
		document.form[campo].select();
		document.form[campo].focus();
		document.form[campo].style.backgroundColor = "#FCD1D1"; //vermelho
		return false;
	}
	else
	{ 
 	document.form[campo].style.backgroundColor = "#D7FED6"; //verde
	document.form[destino].style.backgroundColor = ""; // cinza className 
	//document.form[alterar].className = "TextoPadraoVermelho";
	document.form[destino].disabled = false;	
	document.form[destino].focus();
	return true;
	} */
	
}

NUM_DIGITOS_CPF  = 11;
NUM_DIGITOS_CNPJ = 14;
NUM_DGT_CNPJ_BASE = 8;


/**
 * Adiciona método lpad() à classe String.
 * Preenche a String à esquerda com o caractere fornecido,
 * até que ela atinja o tamanho especificado.
 */
String.prototype.lpad = function(pSize, pCharPad)
{
	var str = this;
	var dif = pSize - str.length;
	var ch = String(pCharPad).charAt(0);
	for (; dif>0; dif--) str = ch + str;
	return (str);
} //String.lpad


/**
 * Adiciona método trim() à classe String.
 * Elimina brancos no início e fim da String.
 */
String.prototype.trim = function()
{
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
} //String.trim


/**
 * Elimina caracteres de formatação e zeros à esquerda da string
 * de número fornecida.
 * @param String pNum
 * 	String de número fornecida para ser desformatada.
 * @return String de número desformatada.
 */
function unformatNumber(pNum)
{
	return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
} //unformatNumber


/**
 * Formata a string fornecida como CNPJ ou CPF, adicionando zeros
 * à esquerda se necessário e caracteres separadores, conforme solicitado.
 * @param String pCpfCnpj
 * 	String fornecida para ser formatada.
 * @param boolean pUseSepar
 * 	Indica se devem ser usados caracteres separadores (. - /).
 * @param boolean pIsCnpj
 * 	Indica se a string fornecida é um CNPJ.
 * 	Caso contrário, é CPF. Default = false (CPF).
 * @return String de CPF ou CNPJ devidamente formatada.
 */
function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	if (pUseSepar==null) pUseSepar = true;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var numero = unformatNumber(pCpfCnpj);

	numero = numero.lpad(maxDigitos, '0');
	if (!pUseSepar) return numero;

	if (pIsCnpj)
	{
		reCnpj = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/;
		numero = numero.replace(reCnpj, "$1.$2.$3/$4-$5");
	}
	else
	{
		reCpf  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
		numero = numero.replace(reCpf, "$1.$2.$3-$4");
	}
	return numero;
} //formatCpfCnpj


/**
 * Calcula os 2 dígitos verificadores para o número-efetivo pEfetivo de
 * CNPJ (12 dígitos) ou CPF (9 dígitos) fornecido. pIsCnpj é booleano e
 * informa se o número-efetivo fornecido é CNPJ (default = false).
 * @param String pEfetivo
 * 	String do número-efetivo (SEM dígitos verificadores) de CNPJ ou CPF.
 * @param boolean pIsCnpj
 * 	Indica se a string fornecida é de um CNPJ.
 * 	Caso contrário, é CPF. Default = false (CPF).
 * @return String com os dois dígitos verificadores.
 */
function dvCpfCnpj(pEfetivo, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	var i, j, k, soma, dv;
	var cicloPeso = pIsCnpj? NUM_DGT_CNPJ_BASE: NUM_DIGITOS_CPF;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var calculado = formatCpfCnpj(pEfetivo, false, pIsCnpj);
	calculado = calculado.substring(2, maxDigitos);
	var result = "";

	for (j = 1; j <= 2; j++)
	{
		k = 2;
		soma = 0;
		for (i = calculado.length-1; i >= 0; i--)
		{
			soma += (calculado.charAt(i) - '0') * k;
			k = (k-1) % cicloPeso + 2;
		}
		dv = 11 - soma % 11;
		if (dv > 9) dv = 0;
		calculado += dv;
		result += dv
	}

	return result;
} //dvCpfCnpj


/**
 * Testa se a String pCpf fornecida é um CPF válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpf
 * 	String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF válido.
 */
function isCpf(pCpf)
{
	var numero = formatCpfCnpj(pCpf, false, false);
	var base = numero.substring(0, numero.length - 2);
	var digitos = dvCpfCnpj(base, false);
	var algUnico, i;

	// Valida dígitos verificadores
	if (numero != base + digitos) return false;

	/* Não serão considerados válidos os seguintes CPF:
	 * 000.000.000-00, 111.111.111-11, 222.222.222-22, 333.333.333-33, 444.444.444-44,
	 * 555.555.555-55, 666.666.666-66, 777.777.777-77, 888.888.888-88, 999.999.999-99.
	 */
	algUnico = true;
	for (i=1; i<NUM_DIGITOS_CPF; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	return (!algUnico);
} //isCpf


/**
 * Testa se a String pCnpj fornecida é um CNPJ válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCnpj
 * 	String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CNPJ válido.
 */
function isCnpj(pCnpj)
{
	var numero = formatCpfCnpj(pCnpj, false, true);
	var base = numero.substring(0, NUM_DGT_CNPJ_BASE);
	var ordem = numero.substring(NUM_DGT_CNPJ_BASE, 12);
	var digitos = dvCpfCnpj(base + ordem, true);
	var algUnico;

	// Valida dígitos verificadores
	if (numero != base + ordem + digitos) return false;

	/* Não serão considerados válidos os CNPJ com os seguintes números BÁSICOS:
	 * 11.111.111, 22.222.222, 33.333.333, 44.444.444, 55.555.555,
	 * 66.666.666, 77.777.777, 88.888.888, 99.999.999.
	 */
	algUnico = numero.charAt(0) != '0';
	for (i=1; i<NUM_DGT_CNPJ_BASE; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	if (algUnico || numero == "00000000") return false;

	/* Não será considerado válido CNPJ com número de ORDEM igual a 0000.
	 * Não será considerado válido CNPJ com número de ORDEM maior do que 0300
	 * e com as três primeiras posições do número BÁSICO com 000 (zeros).
	 * Esta crítica não será feita quando o no BÁSICO do CNPJ for igual a 00.000.000.
	 */
	if (ordem == "0000") return false;
	return (base == "00000000"
		|| parseInt(ordem, 10) <= 300 || base.substring(0, 3) != "000");
} //isCnpj


/**
 * Testa se a String pCpfCnpj fornecida é um CPF ou CNPJ válido.
 * Se a String tiver uma quantidade de dígitos igual ou inferior
 * a 11, valida como CPF. Se for maior que 11, valida como CNPJ.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpfCnpj
 * 	String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF ou CNPJ válido.
 */
function isCpfCnpj(pCpfCnpj)
{
	var numero = pCpfCnpj.replace(/\D/g, "");
	if (numero.length > NUM_DIGITOS_CPF)
		return isCnpj(pCpfCnpj)
	else
		return isCpf(pCpfCnpj);
} //isCpfCnpj


/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox


/***********************************************
CHAVEADOR DE TEXTO


* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='<img src="../imagens/icones/arr_closed.gif">' //HTML for contract symbol. For image, use: 
var expandsymbol='<img src="../imagens/icones/arr_opened.gif">' //HTML for expand symbol.



if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate


function limparimage()
{
window.clipboardData.clearData('Image');
}
//=======================================================================================================|
//=======================================================================================================|
// INICIO - FUNÇÃO DE BLOQUEAR
//=======================================================================================================|
//setInterval("limparimage()",100);
/*


var message="Caro Usuário, Essa função está desabilitada no site.";
// desativar Botao esquerdo do mouse
function clickIE() {if (document.all) {(message);return true;}}

function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return true;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return true")
//desativar seleção de texto (IE4+, NS6+)


// function click() {
// 	if (event.button == 2 || event.button == 3) oncontextmenu = 'return false';
//}

//if IE4+
document.onselectstart=new Function ("return true")



//if NS6
if (window.sidebar){
//document.onmousedown = new Function ("return false")
document.onclick=new Function ("return true")
}

document.oncontextmenu =  new Function('return false;');
//document.onkeypress =  new Function('return false;');
//document.onmousedown =  new Function('return false;');
document.onmouseup =  new Function('return false;');
document.onselectstart=  new Function('return false;');
=======================================================================================================
// FIM - FUNÇÃO DE BLOQUEAR
=======================================================================================================
=======================================================================================================



=======================================================================================================
=======================================================================================================
// FUNÇÃO TECLAS DE ATALHO
=======================================================================================================

*/
function shortcut(shortcut,callback,opt) 
{ 
//Provide a set of default options 
var default_options = { 
'type':'keydown', 
'propagate':false, 
'target':document 
} 
if(!opt) opt = default_options; 
else { 
for(var dfo in default_options) { 
if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo]; 
} 
} 

var ele = opt.target 
if(typeof opt.target == 'string') ele = document.getElementById(opt.target); 
var ths = this; 

//The function to be called at keypress 
var func = function(e) { 
e = e || window.event; 

//Find Which key is pressed 
if (e.keyCode) code = e.keyCode; 
else if (e.which) code = e.which; 
var character = String.fromCharCode(code).toLowerCase(); 

var keys = shortcut.toLowerCase().split("+"); 
//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked 
var kp = 0; 

//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken 
var shift_nums = { 
"`":"~", 
"1":"!", 
"2":"@", 
"3":"#", 
"4":"$", 
"5":"%", 
"6":"^", 
"7":"&", 
"8":"*", 
"9":"(", 
"0":")", 
"-":"_", 
"=":"+", 
";":":", 
"'":"\"", 
",":"<", 
".":">", 
"/":"?", 
"\\":"|" 
} 
//Special Keys - and their codes 
var special_keys = { 
'esc':27, 
'escape':27, 
'tab':9, 
'space':32, 
'return':13, 
'enter':13, 
'backspace':8, 

'scrolllock':145, 
'scroll_lock':145, 
'scroll':145, 
'capslock':20, 
'caps_lock':20, 
'caps':20, 
'numlock':144, 
'num_lock':144, 
'num':144, 

'pause':19, 
'break':19, 

'insert':45, 
'home':36, 
'delete':46, 
'end':35, 

'pageup':33, 
'page_up':33, 
'pu':33, 

'pagedown':34, 
'page_down':34, 
'pd':34, 

'left':37, 
'up':38, 
'right':39, 
'down':40, 

'f1':112, 
'f2':113, 
'f3':114, 
'f4':115, 
'f5':116, 
'f6':117, 
'f7':118, 
'f8':119, 
'f9':120, 
'f10':121, 
'f11':122, 
'f12':123 
} 


for(var i=0; k=keys[i],i<keys.length; i++) { 
//Modifiers 
if(k == 'ctrl' || k == 'control') { 
if(e.ctrlKey) kp++; 

} else if(k == 'shift') { 
if(e.shiftKey) kp++; 

} else if(k == 'alt') { 
if(e.altKey) kp++; 

} else if(k.length > 1) { //If it is a special key 
if(special_keys[k] == code) kp++; 

} else { //The special keys did not match 
if(character == k) kp++; 
else { 
if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase 
character = shift_nums[character]; 
if(character == k) kp++; 
} 
} 
} 
} 

if(kp == keys.length) { 
callback(e); 

if(!opt['propagate']) { //Stop the event 
//e.cancelBubble is supported by IE - this will kill the bubbling process. 
e.cancelBubble = true; 
e.returnValue = false; 

//e.stopPropagation works only in Firefox. 
if (e.stopPropagation) { 
e.stopPropagation(); 
e.preventDefault(); 
} 
return false; 
} 
} 
} 

//Attach the function with the event 
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false); 
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func); 
else ele['on'+opt['type']] = func; 
} 

// Exemplo: 

shortcut("Ctrl+E", function() { 
	window.location = "contato_formulario.asp";      
}); 

shortcut("Ctrl+D", function() { 
	window.location = "download.asp";      
}); 

shortcut("Ctrl+I", function() { 
	window.location = "default.asp";      
}); 

shortcut("Ctrl+L", function() { 
	window.location = "loja.asp";      
}); 

shortcut("Ctrl+N", function() { 
	window.location = "novidades.asp";      
}); 


shortcut("F1", function() { 
	 window.location = "central_ajuda.asp";      
}); 
		
shortcut("F6", function() { 
		window.scrollTo(0,1);
	    document.Form.Produtonome.value = "";  
		document.Form.Produtonome.focus();}); 

shortcut("F7", function() { 
	   	window.scrollTo(0,1);
		document.Form.Produtonome.select();
		document.Form.Produtonome.focus();
		if (document.Form.Produtonome.value == "CTAT")
				document.Form.Produtonome.value = "PN:";
		else
				document.Form.Produtonome.value = "CTAT";				
		if (document.Form.Produtonome.value == "")
				document.Form.Produtonome.value = "CTAT";  	
		
}); 

shortcut("F8", function() { 
    	window.location = "painel_usuario.asp";  				
}); 
shortcut("F9", function() { 
    	window.location = "download_Procurar.asp";  				
}); 
shortcut("F2", function() { 
    	window.location = "Painel_Usuario_Pedidos.asp";  				
});



shortcut("F12", function() { 
    	window.location = "carrinho_compra.asp";  				
}); 

/* document.onkeyup = KeyCheck;       
//function KeyCheck()
//{
 //  var KeyID = event.keyCode;
 //  switch(KeyID)
  // {
 //     case 120:
		//alert('Voce apertou a tecla F9');
	//	window.location = "adminPedidos.asp?cod_pedido=000";      
//	   break;
  //    case 119:
	//	window.location = "adminUsuario.asp?repetir=1";      
    //  break;    
	//  case 118:
		//window.location = "adminloja.asp?nomeProduto=000000";      
    //  break;    
	
	 //  }
//}

=======================================================================================================
// FIM - FUNÇÃO TECLAS DE ATALHO
=======================================================================================================
=======================================================================================================


*/
/*
=======================================================================================================
=======================================================================================================
// FUNÇÃO ACEITAR OS TERMOS
=======================================================================================================
*/

var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Por favor, aceite os termos do cadastro para continuar!")
return false
}
}
}




