// ------- Submenu -------- //

var lastActiveSubMenu = 'submenu-vestibular2009';

function OpenCloseSubMenu(subMenuId, show)

{

	if (document.getElementById(subMenuId))

	{

		document.getElementById(lastActiveSubMenu).style.display = 'none';

		document.getElementById(subMenuId).style.display = '';

		lastActiveSubMenu = subMenuId;

	}

}



// Calendrio

function OnChangeCalendar(city)

{

	if (city == 'saopaulo')

	{

		document.getElementById('div-calendario-campinas').style.display = 'none';

		document.getElementById('div-calendario-natal').style.display = 'none';

		document.getElementById('div-calendario-saopaulo').style.display = '';

		

		document.getElementById('div-calendario-campinas-legenda').style.display = 'none';

		document.getElementById('div-calendario-natal-legenda').style.display = 'none';

		document.getElementById('div-calendario-saopaulo-legenda').style.display = '';

	}

	else if (city == 'campinas')

	{

		document.getElementById('div-calendario-campinas').style.display = '';

		document.getElementById('div-calendario-natal').style.display = 'none';

		document.getElementById('div-calendario-saopaulo').style.display = 'none';

		

		document.getElementById('div-calendario-campinas-legenda').style.display = '';

		document.getElementById('div-calendario-natal-legenda').style.display = 'none';

		document.getElementById('div-calendario-saopaulo-legenda').style.display = 'none';

	}

	else if (city == 'natal')

	{

		document.getElementById('div-calendario-campinas').style.display = 'none';

		document.getElementById('div-calendario-natal').style.display = '';

		document.getElementById('div-calendario-saopaulo').style.display = 'none';

		

		document.getElementById('div-calendario-campinas-legenda').style.display = 'none';

		document.getElementById('div-calendario-natal-legenda').style.display = '';

		document.getElementById('div-calendario-saopaulo-legenda').style.display = 'none';

	}

}



// -------- Validao -------//

function verifica_form (form)

{

	var campos = "" ;



	for (i=0;i<form.elements.length;i++)

	{



		if(form.elements[i].id.search("ob_") != -1)

		{



			//Resseta a classe do campo

			form.elements[i].className = 'input-text' ;

			

			//Valida Preenchimento

			if(form.elements[i].value.length == 0 || form.elements[i].value == "0")

			{

				campos = campos + "- " + form.elements[i].title + "\n" ;

				form.elements[i].className = 'input-text-erro' ;

			}



			//Valida Campo de E-mail

			if(form.elements[i].value.length != 0 && form.elements[i].id.search("email") != -1)

			{

				campos += valida_email( form.elements[i].value , form.elements[i].title , form.elements[i] ) ;

			}

			

			//Valida Campo de Data

			//if(form.elements[i].value.length != 0 && form.elements[i].id.search("data_") != -1)

			//{

			//	campos += jValidaData( form.elements[i].value , form.elements[i].title , form.elements[i] ) ;

			//}

			

			//Valida Campo de C.P.F

			if(form.elements[i].value.length != 0 && form.elements[i].id.search("cpf") != -1)

			{

				campos += jValidaCPF( form.elements[i].value , form.elements[i].title , form.elements[i] ) ;

			}



			//Valida Campo de C.N.P.J.

			if(form.elements[i].value.length != 0 && form.elements[i].id.search("cnpj") != -1)

			{

				campos += jValidaCNPJ( form.elements[i].value , form.elements[i].title , form.elements[i] ) ;

			}



		} // Fim Campo Obrigatrio



	} // For

	

	if (campos.length > 0)

	{

		alert("O preenchimento dos seguintes campos  obrigatrio:\n" + campos);

		return false;

	}

	else

	{

		return true;

	}

}



function valida_email ( email , titulo , objeto )

{

	var mensagem = "";



	if (email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)

	{

		objeto.className = 'input-text-erro' ;

		mensagem = "- " + titulo + " foi preenchido incorretamente\n";

	}



	return (mensagem);

}



function viewVideo(file,titulo)

{

	videoHTML = '';

	videoHTML += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Carregando..." type="application/x-oleobject" width="320" height="290">';

	videoHTML += ' <param name="AnimationAtStart" value="true">';

	videoHTML += ' <param name="AutoSize" value="false">';

	videoHTML += ' <param name="AutoStart" value="true">';

	videoHTML += ' <param name="Loop" value="true">';

	videoHTML += ' <param name="FileName" value="'+ file +'">';

	videoHTML += ' <param name="ShowControls" value="true">';

	videoHTML += ' <param name="ShowStatusBar" value="true">';

	videoHTML += ' <param name="TransparentAtStart" value="false">';

	videoHTML += ' <param name="Volume" value="-230">';

	videoHTML += ' <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+ file +'" name="MediaPlayer" width="320" height="290" ShowStatusBar="1" autostart="1" showcontrols="1" volume="-230">';

	videoHTML += '</object>'

	

	document.getElementById('divVideo').innerHTML = videoHTML;

	document.getElementById('titleVideo').innerHTML = titulo;

}



/** valida os dados no formulario de acesso ao portal do aluno **/

function studentAcessValidate()

