function FormataCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres){
	var wTecla, wVr, wTam;
 
       // alert(pForm[pCampo].value);
  
	wTecla = pTeclaPres.keyCode;
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "-", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( "/", "" );
	wTam = wVr.length ;

	 if (wTam < pTamMax && wTecla != 8) { 
	    wTam = wVr.length + 1 ; 
	 }
	
	 if (wTecla == 8 ) { 
	    wTam = wTam - 1 ; 
	 }
	   
	 if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
	  if ( wTam <= 2 ){
	    pForm[pCampo].value = wVr ;
	  }
	  if (wTam > pPosTraco && wTam <= pTamMax) {
	        wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
	  }
	  if ( wTam == pTamMax){
	        wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
	  }
	  pForm[pCampo].value = wVr;
	 
	 }

}



	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	function autoTab(input,len, e) {
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		
		if(input.value.length >= len && !containsElement(filter,keyCode)) {
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
			return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else 
			i++;
		return index;
		}
		return true;
	}
	
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 ValidaPessoaFisica(src){

	if (src.txtNome.value == ""){
		alert('Digite seu nome!');
		src.txtNome.style.backgroundColor = "lightyellow";
		src.txtNome.focus();
		return
	}
	
	if (src.txtCNPJCPF.value == ""){
		alert('Digite seu CPF/CNPJ!');
		src.txtCNPJCPF.style.backgroundColor = "lightyellow";
		src.txtCNPJCPF.focus();
		return
	}
	
	if (src.txtEndereco.value == ""){
		alert('Digite sua Rua!');
		src.txtEndereco.style.backgroundColor = "lightyellow";
		src.txtEndereco.focus();
		return
	}
	
	if (src.txtNumero.value == ""){
		alert('Digite o número da sua residência!');
		src.txtNumero.style.backgroundColor = "lightyellow";
		src.txtNumero.focus();
		return
	}
	
	if (src.txtBairro.value == ""){
		alert('Digite seu bairro!');
		src.txtBairro.style.backgroundColor = "lightyellow";
		src.txtBairro.focus();
		return
	}
	
	if (src.txtCidade.value == ""){
		alert('Digite sua cidade!');
		src.txtCidade.style.backgroundColor = "lightyellow";
		src.txtCidade.focus();
		return
	}
	
	if (src.cmbEstado.value == ""){
		alert('Escolha o seu estado!');
		src.cmbEstado.style.backgroundColor = "lightyellow";
		src.cmbEstado.focus();
		return
	}
	
	if (src.txtCep1.value == ""){
		alert('Digite a primeira parte do seu CEP!');
		src.txtCep1.style.backgroundColor = "lightyellow";
		src.txtCep1.focus();
		return
	}
	
	if (src.txtCep2.value == ""){
		alert('Digite a segunda parte do seu CEP!');
		src.txtCep2.style.backgroundColor = "lightyellow";
		src.txtCep2.focus();
		return
	}
	
	if (src.txtTelefoneResidencialDdd.value == ""){
		alert('Digite o DDD!');
		src.txtTelefoneResidencialDdd.style.backgroundColor = "lightyellow";
		src.txtTelefoneResidencialDdd.focus();
		return
	}
	
	if (src.txtTelefoneResidencial.value == ""){
		alert('Digite o telefone residencial!');
		src.txtTelefoneResidencial.style.backgroundColor = "lightyellow";
		src.txtTelefoneResidencial.focus();
		return
	}
	
	if (src.txtEmail.value == ""){
		alert('Digite o e-mail!');
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}

	if (src.txtEmail.value.indexOf('@', 0) == -1 || src.txtEmail.value.indexOf('.', 0) == -1){
		alert("E-mail inválido! Digite novamente!");
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}
	
	if (src.txtTemasInteresse.value == ""){
		alert('Digite os seus temas de interesse!');
		src.txtTemasInteresse.style.backgroundColor = "lightyellow";
		src.txtTemasInteresse.focus();
		return
	}
	
	if (src.txtLogin.value == ""){
		alert('Digite o seu login!');
		src.txtLogin.style.backgroundColor = "lightyellow";
		src.txtLogin.focus();
		return
	}
	
	if (src.txtLogin.value.length < 4) {
		alert ('O login precisa ter no mínimo quatro e no máximo oito caracteres!');
		src.txtLogin.style.backgroundColor = "lightyellow";
		src.txtLogin.focus();
		return
	}
	
	if (src.txtSenha.value == ""){
		alert('Digite sua senha!');
		src.txtSenha.style.backgroundColor = "lightyellow";
		src.txtSenha.focus();
		return
	}
	// verifica se a senha possui ao menos quatro caracteres
	if (src.txtSenha.value.length < 4) {
		alert ('A senha precisa ter no mínimo quatro e no máximo dez caracteres!');
		src.txtSenha.style.backgroundColor = "lightyellow";
		src.txtSenha.focus();
		return
	}
	if (src.txtSenhaConfirmacao.value == ""){
		alert('Digite a confirmação da senha!');
		src.txtSenhaConfirmacao.style.backgroundColor = "lightyellow";
		src.txtSenhaConfirmacao.focus();
		return
	}
	if (src.txtSenhaConfirmacao.value != src.txtSenha.value){
		alert('A senha e a confirmação não conferem!');
		src.txtSenhaConfirmacao.style.backgroundColor = "lightyellow";
		src.txtSenhaConfirmacao.focus();
		return
	}
	
	src.submit();
}

