// LINKS
function inicial(aURL) 
{
	location.href = 'index.php?'+aURL;
}

function descricao(aURL) 
{
	location.href = 'descricao.php?curso_id='+aURL;
}

function empresa(aURL) 
{
	location.href = 'empresa.php'+aURL;
}

function incluir(aURL) 
{
	location.href = 'monta_carrinho.php?acao=incluir&curso_id='+aURL;
}

function excluir(aURL) 
{
	location.href = 'monta_carrinho.php?acao=excluir&sessao_compra_id='+aURL;
}

function limpar(aURL) 
{
	location.href = 'monta_carrinho.php?acao=limpar'+aURL;
}

function carrinho(aURL) 
{
	location.href = 'carrinho.php';
}

function institucional(aURL) 
{
	location.href = 'institucional.php?institucional_id='+aURL;
}

function categoria_curso(aURL) 
{
	location.href = 'curso.php?categoria_curso_id='+aURL;
}

function identificacao(aURL) 
{
	location.href = 'identificacao.php'+aURL;
}

function selecionarpagamento(aURL) 
{
	location.href = 'selecionarpagamento.php?pag=selecionarpagamento.php'+aURL;
}

function finalizar(aURL) 
{
	location.href = 'monta_pedido.php?pedido_id='+aURL;
}

function corporativo(aURL) 
{
	location.href = 'corporativo.php';
}

function parceiro(aURL) 
{
	location.href = 'parceiro.php';
}

function contato(aURL) 
{
	location.href = 'contato.php';
}

function promocao(aURL) 
{
	location.href = 'promocao.php';
}

function indicar(aURL) 
{
	location.href = 'indicar.php';
}

function minhaconta(aURL) 
{
	location.href = 'minha_conta.php';
}

function dados(aURL) 
{
	location.href = 'minha_conta.php?DADOS=TRUE';
}

function logout(aURL) 
{
	location.href = 'logout.php';
}
function moodle(aURL) 
{
	location.href = 'moodle.php';
}

function senha(aURL) 
{
	location.href = '?SENHA=TRUE';
}

function email(aURL) 
{
	location.href = '?EMAIL=TRUE';
}

function matriculas(aURL) 
{
	location.href = '?MATRICULAS=TRUE';
}

function pagamento(aURL) 
{
	location.href = '?PAGAMENTO=TRUE&SESSAO='+aURL;
}

function webconferencia(aURL) 
{
	location.href = 'webconferencia.php'+aURL;
}

function depoimentos(aURL) 
{
	location.href = 'depoimento.php'+aURL;
}

function porque(aURL) 
{
	location.href = 'porque.php?porque_id='+aURL;
}
function sala(aURL) 
{
	location.href = '?SALA=TRUE';
}


//========================FORMULARIO DE CADASTRO===================//
//INICIALIZO O OBJET XHTMLREQUEST
var ajax;
function IniciaAjax()
{
	var ajax;
	if(window.XMLHttpRequest)//MOZILA, SAFARI
	{
		ajax = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)//IE
	{
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
		if(!ajax)
		{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{
		alert("Seu navegador não possuí suporte a essa aplicação!");	
	}
	return ajax;
}

//CONTA CEP PARA PULAR PARA PROXIMO CAMPO
function Conta()
{
	var cep = document.getElementById("cep1").value;
	var numElementos = cep.length;
	
	if(numElementos == 5)
	{
		document.getElementById("cep2").focus();	
	}
	
}


//EFETUO A CONSULTA
function Processa()
{
	//INICIALIZO O OBJET XHTMLREQUEST
	ajax = IniciaAjax();
	if(ajax)
	{
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)	
				{				
					//OCULTO OS CAMPOS DESNECESSARIOS
					document.getElementById("endereco").style.display="none";
					
					//AQUI RETORNO O RESULTADO COM AS DEVIDAS PORCENTAGENS 
					var resultado = ajax.responseText;
					document.getElementById("resultado").innerHTML=resultado;
					
					//OCULTO O LOADING
					document.getElementById("loading").style.display="none";
				}
				else
				{
					alert(ajax.statusText);	
				}
			}
		}
		
		//PEGO O CEP INFORMADO PELO USUARIO
		cep1 = document.getElementById("cep1").value;
		cep2 = document.getElementById("cep2").value;
		
		//VERIFICO SE ALGUMA RESPOSTA FOI SELECIONADA
		if (!cep1 || !cep2)
		{
			alert("Informe seu cep!");
			return false;
		}
		else
		{
			//HABILITO O LOADING
			document.getElementById("loading").style.display="block";
			
			//MONTA QUERYSTRING
			dados = 'cep='+cep1+cep2;
		
			//FAZ A REQUISIÇÃO E O ENVIO PELO METODO POST
			ajax.open('POST', 'retornocep.php', true);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.send(dados);
		}
	}
	
}


