function LimpaList(el,end) {

	var cnt = el.options.length
	
	for (var i = cnt-1; i>=0; i--) el.options[i] = null
	el.selectedIndex = 0

}

function popula_conclusao(codtipo,form)	{

	var option = new Array
	var listObj = form.conclusao
	var listLength = listObj.length
	var virgula = ";"
	var tipo
	var conclusao
	var cont = 0
	var arrayOfStrings

	LimpaList(listObj,listLength)
	
	for (var i = 0; i < Conclusao.length; i++)	{

		arrayOfStrings = Conclusao[i].split(virgula);

		tipo = arrayOfStrings[0]

		if (tipo == codtipo)	{

			cont = 1 + cont
			conclusao = arrayOfStrings[1]

			option[cont] = new Option(conclusao,conclusao)
			eval("listObj.options[cont] = option[cont]")

		}

	}

	listObj.options[0] = new Option(""," ")
	listObj.selectedIndex = 0
	
	//if (navigator.appName == "Netscape")	{
	//	history.go(0)
	//}

}

function popula_periodo(codtipo,form)	{

	var option = new Array
	var listObj = form.periodo
	var listLength = listObj.length
	var virgula = ";"
	var tipo
	var periodo
	var cont = 0
	var arrayOfStrings

	LimpaList(listObj,listLength)

	for (var i = 0; i < Periodo.length; i++)	{

		arrayOfStrings = Periodo[i].split(virgula);

		tipo = arrayOfStrings[0]

		if (tipo == codtipo)	{

			cont = 1 + cont
			periodo = arrayOfStrings[1]

			option[cont] = new Option(periodo,periodo)
			eval("listObj.options[cont] = option[cont]")

		}

	}

	listObj.options[0] = new Option(""," ")
	listObj.selectedIndex = 0

	//if (navigator.appName == "Netscape")	{
	//	history.go(0)
	//}

}

function popula_instituicao(codestado,form)	{

	var option = new Array
	var listObj = form.instituicao
	var listLength = listObj.length
	var virgula = ";"
	var estado
	var nome_instituicao
	var cont = 0
	var arrayOfStrings

	LimpaList(listObj,listLength)

	for (var i = 0; i < Instituicao.length; i++)	{

		arrayOfStrings = Instituicao[i].split(virgula);

		estado = arrayOfStrings[1]

		if (codestado == "GO" || codestado == "DF" || codestado == "MG" || codestado == "SP")	{

				if (estado == "GO" || estado == "DF" || estado == "MG" || estado == "SP")	{
		
					cont = 1 + cont
					nome_instituicao = arrayOfStrings[0]
		
					option[cont] = new Option(nome_instituicao,nome_instituicao)
					eval("listObj.options[cont] = option[cont]")
		
				}

		}	else	{

				if (estado == codestado)	{
		
					cont = 1 + cont
					nome_instituicao = arrayOfStrings[0]
		
					option[cont] = new Option(nome_instituicao,nome_instituicao)
					eval("listObj.options[cont] = option[cont]")
		
				}

			}

	}

	listObj.options[0] = new Option(""," ")
	listObj.selectedIndex = 0

	//if (navigator.appName == "Netscape")	{
	//	history.go(0)
	//}

}

function valida_email(email)	{			

	var ultpos = (email.length - 1)
	var z = 0

	//procurando por mais de uma @ ou por / 

	for(i=0; i < email.length;i++)	{	

		if (email.charAt(i)=="@")
			z++;
		if ( (z > 1) || (email.charAt(i) == "/") )
			return false;		

	}	

	if ((email.charAt(0) == "@") || (email.charAt(0) == ".") || (email.charAt(ultpos) == "@") || (email.charAt(ultpos) == ".") || (email.indexOf("@") == -1) || (email.indexOf(".") == -1) || (email.indexOf("@.") != -1))
		return false;

	return true

}
	
function critica_frm_estagio()	{

	if ( ! notNull(document.frm_estagio.nome.value) )	{
		alert("Informe o nome");
		document.frm_estagio.nome.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.nome.value) )	{
				alert("Informe o nome");
				document.frm_estagio.nome.focus();
				document.frm_estagio.nome.select();
				return
			}
		}