function ValidaPessoaJuridica(src){

	if (src.txtNome.value == ""){
		alert('Digite a razão social da sua empresa!');
		src.txtNome.style.backgroundColor = "lightyellow";
		src.txtNome.focus();
		return
	}
	
	if (src.txtCNPJCPF.value == ""){
		alert('Digite seu CPF/CNPJ!');
		src.txtCNPJCPF.style.backgroundColor = "lightyellow";
		src.txtCNPJCPF.focus();
		return
	}
	
	if (src.txtInscricaoEstadual.value == ""){
		alert('Digite a inscrição estadual da sua empresa!');
		src.txtInscricaoEstadual.style.backgroundColor = "lightyellow";
		src.txtInscricaoEstadual.focus();
		return
	}
	
	if (src.txtEndereco.value == ""){
		alert('Digite sua Rua!');
		src.txtEndereco.style.backgroundColor = "lightyellow";
		src.txtEndereco.focus();
		return
	}
	
	if (src.txtNumero.value == ""){
		alert('Digite o número da sua residência!');
		src.txtNumero.style.backgroundColor = "lightyellow";
		src.txtNumero.focus();
		return
	}
	
	if (src.txtBairro.value == ""){
		alert('Digite seu bairro!');
		src.txtBairro.style.backgroundColor = "lightyellow";
		src.txtBairro.focus();
		return
	}
	
	if (src.txtCidade.value == ""){
		alert('Digite sua cidade!');
		src.txtCidade.style.backgroundColor = "lightyellow";
		src.txtCidade.focus();
		return
	}
	
	if (src.cmbEstado.value == ""){
		alert('Escolha o seu estado!');
		src.cmbEstado.style.backgroundColor = "lightyellow";
		src.cmbEstado.focus();
		return
	}
	
	if (src.txtCep1.value == ""){
		alert('Digite a primeira parte do seu CEP!');
		src.txtCep1.style.backgroundColor = "lightyellow";
		src.txtCep1.focus();
		return
	}
	
	if (src.txtCep2.value == ""){
		alert('Digite a segunda parte do seu CEP!');
		src.txtCep2.style.backgroundColor = "lightyellow";
		src.txtCep2.focus();
		return
	}
	
	if (src.txtTelefoneComercialDdd.value == ""){
		alert('Digite o DDD!');
		src.txtTelefoneComercialDdd.style.backgroundColor = "lightyellow";
		src.txtTelefoneComercialDdd.focus();
		return
	}
	
	if (src.txtTelefoneComercial.value == ""){
		alert('Digite o telefone comercial!');
		src.txtTelefoneComercial.style.backgroundColor = "lightyellow";
		src.txtTelefoneComercial.focus();
		return
	}
	
	if (src.txtEmail.value == ""){
		alert('Digite o e-mail!');
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}

	if (src.txtEmail.value.indexOf('@', 0) == -1 || src.txtEmail.value.indexOf('.', 0) == -1){
		alert("E-mail inválido! Digite novamente!");
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}
	
	if (src.txtTemasInteresse.value == ""){
		alert('Digite os seus temas de interesse!');
		src.txtTemasInteresse.style.backgroundColor = "lightyellow";
		src.txtTemasInteresse.focus();
		return
	}
	
	if (src.txtLogin.value == ""){
		alert('Digite o seu login!');
		src.txtLogin.style.backgroundColor = "lightyellow";
		src.txtLogin.focus();
		return
	}
	
	if (src.txtLogin.value.length < 4) {
		alert ('O login precisa ter no mínimo quatro e no máximo oito caracteres!');
		src.txtLogin.style.backgroundColor = "lightyellow";
		src.txtLogin.focus();
		return
	}
	
	if (src.txtSenha.value == ""){
		alert('Digite sua senha!');
		src.txtSenha.style.backgroundColor = "lightyellow";
		src.txtSenha.focus();
		return
	}
	// verifica se a senha possui ao menos quatro caracteres
	if (src.txtSenha.value.length < 4) {
		alert ('A senha precisa ter no mínimo quatro e no máximo dez caracteres!');
		src.txtSenha.style.backgroundColor = "lightyellow";
		src.txtSenha.focus();
		return
	}
	if (src.txtSenhaConfirmacao.value == ""){
		alert('Digite a confirmação da senha!');
		src.txtSenhaConfirmacao.style.backgroundColor = "lightyellow";
		src.txtSenhaConfirmacao.focus();
		return
	}
	if (src.txtSenhaConfirmacao.value != src.txtSenha.value){
		alert('A senha e a confirmação não conferem!');
		src.txtSenhaConfirmacao.style.backgroundColor = "lightyellow";
		src.txtSenhaConfirmacao.focus();
		return
	}
	
	src.submit();
}