//EFETUO A CONSULTA
function VerificaCpf()
{
	
	//INICIALIZO O OBJET XHTMLREQUEST
	ajax = IniciaAjax();
	if(ajax)
	{
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)	
				{									
					//AQUI RETORNO O RESULTADO COM AS DEVIDAS PORCENTAGENS 
					var resultado = ajax.responseText;
					
					if(resultado == 1)
					{
						document.getElementById("resultadocpf").style.display="inline";
						document.getElementById("resultadocpf").innerHTML="* CPF em uso!";
						document.getElementById("btnCadastrar").style.display="none";
						document.getElementById("cpf").focus();
					}
					if(resultado == 3)
					{
						document.getElementById("resultadocpf").style.display="inline";
						document.getElementById("resultadocpf").innerHTML="* CPF incorreto!";
						document.getElementById("btnCadastrar").style.display="none";
						document.getElementById("cpf").focus();
					}
					
					if(resultado != 1 && resultado != 3)
					{
						document.getElementById("resultadocpf").style.display="none";
						if(document.getElementById("btnCadastrar").style.display =="none")
						{
							document.getElementById("btnCadastrar").style.display ="inline"	
						}						
					}					
					
					//OCULTO O LOADING
					document.getElementById("loading2").style.display="none";
				}
				else
				{
					alert(ajax.statusText);	
					//OCULTO O LOADING
					document.getElementById("loading2").style.display="none";
				}
			}
		}
		
		//PEGO OS DADOS DO FORMULARIO
		cpf   = document.getElementById("cpf").value;
		document.getElementById("resultadocpf").style.display="none";
		
		//VERIFICO SE OS CAMPOS FORAM INFORMADOS
		if (!cpf)
		{
			alert("Informe seu cpf!");
			document.getElementById("cpf").value.focus();
			return false;
		}	
		else
		{
			//HABILITO O LOADING
			document.getElementById("loading2").style.display="block";
			
			//MONTA QUERYSTRING
			dados = 'cpf='+cpf;
		
			//FAZ A REQUISIÇÃO E O ENVIO PELO METODO POST
			ajax.open('POST', 'verificadados.php', true);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.send(dados);
		}
	}
	
}