//	if ( ! notNull(document.frm_estagio.email.value) )	{
//		alert("Informe o e-mail");
//		document.frm_estagio.email.focus();
//		return
//	}	else	{
//			if ( ! notBlank(document.frm_estagio.email.value) )	{
//				alert("Informe o e-mail");
//				document.frm_estagio.email.focus();
//				document.frm_estagio.email.select();
//				return
//			}	else	{
//					if (! valida_email(document.frm_estagio.email.value))	{
//						alert("Informe um e-mail válido");
//						document.frm_estagio.email.focus();
//						document.frm_estagio.email.select();
//						return
//					}
//				}
//		}

	if ( notNull(document.frm_estagio.email.value) )	{
			if ( notBlank(document.frm_estagio.email.value) )	{
				if (! valida_email(document.frm_estagio.email.value))	{
					alert("Informe um e-mail válido");
					document.frm_estagio.email.focus();
					document.frm_estagio.email.select();
					return
				}
			}
	}

	if ( ! notNull(document.frm_estagio.ddd.value) )	{
		alert("Informe o ddd do telefone");
		document.frm_estagio.ddd.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.ddd.value) )	{
				alert("Informe o ddd do telefone");
				document.frm_estagio.ddd.focus();
				document.frm_estagio.ddd.select();
				return
			}
		}

	if ( ! notNull(document.frm_estagio.tel.value) )	{
		alert("Informe o telefone");
		document.frm_estagio.tel.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.tel.value) )	{
				alert("Informe o telefone");
				document.frm_estagio.tel.focus();
				document.frm_estagio.tel.select();
				return
			}
		}

	if ( ! notNull(document.frm_estagio.endereco.value) )	{
		alert("Informe o endereco");
		document.frm_estagio.endereco.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.endereco.value) )	{
				alert("Informe o endereco");
				document.frm_estagio.endereco.focus();
				document.frm_estagio.endereco.select();
				return
			}
		}

	if ( ! notNull(document.frm_estagio.cidade.value) )	{
		alert("Informe a cidade");
		document.frm_estagio.cidade.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.cidade.value) )	{
				alert("Informe a cidade");
				document.frm_estagio.cidade.focus();
				document.frm_estagio.cidade.select();
				return
			}
		}

	if (document.frm_estagio.estado.selectedIndex == 0)	{
		alert("Selecione o estado");
		document.frm_estagio.estado.focus();
		return
	}

	if (document.frm_estagio.estagio.selectedIndex == 0)	{
		alert("Selecione o tipo de graduação");
		document.frm_estagio.estagio.focus();
		return
	}

	//if (document.frm_estagio.instituicao.selectedIndex == 0)	{
	//	alert("Selecione a instituição conveniada");
	//	document.frm_estagio.instituicao.focus();
	//	return
	//}
	
	if ( ! notNull(document.frm_estagio.instituicao.value) )	{
		alert("Informe a instituição de ensino");
		document.frm_estagio.instituicao.focus();
		return
	}	else	{
			if ( ! notBlank(document.frm_estagio.instituicao.value) )	{
				alert("Informe a instituição de ensino");
				document.frm_estagio.instituicao.focus();
				document.frm_estagio.instituicao.select();
				return
			}
		}

	if (document.frm_estagio.curso.selectedIndex == 0)	{
		alert("Selecione o curso");
		document.frm_estagio.curso.focus();
		return
	}

	if (document.frm_estagio.periodo.selectedIndex == 0)	{
		alert("Selecione o período");
		document.frm_estagio.periodo.focus();
		return
	}

	if (document.frm_estagio.conclusao.selectedIndex == 0)	{
		alert("Selecione o ano de conclusão");
		document.frm_estagio.conclusao.focus();
		return
	}

	document.frm_estagio.submit();

}

function notNull(str) {
	if (str.length == 0)
		return false
	else 
		return true
}

function notBlank(str) {
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) != " ")
			return true
	}
	return false
}
