// Scripts

function getId(obj)
{
	return document.getElementById(obj);
}

function complemento(obj)
{
	switch(obj)
	{
		case 'abre' : getId('linhacomplemento').style.visibility = 'visible'; break;
		case 'fecha' : getId('linhacomplemento').style.visibility = 'hidden'; break;
	}
}

function desativaFormularios() {

 document.getElementById('dFormularioNovasTurmas').style.display = 'none';
 document.getElementById('dFormularioCursoEspecifico').style.display = 'none';
 document.getElementById('dFormularioInscricao').style.display = ''; }

function alternaFormulario1(obj) {
	var chkbox1 = document.getElementById('item1');
	var chkbox3 = document.getElementById('item3');
	var chkbox4 = document.getElementById('item4');

	if (chkbox3.checked == true)
	  chkbox3.click();
	if (chkbox4.checked == true)
	  chkbox4.click();

	var el = document.getElementById(obj);
	if (el.style.display != 'none') {
		el.style.display = 'none'; }
	else {
	el.style.display = ''; }

}

function alternaFormulario3(obj) {
	var chkbox1 = document.getElementById('item1');
	var chkbox3 = document.getElementById('item3');
	var chkbox4 = document.getElementById('item4');

	if (chkbox1.checked == true)
	  chkbox1.click();
	if (chkbox4.checked == true)
	  chkbox4.click();

	var el = document.getElementById(obj);
	if (el.style.display != 'none') {
		el.style.display = 'none'; }
	else {
	el.style.display = ''; }

}

function alternaFormulario4(obj) {
	var chkbox1 = document.getElementById('item1');
	var chkbox3 = document.getElementById('item3');
	var chkbox4 = document.getElementById('item4');

	if (chkbox1.checked == true)
	  chkbox1.click();
	if (chkbox3.checked == true)
	  chkbox3.click();

	var el = document.getElementById(obj);
	if (el.style.display != 'none') {
		el.style.display = 'none'; }
	else {
	el.style.display = ''; }

}

function tirarSelecao() {
	var chkbox = document.getElementById("item");
	if (chkbox.focus()!= true) {
		for (x = 0; x < chkbox.length; x++) {
			chkbox.click(); }
	}
}

function validaFormNovasTurmas(){
           d = document.formularioNovasTurmas;
           //validar nome
         if (d.tx_nome.value == ""){
                   alert("O campo nome deve ser preenchido!");
                   d.tx_nome.focus();
                   return false;
         }
		  //validar e-mail
           if (d.tx_email.value == ""){
                     alert("O campo e-mail deve ser preenchido!");
                     d.tx_email.focus();
                     return false;
          }
		  //validar confirmação de e-mail           
			if (d.tx_email_confirmacao.value == ""){
                     alert("O campo de confirmação de e-mail também deve ser preenchido!");
                     d.tx_email_confirmacao.focus();
                     return false;
          }
         return true;
}

function validaFormCursoCidade(){
           d = document.formularioCursoCidade;
           //validar nome
         if (d.tx_nome.value == ""){
                   alert("O campo nome deve ser preenchido!");
                   d.tx_nome.focus();
                   return false;
         }
		  //validar e-mail
           if (d.tx_email.value == ""){
                     alert("O campo e-mail deve ser preenchido!");
                     d.tx_email.focus();
                     return false;
          }
		  //validar confirmação de e-mail           
			if (d.tx_email_confirmacao.value == ""){
                     alert("O campo de confirmação de e-mail também deve ser preenchido!");
                     d.tx_email_confirmacao.focus();
                     return false;
          }
         return true;
}

function validaFormCursoEspecifico(){
           d = document.formularioCursoEspecifico;
           //validar nome
         if (d.tx_nome.value == ""){
                   alert("O campo nome deve ser preenchido!");
                   d.tx_nome.focus();
                   return false;
         }
		  //validar e-mail
           if (d.tx_email.value == ""){
                     alert("O campo e-mail deve ser preenchido!");
                     d.tx_email.focus();
                     return false;
          }
		  //validar confirmação de e-mail           
			if (d.tx_email_confirmacao.value == ""){
                     alert("O campo de confirmação de e-mail também deve ser preenchido!");
                     d.tx_email_confirmacao.focus();
                     return false;
          }
         return true;
}

function validaFormInscricao(){

           d = document.formularioInscricao;

           //validar nome

         if (d.tx_nome.value == ""){
                   alert("O campo NOME deve ser preenchido!");
                   d.tx_nome.focus();
                   return false;
         }

			//validar cpf

         if (d.tx_cpf.value == ""){
                   alert("O campo CPF deve ser preenchido!");
                   d.tx_cpf.focus();
                   return false;
         }
           //validar endereco residencial

         if (d.txt_enderecoRes.value == ""){
                   alert("O campo ENDERECO RESIDENCIAL deve ser preenchido!");
                   d.txt_enderecoRes.focus();
                   return false;
         }

           //validar cidade

         if (d.tx_cidade.value == ""){
                   alert("O campo MUNICIPIO nome deve ser preenchido!");
                   d.tx_cidade.focus();
                   return false;
         }

           //validar estado

         if (d.cb_uf.value == ""){
                   alert("O campo UF nome deve ser preenchido!");
                   d.cb_uf.focus();
                   return false;
         }

           //validar cep

         if (d.tx_CEP.value == ""){
                   alert("O campo CEP nome deve ser preenchido!");
                   d.tx_CEP.focus();
                   return false;
         }

           //validar telefone residencial

         if (d.tx_tel_casa.value == ""){
                   alert("O campo TELEFONE RESIDENCIAL nome deve ser preenchido!");
                   d.tx_tel_casa.focus();
                   return false;
         }

		  //validar e-mail

           if (d.tx_email.value == ""){
                     alert("O campo e-mail deve ser preenchido!");
                     d.tx_email.focus();
                     return false;
          }

		  //validar data de nascimento

           if (d.tx_datanasc.value == ""){
                     alert("O campo DATA DE NASCIMENTO deve ser preenchido!");
                     d.tx_datanasc.focus();
                     return false;
          }

         return true;
		
}

function chkboxbh() {
	
	var chkboxum = document.getElementById('belohorizonte');
	var chkboxdois = document.getElementById('brasilia');

	if (chkboxdois.checked == true)
	  chkboxdois.click();

}

function chkboxbrasilia() {
	
	var chkboxum = document.getElementById('belohorizonte');
	var chkboxdois = document.getElementById('brasilia');

	if (chkboxum.checked == true)
	  chkboxum.click();

}

function chkboxdata(obj) {

	var formularioTratado = document.getElementById("formularioInscricao").elements;
	var ck = document.getElementById(obj);

	for (x = 0; x < formularioTratado.length; x++)
	{
		if (formularioTratado[x] != ck) 
		{
			if (formularioTratado[x].checked == true)
			  formularioTratado[x].click();
		}
	}

}