//EFETUO A CONSULTA
function VerificaEmail()
{
	
	//INICIALIZO O OBJET XHTMLREQUEST
	ajax = IniciaAjax();
	if(ajax)
	{
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)	
				{									
					//AQUI RETORNO O RESULTADO COM AS DEVIDAS PORCENTAGENS 
					var resultado = ajax.responseText;
					
					if(resultado == 2)
					{
						document.getElementById("retornoemail").style.display="inline";
						document.getElementById("retornoemail").innerHTML="* E-MAIL em uso!";
						document.getElementById("btnCadastrar").style.display="none";
						document.getElementById("email").focus();
					}
					else if(resultado == 4)
					{
						document.getElementById("retornoemail").style.display="inline";
						document.getElementById("retornoemail").innerHTML="* Digite um e-mail válido!";
						document.getElementById("btnCadastrar").style.display="none";
						document.getElementById("email").focus();
					}					
					else
					{
						document.getElementById("retornoemail").style.display="none";
						if(document.getElementById("btnCadastrar").style.display =="none")
						{
							document.getElementById("btnCadastrar").style.display ="inline"	
						}
					}	
					
					//OCULTO O LOADING
					document.getElementById("loading3").style.display="none";
				}
				else
				{
					alert(ajax.statusText);	
					//OCULTO O LOADING
					document.getElementById("loading3").style.display="none";
				}
			}
		}
		
		//PEGO OS DADOS DO FORMULARIO
		email   = document.getElementById("email").value;
		
		//VERIFICO SE OS CAMPOS FORAM INFORMADOS
		if (!email)
		{
			alert("Informe seu e-mail!");
			document.getElementById("email").value.focus();
			return false;
		}	
		else
		{
			//HABILITO O LOADING
			document.getElementById("loading3").style.display="inline";
			
			//MONTA QUERYSTRING
			dados = 'email='+email;
		
			//FAZ A REQUISIÇÃO E O ENVIO PELO METODO POST
			ajax.open('POST', 'verificadados.php', true);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.send(dados);
		}
	}
	
}

function contacep()
{
	if(document.getElementById("cep").value.length == 8)
	{
		Processa();	
	}
}

