var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
    if (event.button==2){
        //alert(message);
        return false;
    }
}

function clickNS4(e){
    if (document.layers||document.getElementById&&!document.all){
        if (e.which==2||e.which==3){
            //alert(message);
            return false;
        }
    }
}

if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS4;
}
    else if (document.all&&!document.getElementById){
    document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function abrir_janela_popup(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function quantoGanhar() {
  abrir_janela_popup('calculo.php','calculo','scrollbar=yes,width=300,height=400,top=0,left=0');
}




function calculo() {
	f = document.forms[0];
	campo = f.ganhar.value;
	if ((isNaN(campo)) || (campo<10)) {
		alert("Informe um número maior que 10");
	}
	else
	{
		f.submit();
	}
}

function validarContato()
{
	msgErros = '';
	cntErros = 0;
	with (document.formContato)
	{
		if (Nome.value.length < 3)
		{
			msgErros += "-> Nome\n";
			cntErros++;
		}
		
		if (DataNascimento.value.length < 3)
		{
			msgErros += "-> DataNascimento\n";
			cntErros++;
		}
			
		if (Endereco.value.length < 5)
		{
			msgErros += "-> Endereço\n";
			cntErros++;
		}
		
		if (Bairro.value.length < 3)
		{
			msgErros += "-> Bairro\n";
			cntErros++;
		}
		
		if (CEP.value.length < 5)
		{
			msgErros += "-> CEP\n";
			cntErros++;
		}

		
		if (Cidade.value.length < 3)
		{
			msgErros += "-> Cidade\n";
			cntErros++;
		}
		
		if (UF.value.length < 2)
		{
			msgErros += "-> UF\n";
			cntErros++;
		}
		
	
		if (Telefone.value.length < 6)
		{
			msgErros += "-> Fone\n";
			cntErros++;
		}
		
		
		if (Email.value.length < 6)
		{
			msgErros += "-> Email\n";
			cntErros++;
		}
		else
		{
			if (Email.value.indexOf('@',0)==-1 ||
				Email.value.indexOf('@',0)== 0 ||
				Email.value.indexOf('.',0)==-1)
      	{
            msgErros += "-> Email (é inválido)\n";
				cntErros++;
      	}
		}
		
		if (Mensagem.value.length < 5)
		{
			msgErros += "-> Mensagem\n";
			cntErros++;
		}
	
		if (cntErros > 0)
		{
			alert("Você precisa preencher corretamente o(s) campo(s)\n abaixo para poder enviar o formulário:\n" + msgErros);
		}
		else
		{
			if (confirm("Você está de acordo com as informações contidas no formulário?"))
			{
				action = "envia_mail.php";
				submit();
			}
		}
	}

}


function validarRevendedor()
{
	msgErros = '';
	cntErros = 0;
	with (document.formRevendedor)
	{
		if (Nome.value.length < 3)
		{
			msgErros += "-> Nome\n";
			cntErros++;
		}
		
		if (DataNascimento.value.length < 3)
		{
			msgErros += "-> DataNascimento\n";
			cntErros++;
		}
		
		if (Escolaridade.value.length < 3)
		{
			msgErros += "-> Escolaridade\n";
			cntErros++;
		}
			
		if (Endereco.value.length < 5)
		{
			msgErros += "-> Endereço\n";
			cntErros++;
		}
		
		if (Bairro.value.length < 3)
		{
			msgErros += "-> Bairro\n";
			cntErros++;
		}
		
		if (CEP.value.length < 5)
		{
			msgErros += "-> CEP\n";
			cntErros++;
		}

		
		if (Cidade.value.length < 3)
		{
			msgErros += "-> Cidade\n";
			cntErros++;
		}
		
		if (UF.value.length < 2)
		{
			msgErros += "-> UF\n";
			cntErros++;
		}
		
		
		if (CPF.value.length < 2)
		{
			msgErros += "-> CPF\n";
			cntErros++;
		}
		
		
		if (RG.value.length < 2)
		{
			msgErros += "-> RG\n";
			cntErros++;
		}
	
		if (Telefone.value.length < 6)
		{
			msgErros += "-> Fone\n";
			cntErros++;
		}
		
		
		if (Email.value.length < 6)
		{
			msgErros += "-> Email\n";
			cntErros++;
		}
		else
		{
			if (Email.value.indexOf('@',0)==-1 ||
				Email.value.indexOf('@',0)== 0 ||
				Email.value.indexOf('.',0)==-1)
      	{
            msgErros += "-> Email (é inválido)\n";
				cntErros++;
      	}
		}
		
		if (Mensagem.value.length < 5)
		{
			msgErros += "-> Mensagem\n";
			cntErros++;
		}
	
		if (cntErros > 0)
		{
			alert("Você precisa preencher corretamente o(s) campo(s)\n abaixo para poder enviar o formulário:\n" + msgErros);
		}
		else
		{
			if (confirm("Você está de acordo com as informações contidas no formulário?"))
			{
				action = "envia_mail.php";
				submit();
			}
		}
	}

}


function validarCadastro()
{
	msgErros = '';
	cntErros = 0;
	with (document.formCadastro)
	{
		if (Nome.value.length < 3)
		{
			msgErros += "-> Nome\n";
			cntErros++;
		}
		
		if (Telefone.value.length < 6)
		{
			msgErros += "-> Fone\n";
			cntErros++;
		}
		
		
		if (Email.value.length < 6)
		{
			msgErros += "-> Email\n";
			cntErros++;
		}
		else
		{
			if (Email.value.indexOf('@',0)==-1 ||
				Email.value.indexOf('@',0)== 0 ||
				Email.value.indexOf('.',0)==-1)
      	{
            msgErros += "-> Email (é inválido)\n";
				cntErros++;
      	}
		}
		
		if (!Concordo.checked)
		{
			msgErros += "-> Você precisa concordar em receber informações sobre cursos.\n";
			cntErros++;
		}
	
		if (cntErros > 0)
		{
			alert("Você precisa preencher corretamente o(s) campo(s)\n abaixo para poder enviar o formulário:\n" + msgErros);
		}
		else
		{
			action = "envia_mail.php";
			submit();
		}
	}

}


function validarTeste(tipo){

f = eval("document."+tipo);
//p = pergunta
//o = alternativa

a = b = c = d = 0;

msg = "";
for (var p = 1; p <= 10; p++)
{
	for (var o = 0; o < 4; o++)
	{
		opcao = eval("f.perg"+p+"["+o+"]");
   		if (opcao.checked) {
			opcaomarcada = opcao.value;
			//letraopcao = eval(opcaomarcada++);
			if (opcaomarcada == "a") {a++;}
			if (opcaomarcada == "b") {b++;}
			if (opcaomarcada == "c") {c++;}
			if (opcaomarcada == "d") {d++;}
		}
	}
	msg = msg + opcaomarcada + "\n";
}

//maismarcada = "a"
//if (b > eval(maismarcada)) { maismarcada = "b"};
//if (c > eval(maismarcada)) { maismarcada = "c"};
//if (d > eval(maismarcada)) { maismarcada = "d"};

opcoes = "A = "+a;
opcoes += "\nB = "+b;
opcoes += "\nC = "+c;
opcoes += "\nD = "+d;
//alert(opcoes);

qualTeste = "resultado_"+tipo;

eval(document.getElementById(qualTeste)).style.display = 'block';
location.href="#"+qualTeste;

f.a.value = a;
f.b.value = b;
f.c.value = c;
f.d.value = d;

}

function abreTeste(tipo) {
	if (tipo == "feminino") {
		document.getElementById("teste_feminino").style.display = 'block';
		document.getElementById("teste_masculino").style.display = 'none';
		}
	else {
		document.getElementById("teste_feminino").style.display = 'none';
		document.getElementById("teste_masculino").style.display = 'block';
		}
document.getElementById("resultado_feminino").style.display = 'none';
document.getElementById("resultado_masculino").style.display = 'none';
location.href="#";
}


function validarHome()
{
	msgErros = '';
	cntErros = 0;
	with (document.formHome)
	{
    	
    	if (ComoChegou[6].checked == true)
		{
			
    		if (SiteOutros.value.length < 3)
    		{
    			msgErros += "-> Informe como conheceu\n";
    			cntErros++;
    		}

	    }
    	
    	
		if (ReceberEmail[0].checked == true)
		{
			
    		if (Email.value.length < 6)
    		{
    			msgErros += "-> Email\n";
    			cntErros++;
    		}
    		else
    		{
    			if (Email.value.indexOf('@',0)==-1 ||
    				Email.value.indexOf('@',0)== 0 ||
    				Email.value.indexOf('.',0)==-1)
              	{
                    msgErros += "-> Email (é inválido)\n";
        			cntErros++;
              	}
        		
    		}
    		
    		if (Nome.value.length < 2)
    		{
    			msgErros += "-> Nome\n";
    			cntErros++;
    		}
	    }
		
	
		if (cntErros > 0)
		{
			alert("Você precisa preencher corretamente o(s) campo(s)\n abaixo para poder enviar o formulário:\n" + msgErros);
		}
		else
		{
			action = "envia_mail.php";
			submit();
		}
	}

}