{

	type = document.getElementById("AccessMode");

	

	if(type.value=="A")

	{

		tx_empresa = document.getElementById("form_aluno_empresa");

		tx_ra = document.getElementById("form_aluno_ra");

		tx_senha = document.getElementById("form_aluno_senha");

		

		if(tx_empresa.value!=-1)

		{

			if((tx_ra.value!="RA")&&(tx_ra.value!=""))

			{

				if((tx_senha.value!="Senha")&&(tx_senha.value!=""))

				{

					tx_ra.value = tx_ra.value.toUpperCase();

					return true;

				}

				else

				{

					alert("Informe sua senha!");

					return false;

				}

			}

			else

			{

				alert("Infome seu RA!");

				return false;

			}

		}

		else

		{

			alert("Escolha sua unidade!");

			return false;

		}

	}

	else

	{

		tx_empresa = document.getElementById("form_professor_empresa");

		tx_matricula = document.getElementById("form_professor_matricula");

		tx_senha = document.getElementById("form_professor_senha");

		

		if(tx_empresa.value!=-1)

		{

			if((tx_matricula.value!="MATRICULA")&&(tx_matricula.value!=""))

			{

				if((tx_senha.value!="Senha")&&(tx_senha.value!=""))

				{

					tx_matricula.value = tx_matricula.value.toUpperCase();

					return true;

				}

				else

				{

					alert("Informe sua senha!");

					return false;

				}

			}

			else

			{

				alert("Infome seu nmero de matrcula!");

				return false;

			}

		}

		else

		{

			alert("Escolha sua unidade!");

			return false;

		}

	}

}



/* altera o modo de acesso de aluno para professor (ou ao contrario) */

function alterAccessMode()

{

	type = document.getElementById("AccessMode");

	

	if(type.value=="A")

	{

		document.images["topo-banner-aluno-titulo"].src = "Images/top_professor_titulo.gif";

		document.images["topo-banner-aluno-subtitulo"].src = "Images/top_aluno_subtitulo.gif";

		document.getElementById("login").style.display = "none";

		document.getElementById("login_professor").style.display = "";

		document.getElementById("link-lembra-senha-aluno").style.display = "none";

		document.getElementById("link-lembra-senha-professor").style.display = "";

		type.value = "P";

	}

	else

	{

		document.images["topo-banner-aluno-titulo"].src = "Images/top_aluno_titulo.gif";

		document.images["topo-banner-aluno-subtitulo"].src = "Images/top_professor_subtitulo.gif";

		document.getElementById("login_professor").style.display = "none";

		document.getElementById("login").style.display = "";

		document.getElementById("link-lembra-senha-professor").style.display = "none";

		document.getElementById("link-lembra-senha-aluno").style.display = "";

		type.value = "A";

	}

}



	/**
	 *	Função para validação da consulta para rematricula
	 */
	function validaConsultaRematricula(idForm) {
	
		// Valida o campo CPF (Verifica se o campo  nulo, se  nmerico ou se contem mais de 11 digitos)
		if(!idForm.cpf.value) {
			alert('Atenção! Você deve inserir seu CPF para efetuar a rematricula.');
			return false;
		} else {
			if(isNaN(idForm.cpf.value)) {
				alert('Atenção! O campo CPF deve conter apenas números. Portanto, não insira pontos nem traços.');
				return false;
			} else {
				if(idForm.cpf.value.length < 11 || idForm.cpf.value.length > 11) {
					alert('Atenção! O CPF deve conter 11 dígitos.');
					return false;
				}	
			}
		}
		
		// Valida o campo RA (verifica se o campo  nulo ou se a quantidade de digitos excede o padrao)
		if(!idForm.ra.value) {
			alert('Atenção! Você deve inserir seu RA para efetuar a rematricula.');
			return false;
		} else {
			if(idForm.ra.value.length > 12) {
				alert('Atenção! O RA deve conter apenas 12 dígitos. O número inserido contém '+idForm.ra.value.length+' dígitos.');
				return false;
			}
		}
		
	}
	
	/**
	 *	Validação de confirmação de aceite - Checkbox
	 */
	function validaBotaoAceite(idCheck,idLink) {
		
		var bt = document.getElementById(idLink);
		
		if(idCheck.checked) {
			bt.style.display = 'block';
		} else {
			bt.style.display = 'none';
		}
		
	}
	
	/**
	 *	Valida formulário de alteração de cadastro do Aluno
	 *	validação feita apenas nos campos CEP e EMAIL
	 */
	function validaRematricula(idForm) {
		
		//	Valida o campo CEP
		if(idForm.cep.value) {
			//	Verifica se o valor inserido  nmerico
			if(isNaN(idForm.cep.value)) {
				alert('Atenção! O CEP deve conter apenas números. Portanto, não insira pontos nem traços.');
				idForm.cep.className = 'cl-alert-focus';
				return false;
			} else {
				idForm.cep.className = null;
			}
			//	Verifica se o valor inserido tem mais ou menos que 8 digitos
			if(idForm.cep.value.length > 8 || idForm.cep.value.length < 8) {
				alert('Atenção! O CEP é composto por apenas 8 dgitos. Por favor, verifique se a informação está correta.');
				idForm.cep.className = 'cl-alert-focus';
				return false;
			} else {
				idForm.cep.className = null;	
			}
		}
		
		//	Valida o campo email
		if(idForm.email.value) {
			//	Verifica se há '@' no valor inserido
			if(idForm.email.value.indexOf('@') == -1) {
				alert('Atenção! O e-mail é inválido.');
				idForm.email.className = 'cl-alert-focus';
				return false;
			}
		}
		
		return true;
	
	}
	
	/**
	 *	Função para redirecionamento de pagina
	 */
	function redirect(url) {
		
		if(url != '') {
			document.location.href = url;
			return true;
		}
	
	}