function vlFisicaNacional()
{

		//PEGO OS DADOS DO FORMULARIO
		var nome = document.getElementById("nome").value;
		
		if(document.getElementById("sexo").type == "radio" && document.getElementById("sexo").checked)
		{
			var sexo = document.getElementById("sexo").value;
		}
			
		var dia  = document.getElementById("dia").value;
		var mes  = document.getElementById("mes").value;
		var ano  = document.getElementById("ano").value;
		var cpf  = document.getElementById("cpf").value;
		var ddd  = document.getElementById("ddd").value;
		var telefone      = document.getElementById("telefone").value;
		var ddd_comercial = document.getElementById("ddd_comercial").value;
		var telefone_comercial = document.getElementById("telefone_comercial").value;
		var ddd_celular   = document.getElementById("ddd_celular").value;
		var celular       = document.getElementById("celular").value;
		var cep           = document.getElementById("cep1").value+document.getElementById("cep2").value;
		var logradouro    = document.getElementById("logradouro").value;  
		var numero        = document.getElementById("numero").value;   
		var complemento   = document.getElementById("complemento").value;  
		var bairro        = document.getElementById("bairro").value; 
		var cidade        = document.getElementById("cidade").value; 
		var estado        = document.getElementById("estado").value; 
		var email         = document.getElementById("email").value;  
		var confirmar_email = document.getElementById("confirmar_email").value; 
		var senha       = document.getElementById("senha").value;
		var confirmar   = document.getElementById("confirmar").value;
		var cadastro    = 'FISICANACIONAL';
		
		
		//VERIFICO SE OS CAMPOS FORAM INFORMADOS
		if(!nome)
		{
			document.getElementById("nome").style.border="#FF3300 solid 1px";
			document.getElementById("nome").style.background="#FFEEAA";
			var erro = true;
		}
		if(!dia)
		{
			document.getElementById("dia").style.border="#FF3300 solid 1px";
			document.getElementById("dia").style.background="#FFEEAA";
			var erro = true;
		}
		if(!mes)
		{
			document.getElementById("mes").style.border="#FF3300 solid 1px";
			document.getElementById("mes").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!ano)
		{
			document.getElementById("ano").style.border="#FF3300 solid 1px";
			document.getElementById("ano").style.background="#FFEEAA";
			var erro = true;
		}
		if(!cpf)
		{
			document.getElementById("cpf").style.border="#FF3300 solid 1px";
			document.getElementById("cpf").style.background="#FFEEAA";
			var erro = true;
		}
		if(!ddd)
		{
			document.getElementById("ddd").style.border="#FF3300 solid 1px";
			document.getElementById("ddd").style.background="#FFEEAA";
			var erro = true;
		}
		if(!telefone)
		{
			document.getElementById("telefone").style.border="#FF3300 solid 1px";
			document.getElementById("telefone").style.background="#FFEEAA";
			var erro = true;
		}
		if(!ddd_celular)
		{
			document.getElementById("ddd_celular").style.border="#FF3300 solid 1px";
			document.getElementById("ddd_celular").style.background="#FFEEAA";
			var erro = true;
		}
		if(!celular)
		{
			document.getElementById("celular").style.border="#FF3300 solid 1px";
			document.getElementById("celular").style.background="#FFEEAA";
			var erro = true;
		}
		if(!cep)
		{
			document.getElementById("cep1").style.border="#FF3300 solid 1px";
			document.getElementById("cep1").style.background="#FFEEAA";
			document.getElementById("cep2").style.border="#FF3300 solid 1px";
			document.getElementById("cep2").style.background="#FFEEAA";			
			var erro = true;
		}	
		/*if(!logradouro)
		{
			document.getElementById("logradouro").style.border="#FF3300 solid 1px";
			document.getElementById("logradouro").style.background="#FFEEAA";
			var erro = true;
		}
		if(!numero)
		{
			document.getElementById("numero").style.border="#FF3300 solid 1px";
			document.getElementById("numero").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!complemento)
		{
			document.getElementById("complemento").style.border="#FF3300 solid 1px";
			document.getElementById("complemento").style.background="#FFEEAA";
			var erro = true;
		}		
		if(!bairro)
		{
			document.getElementById("bairro").style.border="#FF3300 solid 1px";
			document.getElementById("bairro").style.background="#FFEEAA";
			var erro = true;
		}
		if(!cidade)
		{
			document.getElementById("cidade").style.border="#FF3300 solid 1px";
			document.getElementById("cidade").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!estado)
		{
			document.getElementById("estado").style.border="#FF3300 solid 1px";
			document.getElementById("estado").style.background="#FFEEAA";
			var erro = true;
		}*/
		if(!email)
		{
			document.getElementById("email").style.border="#FF3300 solid 1px";
			document.getElementById("email").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!confirmar_email)
		{
			document.getElementById("confirmar_email").style.border="#FF3300 solid 1px";
			document.getElementById("confirmar_email").style.background="#FFEEAA";
			var erro = true;
		}
		if(confirmar_email != email)
		{
			alert("E-mails não conferem!");
			var erro = true;
		}
		if(!senha)
		{
			document.getElementById("senha").style.border="#FF3300 solid 1px";
			document.getElementById("senha").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!confirmar)
		{
			document.getElementById("confirmar").style.border="#FF3300 solid 1px";
			document.getElementById("confirmar").style.background="#FFEEAA";
			var erro = true;
		}
		if(confirmar != senha)
		{
			alert("Senhas não conferem!");
			var erro = true;
		}	
		if(erro)
		{
			document.getElementById("obrigatorio").innerHTML = "* Existem campos incompletos.";
			return false;	
		}
}

