/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
function muda_status(mensagem){
	window.status = mensagem;
	return true;
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	if ( selObj.options[selObj.selectedIndex].value != "" ) {
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		selObj.selectedIndex=0;
	}
}

function janela_materia(codigo){
	nome = "Materia"
	largura = 500;
	altura = 300;
//	X = (screen.availWidth - largura) / 2;
	X = "0";
//	Y = (screen.availHeight - altura) / 2;
	Y = "0";
		window.open("../cursos/materia.php?codigo="+codigo,nome,'width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y );

}
function janela_professor(codigo){
	nome = "Materia"
	largura = 500;
	altura = 300;
//	X = (screen.availWidth - largura) / 2;
	X = "0";
//	Y = (screen.availHeight - altura) / 2;
	Y = "0";
		window.open("../cursos/professores.php?codigo="+codigo,nome,'width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y );

}

function janela(codigo, largura, altura)
{
	nome = "PUC_Minas"
	largura = parseInt(largura);
	altura = parseInt(altura);
	if (!(largura > 0))
	  largura = 420;
	if (!(altura > 0))
	  altura = 660;
//	X = (screen.availWidth - largura) / 2;
	X = "0";
//	Y = (screen.availHeight - altura) / 2;
	Y = "0";
		window.open("../popup/mostra_popup.php?codigo="+codigo,nome,'width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y + 'scroll=YES, scrollbars=YES, resizable=YES');

}

function imagem_puctv(codigo){
	nome = "PuvTv"
	largura = 100;
	altura = 100;
//	X = (screen.availWidth - largura) / 2;
	X = "0";
//	Y = (screen.availHeight - altura) / 2;
	Y = "0";
		window.open("img.php?img="+codigo,nome,'width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y );

}

function verifica_estagio(form){
	if (form.nome.value==""){
		alert("Por favor, digite seu nome.");
		form.nome.focus();
		return false;
	}
	if (form.email.value==""){
		alert("Por favor, digite seu email.");
		form.email.focus();
		return false;
	}
	if (!valida_mail(form.email.value)){
		alert("Por favor, digite um email valido.");
		form.email.select();
		return false;
	}
	if (form.curso.value==""){
		alert("Por favor, escolha Curso/Habilitação.");
		form.curso.focus();
		return false;
	}

		if (form.unidade.value==""){
		alert("Por favor, escolha Unidade.");
		form.unidade.focus();
		return false;
	}
		if (form.turno.value==""){
		alert("Por favor, escolha seu Turno.");
		form.turno.focus();
		return false;
	}

		if (form.periodo.value==""){
		alert("Por favor, escolha seu Período.");
		form.periodo.focus();
		return false;
	}
	
	return true;
}



function valida_mail(valor) {
	prim = valor.indexOf("@")
	if(prim < 2) return false;
	if(valor.indexOf("@",prim + 1) != -1) return false;
	if(valor.indexOf(".") < 1) return false;
	if(valor.indexOf("zipmeil.com") > 0) return false;
	if(valor.indexOf("hotmeil.com") > 0) return false;
	if(valor.indexOf(".@") > 0) return false;
	if(valor.indexOf("@.") > 0) return false;
	if(valor.indexOf(".com.br.") > 0) return false;
	if(valor.indexOf("/") > 0) return false;
	if(valor.indexOf("[") > 0) return false;
	if(valor.indexOf("]") > 0) return false;
	if(valor.indexOf("(") > 0) return false;
	if(valor.indexOf(")") > 0) return false;
	if(valor.indexOf("..") > 0) return false;
	if(valor.indexOf(",") > 0) return false;
	return true;
		
}