<!--
window.defaultStatus = "";
function Janela(pagina) {
   var nomearq = pagina;
   var windowvar = window.open(nomearq,'Janela',"scrollbars=yes,location=no,directories=no,status=no,menubar=no,resizable=no,maxbutton=no,toolbar=no,top=0,left=0,width=500,height=480");
   windowvar.focus();
}
// -->


//function Janela(pagina) {
//	window.open(pagina, 'Janela', 'height=480,width=500,top=10,left=10,scrollbars=yes');
//	window.focus();
//}

function ValidarFormEnviarFoto(src){

	//if (src.txtDe.value == ""){
	//	alert('Digite seu nome!');
	//	src.txtDe.style.backgroundColor = "lightyellow";
	//	src.txtDe.focus();
	//	return
	//}
	
	//if (src.txtEmailDe.value == ""){
	//	alert('Digite seu e-mail!');
	//	src.txtEmailDe.style.backgroundColor = "lightyellow";
	//	src.txtEmailDe.focus();
	//	return
	//}
	
	//if (src.txtEmailDe.value.indexOf('@', 0) == -1 || src.txtEmailDe.value.indexOf('.', 0) == -1){
	//	alert("E-mail inválido! Digite novamente!");
	//	src.txtEmailDe.style.backgroundColor = "lightyellow";
	//	src.txtEmailDe.focus();
	//	return
	//}
	
	if (src.txtPara.value == ""){
		alert('Digite o nome do seu amigo!');
		src.txtPara.style.backgroundColor = "lightyellow";
		src.txtPara.focus();
		return
	}
	
	if (src.txtEmailPara.value == ""){
		alert('Digite o e-mail do seu amigo!');
		src.txtEmailPara.style.backgroundColor = "lightyellow";
		src.txtEmailPara.focus();
		return
	}
	
	if (src.txtEmailPara.value.indexOf('@', 0) == -1 || src.txtEmailPara.value.indexOf('.', 0) == -1){
		alert("E-mail do seu amigo é inválido! Digite novamente!");
		src.txtEmailPara.style.backgroundColor = "lightyellow";
		src.txtEmailPara.focus();
		return
	}
	
	src.submit();
}

function ValidarFormFaleConosco(src){

	if (src.txtNome.value == ""){
		alert('Digite o seu nome!');
		src.txtNome.style.backgroundColor = "lightyellow";
		src.txtNome.focus();
		return
	}
	
	if (src.txtEmail.value == ""){
		alert('Digite o seu e-mail!');
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}
	
	if (src.txtEmail.value.indexOf('@', 0) == -1 || src.txtEmail.value.indexOf('.', 0) == -1){
		alert("E-mail inválido! Digite novamente!");
		src.txtEmail.style.backgroundColor = "lightyellow";
		src.txtEmail.focus();
		return
	}
	
	if (src.txtTelefone.value == ""){
		alert('Digite o seu telefone!');
		src.txtTelefone.style.backgroundColor = "lightyellow";
		src.txtTelefone.focus();
		return
	}
	
	if (src.txtComentario.value == ""){
		alert('Digite o seu comentário!');
		src.txtComentario.style.backgroundColor = "lightyellow";
		src.txtComentario.focus();
		return
	}
	src.submit();
}

 function goHist(a) 
 {
 
    history.go(a);      // Go back one.
 
 }
 

 