function vlFisicaInternacional()
{

	//INICIALIZO O OBJET XHTMLREQUEST
	ajax = IniciaAjax();
	if(ajax)
	{
		ajax.onreadystatechange = function()
		{
			if(ajax.readyState == 4)
			{
				if(ajax.status == 200)	
				{									
					//AQUI RETORNO O RESULTADO COM AS DEVIDAS PORCENTAGENS 
					var resultado = ajax.responseText;
					
					//REDIRECIONO
					location.href = resultado;
				}
				else
				{
					alert(ajax.statusText);	
					//OCULTO O LOADING
					document.getElementById("loadingcadastro").style.display="none";
				}
			}
		}
		
		
		//PEGO OS DADOS DO FORMULARIO
		var nome = document.getElementById("nome").value;
		
		if(document.getElementById("sexo").type == "radio" && document.getElementById("sexo").checked)
		{
			var sexo = document.getElementById("sexo").value;
		}
		
		if(document.getElementById("informativo").type == "checkbox" && document.getElementById("informativo").checked)
		{
			var informativo = document.getElementById("informativo").value;
		}		
		
		var dia  = document.getElementById("dia").value;
		var mes  = document.getElementById("mes").value;
		var ano  = document.getElementById("ano").value;
		var ddi  = document.getElementById("ddi").value;
		var ddd  = document.getElementById("ddd").value;
		var telefone      = document.getElementById("telefone").value;
		var ddi_comercial = document.getElementById("ddi_comercial").value;
		var ddd_comercial = document.getElementById("ddd_comercial").value;
		var telefone_comercial = document.getElementById("telefone_comercial").value;
		var ddi_celular   = document.getElementById("ddi_celular").value;
		var ddd_celular   = document.getElementById("ddd_celular").value;
		var celular       = document.getElementById("celular").value;
		var cep           = document.getElementById("cep").value;
		var logradouro    = document.getElementById("logradouro").value;  
		var numero        = document.getElementById("numero").value;   
		var complemento   = document.getElementById("complemento").value;  
		var bairro        = document.getElementById("bairro").value; 
		var cidade        = document.getElementById("cidade").value; 
		var provincia     = document.getElementById("provincia").value; 
		var email         = document.getElementById("email").value;  
		var confirmar_email = document.getElementById("confirmar_email").value; 
		var senha       = document.getElementById("senha").value;
		var confirmar   = document.getElementById("confirmar").value;
		var cliente_pais= document.getElementById("cliente_pais").value;
		
		
		//VERIFICO SE OS CAMPOS FORAM INFORMADOS
		if (!nome)
		{
			document.getElementById("nome").style.border="#FF3300 solid 1px";
			document.getElementById("nome").style.background="#FFEEAA";
			var erro = true;
		}
		if(!dia)
		{
			document.getElementById("dia").style.border="#FF3300 solid 1px";
			document.getElementById("dia").style.background="#FFEEAA";
			var erro = true;
		}
		if(!mes)
		{
			document.getElementById("mes").style.border="#FF3300 solid 1px";
			document.getElementById("mes").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!ano)
		{
			document.getElementById("ano").style.border="#FF3300 solid 1px";
			document.getElementById("ano").style.background="#FFEEAA";
			var erro = true;
		}
		if(!ddi)
		{
			document.getElementById("ddi").style.border="#FF3300 solid 1px";
			document.getElementById("ddi").style.background="#FFEEAA";
			var erro = true;
		}		
		if(!ddd)
		{
			document.getElementById("ddd").style.border="#FF3300 solid 1px";
			document.getElementById("ddd").style.background="#FFEEAA";
			var erro = true;
		}
		if(!telefone)
		{
			document.getElementById("telefone").style.border="#FF3300 solid 1px";
			document.getElementById("telefone").style.background="#FFEEAA";
			var erro = true;
		}
		if(!ddi_celular)
		{
			document.getElementById("ddi_celular").style.border="#FF3300 solid 1px";
			document.getElementById("ddi_celular").style.background="#FFEEAA";
			var erro = true;
		}		
		if(!ddd_celular)
		{
			document.getElementById("ddd_celular").style.border="#FF3300 solid 1px";
			document.getElementById("ddd_celular").style.background="#FFEEAA";
			var erro = true;
		}
		if(!celular)
		{
			document.getElementById("celular").style.border="#FF3300 solid 1px";
			document.getElementById("celular").style.background="#FFEEAA";
			var erro = true;
		}
		if(!cep)
		{
			document.getElementById("cep").style.border="#FF3300 solid 1px";
			document.getElementById("cep").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!logradouro)
		{
			document.getElementById("logradouro").style.border="#FF3300 solid 1px";
			document.getElementById("logradouro").style.background="#FFEEAA";
			var erro = true;
		}
		if(!numero)
		{
			document.getElementById("numero").style.border="#FF3300 solid 1px";
			document.getElementById("numero").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!complemento)
		{
			document.getElementById("complemento").style.border="#FF3300 solid 1px";
			document.getElementById("complemento").style.background="#FFEEAA";
			var erro = true;
		}		
		if(!bairro)
		{
			document.getElementById("bairro").style.border="#FF3300 solid 1px";
			document.getElementById("bairro").style.background="#FFEEAA";
			var erro = true;
		}
		if(!cidade)
		{
			document.getElementById("cidade").style.border="#FF3300 solid 1px";
			document.getElementById("cidade").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!provincia)
		{
			document.getElementById("provincia").style.border="#FF3300 solid 1px";
			document.getElementById("provincia").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!cliente_pais)
		{
			document.getElementById("cliente_pais").style.border="#FF3300 solid 1px";
			document.getElementById("cliente_pais").style.background="#FFEEAA";
			var erro = true;				
		}
		if(!email)
		{
			document.getElementById("email").style.border="#FF3300 solid 1px";
			document.getElementById("email").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!confirmar_email)
		{
			document.getElementById("confirmar_email").style.border="#FF3300 solid 1px";
			document.getElementById("confirmar_email").style.background="#FFEEAA";
			var erro = true;
		}
		if(confirmar_email != email)
		{
			alert("E-mails não conferem!");
			var erro = true;
		}
		if(!senha)
		{
			document.getElementById("senha").style.border="#FF3300 solid 1px";
			document.getElementById("senha").style.background="#FFEEAA";
			var erro = true;
		}	
		if(!confirmar)
		{
			document.getElementById("confirmar").style.border="#FF3300 solid 1px";
			document.getElementById("confirmar").style.background="#FFEEAA";
			var erro = true;
		}
		if(confirmar != senha)
		{
			alert("Senhas não conferem!");
		}	
		if(erro)
		{
			return false;	
		}
		else
		{

			//HABILITO O LOADING
			document.getElementById("loadingcadastro").style.display="inline";
			
			//MONTA QUERYSTRING
			dados = 'nome='+nome+'&sexo='+sexo+'&dia='+dia+'&mes='+mes+'&ano='+ano+'&ddi='+ddi+'&ddi_celular='+ddi_celular+'&ddi_comercial='+ddi_comercial+'&ddd='+ddd+'&cliente_pais='+cliente_pais+'&telefone='+telefone+'&ddd_comercial='+ddd_comercial+'&telefone_comercial='+telefone_comercial+'&ddd_celular='+ddd_celular+'&celular='+celular+'&cep='+cep+'&logradouro='+logradouro+'&numero='+numero+'&complemento='+complemento+'&bairro='+bairro+'&cidade='+cidade+'&email='+email+'&senha='+senha+'&provincia='+provincia+'&informativo='+informativo;
		
			//FAZ A REQUISIÇÃO E O ENVIO PELO METODO POST
			ajax.open('POST', 'gravardados.php', true);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.send(dados);
		}
	}		
}

//---------------------------------VALIDAR FORMULARIOS----------------------------------------\\
function validarFormulario(formObj) 
{   
    for (i=0; i<formObj.elements.length; i++) 
	{   
        var fieldValue = formObj.elements[i].value;
		var fieldName  = formObj.elements[i].name;   
        if(fieldValue == '' && fieldName.charAt(0) != '@')
		{   
            alert('CAMPO OBRIGATORIO!'+fieldName);   
            formObj.elements[i].focus();   
            return false;   
        } 
    }
	Show();
    return true;   
}

//------------------------------------LOADING---------------------------------------------------\\
function Show() 
{                
	document.getElementById("prevew").style.display='block';        
	document.getElementById("Buttom").innerHTML = "<span onclick=\"Hidden()\">Ocultar</span>";        
}

//Mascara para tel, cep, cel
function formatar(src, mask)
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida)
  {
        src.value += texto.substring(0,1);
  }
}

//Somente numeros
function numbers(evt)
{
	var key_code = evt.keyCode  ? evt.keyCode  :
				   evt.charCode ? evt.charCode :
				   evt.which    ? evt.which    : void 0;


	// Habilita teclas <DEL>, <TAB>, <ENTER>, <ESC> e <BACKSPACE>
	if (key_code == 8  ||  key_code == 9  ||  key_code == 27  ||  key_code == 46 || key_code == 13)
	{
		return true;
	}

	// Habilita teclas <HOME>, <END>, mais as quatros setas de navegação (cima, baixo, direta, esquerda)
	else if ((key_code >= 35)  &&  (key_code <= 40))
	{
		return true
	}

	// Habilita números de 0 a 9
	else if ((key_code >= 48)  &&  (key_code <= 57))
	{
		return true
	}

	return false;
}


function abrir(pagina,largura,altura) 
{

	//pega a resolução do visitante
	w = screen.width;
	h = screen.height;

	//divide a resolução por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;

	//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;

	//abre a nova janela, já com a sua devida posição
	window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
}

function mensagem()
{
	document.write("Cadastro feito com sucesso!");	
}

function validacontato(nomeform)
{
	if(nomeform.nome.value=="")
	{
		alert("Por favor informe o seu nome!");
		nomeform.nome.focus();
		return false;
	}
	if(nomeform.email.value=="")
	{
		alert("Por favor informe o seu E-mail!");
		nomeform.email.focus();
		return false;
	}
	
	if(nomeform.email.value.indexOf('@', 1) == -1)
	{
		alert("Por favor informe um email valido!");
		nomeform.email.focus();
		return false;
	}
	if(nomeform.email.value.indexOf('.', 1) == -1)
	{
		alert("Por favor informe um email valido!");
		nomeform.email.focus();
		return false;
	}
	if(nomeform.email.value != nomeform.confirma_email.value)
	{
		alert("Os e-mails nao conferem!");
		nomeform.confirma_email.focus();
		return false;
	}
	if(nomeform.ddd.value=="")
	{
		alert("Por favor informe seu DDD!");
		nomeform.ddd.focus();
		return false;
	}
	if(nomeform.telefone.value=="")
	{
		alert("Por favor informe o seu telefone!");
		nomeform.telefone.focus();
		return false;
	}
	if(nomeform.assunto.value=="")
	{
		alert("Por favor informe o seu assunto!");
		nomeform.assunto.focus();
		return false;
	}
	if(nomeform.mensagem.value=="")
	{
		alert("Por favor informe sua mensagem!");
		nomeform.mensagem.focus();
		return false;
	}	

}


function validacadastro(nomeform)
{
	
	if(nomeform.cpf.value=="")
	{
		alert("Por favor informe o seu CPF!");
		nomeform.cpf.focus();
		return false;
	}	
	if(nomeform.email.value=="")
	{
		alert("Por favor informe o seu E-mail!");
		nomeform.email.focus();
		return false;
	}

	if(nomeform.email.value.indexOf('@', 1) == -1)
	{
		alert("Por favor informe um email valido!");
		nomeform.email.focus();
		return false;
	}
	if(nomeform.email.value.indexOf('.', 1) == -1)
	{
		alert("Por favor informe um email valido!");
		nomeform.email.focus();
		return false;
	}
	if(nomeform.email.value != nomeform.confirma_email.value)
	{
		alert("E-mails nao conferem!");
		nomeform.confirma_email.focus();
		return false;
	}

}


function OnlyNumbers(e) {

if (window.event) //IE
{
tecla = e.keyCode;
}

else if (e.which) //FF
{
tecla = e.which;
}
//techa==8 é para permitir o backspace funcionar para apagar

if ( (tecla >= 48 && tecla <= 57)||(tecla == 8 ) ) {
return true;
}
else {
return false;
}

}