// JavaScript Document
<!-- esta linha serve de protecção para browsers que não suportem jscript
	// Declaring valid date character, minimum year and maximum year
	var dtCh= "-";
	var minYear=1930;
	var maxYear=2030;
	 
	function isInteger(s){
	 var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
	 
	function stripCharsInBag(s, bag){
	 var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}
	 
	function daysInFebruary (year){
	 // February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
	 for (var i = 1; i <= n; i++) {
	  this[i] = 31
	  if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
	  if (i==2) {this[i] = 29}
	   } 
	   return this
	}
	 
	function validardata(dtStr){
	 var daysInMonth = DaysArray(12)
	 var pos1=dtStr.indexOf(dtCh)
	 var pos2=dtStr.indexOf(dtCh,pos1+1)
	 var strDay=dtStr.substring(0,pos1)
	 var strMonth=dtStr.substring(pos1+1,pos2)
	 var strYear=dtStr.substring(pos2+1)
	 strYr=strYear
	 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	 for (var i = 1; i <= 3; i++) {
	  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	 }
	 month=parseInt(strMonth)
	 day=parseInt(strDay)
	 year=parseInt(strYr)
	 if (pos1==-1 || pos2==-1){
	  alert("A data deve ser indicada no formato 'dd-mm-aaaa'")
	  return false
	 }
	 if (strMonth.length<1 || month<1 || month>12){
	  alert("Por favor indique um mês válido")
	  return false
	 }
	 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
	  alert("Por favor indique um dia válido")
	  return false
	 }
	 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	  alert("Por favor indique um ano com 4 dígitos entre "+minYear+" e "+maxYear)
	  return false
	 }
	 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	return true
	}
//
function validardata(dtStr){
	 var daysInMonth = DaysArray(12)
	 var pos1=dtStr.indexOf(dtCh)
	 var pos2=dtStr.indexOf(dtCh,pos1+1)
	 var strDay=dtStr.substring(0,pos1)
	 var strMonth=dtStr.substring(pos1+1,pos2)
	 var strYear=dtStr.substring(pos2+1)
	 strYr=strYear
	 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	 for (var i = 1; i <= 3; i++) {
	  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	 }
	 month=parseInt(strMonth)
	 day=parseInt(strDay)
	 year=parseInt(strYr)
	 if (pos1==-1 || pos2==-1){
	  alert("A data deve ser indicada no formato 'dd-mm-aaaa'")
	  return false
	 }
	 if (strMonth.length<1 || month<1 || month>12){
	  alert("Por favor indique um mês válido")
	  return false
	 }
	 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
	  alert("Por favor indique um dia válido")
	  return false
	 }
	 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	  alert("Por favor indique um ano com 4 dígitos entre "+minYear+" e "+maxYear)
	  return false
	 }
	 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	return true
}
//
	function validarDataComboBox(dtStr){
	 var daysInMonth = DaysArray(12)
	 var pos1=dtStr.indexOf(dtCh)
	 var pos2=dtStr.indexOf(dtCh,pos1+1)
	 var strDay=dtStr.substring(0,pos1)
	 var strMonth=dtStr.substring(pos1+1,pos2)
	 var strYear=dtStr.substring(pos2+1)
	 strYr=strYear
	 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	 for (var i = 1; i <= 3; i++) {
	  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	 }
	 month=parseInt(strMonth)
	 day=parseInt(strDay)
	 year=parseInt(strYr)
	 if (pos1==-1 || pos2==-1){
	  alert("A data deve ser indicada no formato 'dd-mm-aaaa'")
	  return false
	 }
	 if (strMonth.length<1 || month<1 || month>12){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	 if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
	  alert("Por favor indique uma data válida")
	  return false
	 }
	return true
	}

//
//
function menus(id, accao, numMenus, pagina)
{
	var celula = document.getElementById(id);
	var imgAberto = document.getElementById("imgAberto" + id);
	var imgFechado = document.getElementById("imgFechado" + id);
	var divMenu = document.getElementById("menu" + id);
	//var ifrConteudo = document.getElementById("conteudo");
	switch (accao)
	{
	case "over":
		if (divMenu.style.display == "none")		// então o menu está fechado vamos fazer o efeito over
		{
			celula.className = "tdMenuOver";
		}
		else										// então é porque o menu está aberto, não faço nada
		{
		
		}
		break;
	case "click":
		//window.alert(id + accao + numMenus + pagina);
		if (divMenu.style.display == "none")		// então o menu está fechado vamos fechar todos e fazer o efeito click (abrir)
		{
			for (i = 0; i < numMenus; i++)
			{
				document.getElementById("menu" + i).style.display = 'none';
				document.getElementById("imgAberto" + i).style.display = 'none';
				document.getElementById("imgFechado" + i).style.display = '';
				document.getElementById(i).className = 'tdMenu';
			}
			
			celula.className = "tdMenuClick";
			imgFechado.style.display = "none";
			imgAberto.style.display = "";
			divMenu.style.display = "";
			conteudo.location = pagina;
		}
		else										// então é porque o menu está aberto, vamos fechar
		{
			celula.className = "tdMenuOver";
			imgFechado.style.display = "";
			imgAberto.style.display = "none";
			divMenu.style.display = "none";
			conteudo.location = "home.asp";
		}
		break;
	case "out":
		if (divMenu.style.display == "none")		// então o menu está fechado vamos fazer o efeito out
		{
			celula.className = "tdMenu";
		}
		else										// então é porque o menu está aberto, não faço nada
		{
		
		}
		break;
	}
}
//
function entrada(altura, banner)
{
	var frameConteudo = parent.document.getElementById("conteudo");
	if (frameConteudo == null) frameConteudo = document.getElementById("conteudo");
	frameConteudo.style.height = altura;
	if (banner != "") parent.ifr_banners.location = banner;
//	var frameBanner = parent.document.getElementById("ifr_banners");
//	if (frameBanner.location != banner)
//	{
//		frameBanner.location = banner;
//	}
	return true;
}
//
function bfValidarAdicao()
{
	var nome = document.getElementById("nome").value;
	var morada = document.getElementById("morada").value;
	var localidade = document.getElementById("localidade").value;
	var codPostalNum = document.getElementById("codPostalNum").value;
	var codPostalLoc = document.getElementById("codPostalLoc").value;
	var telefone = document.getElementById("telefone").value;
	var telemovel = document.getElementById("telemovel").value;
	var email = document.getElementById("email");
	var diTipo = document.getElementById("diTipo").value;
	var diNumero = document.getElementById("diNumero").value;
	var diArquivo = document.getElementById("diArquivo").value;
	var nif = document.getElementById("nif").value;
	var habLiterarias = document.getElementById("habLiterarias").value;
	var anoHabLiterarias = document.getElementById("anoHabLiterarias").value;
	var areaFormacao = document.getElementById("areaFormacao").value;
	var sexo = document.getElementsByName("sexo");
	var capSN = document.getElementsByName("capSN");
//	var cpaSN = eval(document.all("capSN"));
	var capNum = document.getElementById("capNum").value;
	var expFormativa = document.getElementById("expFormativa").value;
	var expTotalHoras = document.getElementById("expTotalHoras").value;
	var areaCandidatura =  document.getElementsByName("areaCandidatura");
	var disponibilidade = document.getElementById("disponibilidade").value;
	var areasFormacaoSeleccionadas = document.getElementById("areasFormacaoSeleccionadas");
	var dataNasc = "";
	var dataBI = "";
	var dataCAP = "";
	var diaNasc = document.frmBolsaFormadores.diaNasc.options[document.frmBolsaFormadores.diaNasc.selectedIndex].value;
	var mesNasc = document.frmBolsaFormadores.mesNasc.options[document.frmBolsaFormadores.mesNasc.selectedIndex].value;
	var anoNasc = document.frmBolsaFormadores.anoNasc.options[document.frmBolsaFormadores.anoNasc.selectedIndex].value;
	var dtNascMMDDAAAA = document.getElementById("dtNascMMDDAAAA");
	var diaBI = document.frmBolsaFormadores.diaBI.options[document.frmBolsaFormadores.diaBI.selectedIndex].value;
	var mesBI = document.frmBolsaFormadores.mesBI.options[document.frmBolsaFormadores.mesBI.selectedIndex].value;
	var anoBI = document.frmBolsaFormadores.anoBI.options[document.frmBolsaFormadores.anoBI.selectedIndex].value;
	var dtdiMMDDAAAA = document.getElementById("dtdiMMDDAAAA");

	var diaCAP = document.frmBolsaFormadores.diaCAP.options[document.frmBolsaFormadores.diaCAP.selectedIndex].value;
	var mesCAP = document.frmBolsaFormadores.mesCAP.options[document.frmBolsaFormadores.mesCAP.selectedIndex].value;
	var anoCAP = document.frmBolsaFormadores.anoCAP.options[document.frmBolsaFormadores.anoCAP.selectedIndex].value;
	var dtCAPMMDDAAAA = document.getElementById("dtCAPMMDDAAAA");

	var erros = "";
	var formulario = document.getElementById("frmBolsaFormadores");
	dataNasc = diaNasc + "-" + mesNasc + "-" + anoNasc;
	dataBI = diaBI + "-" + mesBI + "-" + anoBI;
	dataCAP = diaCAP + "-" + mesCAP + "-" + anoCAP;

	if(document.getElementById("expTotalHoras").value == "") 
	{
		document.getElementById("expTotalHoras").value = "0";
	}

	if (validarDataComboBox(dataNasc)==false) 
	{
		document.getElementById("diaNasc").focus();
		return false;
	}
	else
	{
		dtNascMMDDAAAA.value = mesNasc + "-" + diaNasc + "-" + anoNasc;
	}
//
	if (validarDataComboBox(dataBI)==false)
	{
		document.getElementById("diaBI").focus();
		return false;
	}
	else
	{
		dtdiMMDDAAAA.value = mesBI + "-" + diaBI + "-" + anoBI;
	}
//
	if (diaCAP !="00" && mesCAP !="00" && anoCAP !="00")
	{
		if (validarDataComboBox(dataCAP)==false)
		{
			document.getElementById("diaCAP").focus();
			return false;
		}
		else
		{
			dtCAPMMDDAAAA.value = mesCAP + "-" + diaCAP + "-" + anoCAP;
		}
	}
	if (diaCAP =="00" && mesCAP =="00" && anoCAP =="00")
	{
		dtCAPMMDDAAAA.value = "01-01-1901";
	}
//
//
	if (nome == "") erros += ".Preencha o seu Nome" + "\n";
	if (morada == "") erros += ".Preencha a sua Morada" + "\n";
	if (localidade == "") erros += ".Preencha a sua Localidade" + "\n";
	if (codPostalNum == "") erros += ".Preencha o seu Código Postal" + "\n";
	if (codPostalLoc == "") erros += ".Preencha a sua Localidade Postal" + "\n";
	if (telefone == "" && telemovel == "") erros += ".Preencha o seu Telefone ou Telemóvel" + "\n";
	if ((email.value == "") || (email.value == null)) erros += ".Preencha o seu E-Mail" + "\n";
	else {
		if (echeck(email.value)==false){
			erros += ".O E-Mail preenchido parece ser inválido" + "\n";
		}
	}
	
	if ((sexo[0].checked == false) && (sexo[1].checked == false)) erros += ".Indique-nos qual o seu Sexo" + "\n";
	if (diTipo == "") erros += ".Indique-nos qual é o seu Doc. de Identificacão" + "\n";
	if (diNumero == "") erros += ".Preencha seu Numero de Doc. de Identificação" + "\n";
	if (diArquivo == "") erros += ".Preencha o Arquivo do Doc. de Identificação" + "\n";
	if (nif == "") erros += ".Preencha o seu NIF (Número de Identificação Fiscal)" + "\n";
	if (habLiterarias == "") erros += ".Indique-nos as suas Habilitações Literárias" + "\n";
	if (anoHabLiterarias == "") erros += ".Preencha o Ano de Conclusão das suas Habilitações" + "\n";
	if ((capSN[0].checked == false) && (capSN[1].checked == false)) erros += ".Indique-nos se Tem ou Não o CAP" + "\n";

	areasFormacaoSeleccionadas.value = "";
	var i=0;
	var flagAreaCandidatura = 0;
	for (i=0; i<areaCandidatura.length; i++) {
		if(areaCandidatura[i].checked==true) 
		{
			flagAreaCandidatura = 1;
			areasFormacaoSeleccionadas.value += areaCandidatura[i].value + "|";
		}
	}
	if (flagAreaCandidatura == 0) erros += ".Indique-nos quais as Áreas de Formação a que se candidata" + "\n";

	if (disponibilidade == "") erros += ".Indique-nos a sua Disponibilidade" + "\n";
	if (erros=="") {
		formulario.submit();
	}
	else {
		window.alert("Por Favor Corrija os seguintes Dados: " + "\n" + "\n" + erros);
		return false;
	}
}
//
function bfValidarNif()
{
	var nif = document.getElementById("nif").value;
	var formulario = document.getElementById("frmNif");
	var erros = "";
	var naoNumerico = isNaN(nif);
 	if(naoNumerico==true)
	{
		erros += "O número que introduziu não é válido";
	}
	if(nif == "") 
	{
		erros += "Por Favor Introduza o NIF a Verificar";
	}
	if(erros != "")
	{
		window.alert("Por Favor corrija os seguintes erros: \n\n" + erros);
		document.getElementById('nif').focus();
		return false;
	}
	else 
	{
		formulario.submit();
	}
}
//
function bfValidarLogin()
{
	var nif = document.getElementById("nif").value;
	var formulario = document.getElementById("frmLoginAlteracao");
	var erros = "";
	var naoNumerico = isNaN(nif);
 	if(naoNumerico==true)
	{
		erros += "O número que introduziu não é válido";
	}
	if(nif == "") 
	{
		erros += "Por Favor Introduza o NIF a Verificar";
	}
	if(erros != "")
	{
		window.alert("Por Favor corrija os seguintes erros: \n\n" + erros);
		document.getElementById('nif').focus();
		return false;
	}
	else 
	{
		formulario.submit();
	}
}
//
function bfValidarAreas()
{
	var areasFormacaoSeleccionadas = document.getElementById("areasFormacaoSeleccionadas");
	var formulario = document.getElementById("frmAreasFormacao");
	var areaCandidatura = document.getElementsByName("areaCandidatura");
	areasFormacaoSeleccionadas.value = "";
	var erros = "";
	var i=0;
	var flagAreaCandidatura = 0;
	for (i=0; i<areaCandidatura.length; i++) {
		if(areaCandidatura[i].checked==true) 
		{
			flagAreaCandidatura = 1;
			areasFormacaoSeleccionadas.value += areaCandidatura[i].value + "|";
		}
	}
	if (flagAreaCandidatura == 0) erros += ".Indique-nos quais as Áreas de Formação a que se candidata" + "\n";
	if (erros=="") {
		formulario.submit();
	}
	else {
		window.alert("Por Favor Corrija os seguintes Dados: " + "\n" + "\n" + erros);
		return false;
	}
}
//
function bfValidarAltPessoais()
{
	var nome = document.getElementById("nome").value;
	var morada = document.getElementById("morada").value;
	var localidade = document.getElementById("localidade").value;
	var codPostalNum = document.getElementById("codPostalNum").value;
	var codPostalLoc = document.getElementById("codPostalLoc").value;
	var telefone = document.getElementById("telefone").value;
	var telemovel = document.getElementById("telemovel").value;
	var email = document.getElementById("email");
	var diTipo = document.getElementById("diTipo").value;
	var diNumero = document.getElementById("diNumero").value;
	var diArquivo = document.getElementById("diArquivo").value;
	var nif = document.getElementById("nif").value;
	var habLiterarias = document.getElementById("habLiterarias").value;
	var anoHabLiterarias = document.getElementById("anoHabLiterarias").value;
	var areaFormacao = document.getElementById("areaFormacao").value;
	var sexo = document.getElementsByName("sexo");
	var capSN = document.getElementsByName("capSN");
	var capNum = document.getElementById("capNum").value;
	var expFormativa = document.getElementById("expFormativa").value;
	var expTotalHoras = document.getElementById("expTotalHoras").value;
	var areaCandidatura = document.getElementsByName("areaCandidatura");
	var disponibilidade = document.getElementById("disponibilidade").value;
//	var areasFormacaoSeleccionadas = document.getElementById("areasFormacaoSeleccionadas");
	var dataNasc = "";
	var dataBI = "";
	var dataCAP = "";
	var diaNasc = document.frmBolsaFormadores.diaNasc.options[document.frmBolsaFormadores.diaNasc.selectedIndex].value;
	var mesNasc = document.frmBolsaFormadores.mesNasc.options[document.frmBolsaFormadores.mesNasc.selectedIndex].value;
	var anoNasc = document.frmBolsaFormadores.anoNasc.options[document.frmBolsaFormadores.anoNasc.selectedIndex].value;
	var dtNascMMDDAAAA = document.getElementById("dtNascMMDDAAAA");
	
	var diaBI = document.frmBolsaFormadores.diaBI.options[document.frmBolsaFormadores.diaBI.selectedIndex].value;
	var mesBI = document.frmBolsaFormadores.mesBI.options[document.frmBolsaFormadores.mesBI.selectedIndex].value;
	var anoBI = document.frmBolsaFormadores.anoBI.options[document.frmBolsaFormadores.anoBI.selectedIndex].value;
	var dtdiMMDDAAAA = document.getElementById("dtdiMMDDAAAA");

	var diaCAP = document.frmBolsaFormadores.diaCAP.options[document.frmBolsaFormadores.diaCAP.selectedIndex].value;
	var mesCAP = document.frmBolsaFormadores.mesCAP.options[document.frmBolsaFormadores.mesCAP.selectedIndex].value;
	var anoCAP = document.frmBolsaFormadores.anoCAP.options[document.frmBolsaFormadores.anoCAP.selectedIndex].value;
	var dtCAPMMDDAAAA = document.getElementById("dtCAPMMDDAAAA");

	var erros = "";
	var formulario = document.getElementById("frmBolsaFormadores");
	dataNasc = diaNasc + "-" + mesNasc + "-" + anoNasc;
	dataBI = diaBI + "-" + mesBI + "-" + anoBI;
	dataCAP = diaCAP + "-" + mesCAP + "-" + anoCAP;

	if(document.getElementById("expTotalHoras").value == "") 
	{
		document.getElementById("expTotalHoras").value = "0";
	}

	if (validarDataComboBox(dataNasc)==false) 
	{
		document.getElementById("diaNasc").focus();
		return false;
	}
	else
	{
		dtNascMMDDAAAA.value = mesNasc + "-" + diaNasc + "-" + anoNasc;
	}
//
	if (validarDataComboBox(dataBI)==false)
	{
		document.getElementById("diaBI").focus();
		return false;
	}
	else
	{
		dtdiMMDDAAAA.value = mesBI + "-" + diaBI + "-" + anoBI;
	}
//
	if (diaCAP !="00" && mesCAP !="00" && anoCAP !="00")
	{
		if (validarDataComboBox(dataCAP)==false)
		{
			document.getElementById("diaCAP").focus();
			return false;
		}
		else
		{
			dtCAPMMDDAAAA.value = mesCAP + "-" + diaCAP + "-" + anoCAP;
		}
	}
	if (diaCAP =="00" && mesCAP =="00" && anoCAP =="00")
	{
		dtCAPMMDDAAAA.value = "01-01-1901";
	}

//
//
	if (nome == "") erros += ".Preencha o seu Nome" + "\n";
	if (morada == "") erros += ".Preencha a sua Morada" + "\n";
	if (localidade == "") erros += ".Preencha a sua Localidade" + "\n";
	if (codPostalNum == "") erros += ".Preencha o seu Código Postal" + "\n";
	if (codPostalLoc == "") erros += ".Preencha a sua Localidade Postal" + "\n";
	if (telefone == "" && telemovel == "") erros += ".Preencha o seu Telefone ou Telemóvel" + "\n";
	if ((email.value == "") || (email.value == null)) erros += ".Preencha o seu E-Mail" + "\n";
	else {
		if (echeck(email.value)==false){
			erros += ".O E-Mail preenchido parece ser inválido" + "\n";
		}
	}
	if ((sexo[0].checked == false) && (sexo[1].checked == false)) erros += ".Indique-nos qual o seu Sexo" + "\n";
	if (diTipo == "") erros += ".Indique-nos qual é o seu Doc. de Identificacão" + "\n";
	if (diNumero == "") erros += ".Preencha seu Numero de Doc. de Identificação" + "\n";
	if (diArquivo == "") erros += ".Preencha o Arquivo do Doc. de Identificação" + "\n";
	if (nif == "") erros += ".Preencha o seu NIF (Número de Identificação Fiscal)" + "\n";
	if (habLiterarias == "") erros += ".Indique-nos as suas Habilitações Literárias" + "\n";
	if (anoHabLiterarias == "") erros += ".Preencha o Ano de Conclusão das suas Habilitações" + "\n";
	if ((capSN[0].checked == false) && (capSN[1].checked == false)) erros += ".Indique-nos se Tem ou Não o CAP" + "\n";

//	areasFormacaoSeleccionadas.value = "";
//	var i=0;
//	var flagAreaCandidatura = 0;
//	for (i=0; i<areaCandidatura.length; i++) {
//		if(areaCandidatura[i].checked==true) 
//		{
//			flagAreaCandidatura = 1;
//			areasFormacaoSeleccionadas.value += areaCandidatura[i].value + "|";
//		}
//	}
//	if (flagAreaCandidatura == 0) erros += ".Indique-nos quais as Áreas de Formação a que se candidata" + "\n";

	if (disponibilidade == "") erros += ".Indique-nos a sua Disponibilidade" + "\n";
	if (erros=="") {
		formulario.submit();
	}
	else {
		window.alert("Por Favor Corrija os seguintes Dados: " + "\n" + "\n" + erros);
		return false;
	}
}
//
function echeck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
//		   alert("E-Mail Inválido")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
//		   alert("E-Mail Inválido")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
//		    alert("E-Mail Inválido")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
//		    alert("E-Mail Inválido")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
//		    alert("E-Mail Inválido")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
//		    alert("E-Mail Inválido")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
//		    alert("E-Mail Inválido")
		    return false
		 }
 		 return true					
}
//
function controlarDivsModular(id)
{
	var divModulo = document.getElementById("div" + id);
	var imgAbrir = document.getElementById("imgAbrir" + id);
	var imgFechar = document.getElementById("imgFechar" + id);
	var numDivs = 26;
	var frameConteudo = parent.document.getElementById("conteudo");
	if (divModulo.style.display=="none")
	{
		for (i=0; i< numDivs; i++)
		{
			document.getElementById("div" + i).style.display = "none";
			document.getElementById("imgAbrir" + i).style.display = "";
			document.getElementById("imgFechar" + i).style.display = "none";
		}
		frameConteudo.style.height = '3700px';
		divModulo.style.display = "";
		imgAbrir.style.display = "none";
		imgFechar.style.display = "";
	}
	else
	{
		divModulo.style.display = "none";
		imgAbrir.style.display = "";
		imgFechar.style.display = "none";
		frameConteudo.style.height = '2200px';
	}
}
//
function controlarDivsModularAntiga(id)
{
	window.alert(id);
//	var divModulo = ['div'];
	var divModulo = document.getElementById("div");
	var imgAbrir = document.getElementsByName("imgAbrir");
	var imgFechar = document.getElementsByName("imgFechar");
	var numDivs = divModulo.length;
	window.alert(numDivs);
	var frameConteudo = parent.document.getElementById("conteudo");
	if (divModulo[id].style.display=="none")
	{
		for (i=0; i< numDivs; i++)
		{
			divModulo[i].style.display = "none";
			imgAbrir[i].style.display = "";
			imgFechar[i].style.display = "none";
		}
		frameConteudo.style.height = '3700px';
		divModulo[id].style.display = "";
		imgAbrir[id].style.display = "none";
		imgFechar[id].style.display = "";
	}
	else
	{
		divModulo[id].style.display = "none";
		imgAbrir[id].style.display = "";
		imgFechar[id].style.display = "none";
		frameConteudo.style.height = '2200px';
	}
}
//
function controlarDivsContinua(id)
{
	var divModulo = document.getElementById("div" + id);
	var imgAbrir = document.getElementById("imgAbrir" + id);
	var imgFechar = document.getElementById("imgFechar" + id);
	var numDivs = 23;
	var frameConteudo = parent.document.getElementById("conteudo");
	if (divModulo.style.display=="none")
	{
		for (i=0; i< numDivs; i++)
		{
			document.getElementById("div" + i).style.display = "none";
			document.getElementById("imgAbrir" + i).style.display = "";
			document.getElementById("imgFechar" + i).style.display = "none";
		}
		frameConteudo.style.height = '3700px';
		divModulo.style.display = "";
		imgAbrir.style.display = "none";
		imgFechar.style.display = "";
	}
	else
	{
		divModulo.style.display = "none";
		imgAbrir.style.display = "";
		imgFechar.style.display = "none";
		frameConteudo.style.height = '2200px';
	}
}
//
function mudarSeccaoNewsletter(seccao)
{
	document.getElementById("tdEditorial").className='tdNewsletterSemFoco';	
	document.getElementById("tdFormacao").className='tdNewsletterSemFoco';	
	document.getElementById("tdAconteceCICCOPN").className='tdNewsletterSemFoco';	
	document.getElementById("tdLGMC").className='tdNewsletterSemFoco';	
	document.getElementById("tdForaPortas").className='tdNewsletterSemFoco';	
	document.getElementById("tdOpiniao").className='tdNewsletterSemFoco';	
	document.getElementById("tdBreves").className='tdNewsletterSemFoco';	
//
	document.getElementById("td" + seccao).className='tdNewsletterComFoco';	
//
	document.getElementById("divEditorial").style.display='none';	
	document.getElementById("divFormacao").style.display='none';	
	document.getElementById("divAconteceCICCOPN").style.display='none';	
	document.getElementById("divLGMC").style.display='none';	
	document.getElementById("divForaPortas").style.display='none';	
	document.getElementById("divOpiniao").style.display='none';	
	document.getElementById("divBreves").style.display='none';	
//
	document.getElementById("div" + seccao).style.display='';	
}
//
function validarHabCandRVCC()
{
	var formulario = document.getElementById("frmTriagem");
	var habilitacoes = document.getElementsByName("habilitacoes");
//	var habilitacoes = eval(document.all("habilitacoes"));
	var codHabilitacoes
	var erros = "";
	var numSituacoesHabilitacoes = habilitacoes.length;
	var i = 0
	var flagHabilitacoes = 0
	while (i < numSituacoesHabilitacoes)
	{
		if (habilitacoes[i].checked == true)
		{
			flagHabilitacoes = 1;
			codHabilitacoes = habilitacoes[i].value;
		}
		i++;
	}
	if (flagHabilitacoes == 0)
	{
		erros += ". Indique-nos as suas Habilitações" + "\n";
	}
//
	if (erros=="") 
	{
		switch (codHabilitacoes)
		{
			case "01":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "02":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "03":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "04":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "05":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "06":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "07":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "08":
				location="fichaCandidaturaBas.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "09":
				location="fichaCandidaturaSec.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "10":
				location="fichaCandidaturaSec.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			case "11":
				location="fichaCandidaturaSec.asp?habilitacoes="+ codHabilitacoes +"";
				break;
			default:
				break;
		}
	}
	else {
		window.alert("Por Favor Corrija os seguintes Dados: " + "\n" + "\n" + erros);
		return false;
	}
}
//
function inqLandingRed()
{
	//var chaveConvite
	var chaveConviteIndex;
	//nifIndex = parent.document.getElementById("nifIndex").value;
	chaveConviteIndex = parent.chaveConviteIndex.value;
	//chaveConvite = document.getElementById("chaveConvite");
	//chaveConvite.value = chaveConviteIndex;
	location="inqueritoTerminado.asp?convite="+ chaveConviteIndex +""
}
//
function inqueritoTerminar()
{
	document.getElementById("frmEstadoConvite").submit();
}
//
function validarInscricaoSigo()
{
	var formulario = document.getElementById("frmFichaInscricao");

	var tipoInscricao = document.getElementsByName("tipoInscricao");
//	var tipoInscricao = eval(document.all("tipoInscricao"));

	var nome = document.getElementById("nome").value;
	var diaNasc = document.frmFichaInscricao.dia.options[document.frmFichaInscricao.dia.selectedIndex].value;
	var mesNasc = document.frmFichaInscricao.mes.options[document.frmFichaInscricao.mes.selectedIndex].value;
	var anoNasc = document.frmFichaInscricao.ano.options[document.frmFichaInscricao.ano.selectedIndex].value;
	var dataNasc = "";
	var morada = document.getElementById("morada").value;

	var sexo = document.getElementsByName("sexo");
//	var sexo = eval(document.all("sexo"));

	var codPostal = document.getElementById("codPostal").value;
	var locPostal = document.getElementById("locPostal").value;
	var nif = document.getElementById("nif").value;
	var freguesia = document.getElementById("freguesia").value;
	var concelho = document.getElementById("concelho").value;
	var distrito = document.getElementById("distrito").value;
	var telefone = document.getElementById("telefone").value;
	var telemovel = document.getElementById("telemovel").value;
	var email = document.getElementById("email").value;
	var nacionalidade = document.getElementById("nacionalidade").value;
	var naturalidade = document.getElementById("naturalidade").value;
	var tipoDocumento = document.frmFichaInscricao.tipoDocIdentificacao.options[document.frmFichaInscricao.tipoDocIdentificacao.selectedIndex].value;
	var numDocumento = document.getElementById("numDocIdentificacao").value;
	var entidadeEmissora = document.frmFichaInscricao.docEmitidoPor.options[document.frmFichaInscricao.docEmitidoPor.selectedIndex].value;
	var diaDoc = document.frmFichaInscricao.diaBI.options[document.frmFichaInscricao.diaBI.selectedIndex].value;
	var mesDoc = document.frmFichaInscricao.mesBI.options[document.frmFichaInscricao.mesBI.selectedIndex].value;
	var anoDoc = document.frmFichaInscricao.anoBI.options[document.frmFichaInscricao.anoBI.selectedIndex].value;
	var dataDoc = "";
	var habilitacoes = document.frmFichaInscricao.habilitacoes.options[document.frmFichaInscricao.habilitacoes.selectedIndex].value;
	var situacaoProfissional = document.frmFichaInscricao.situacaoProfissional.options[document.frmFichaInscricao.situacaoProfissional.selectedIndex].value;

	var exFormando = document.getElementsByName("exFormando");
//	var exFormando = eval(document.all("exFormando"));

	//var situacaoProfissional = document.getElementById("situacaoProfissional").value;
	var profissao = document.getElementById("profissao").value;
	var empresa = document.getElementById("empresa").value;
	var sectorActividade = document.frmFichaInscricao.sector.options[document.frmFichaInscricao.sector.selectedIndex].value;

	var erros = "";
	dataNasc = diaNasc + "-" + mesNasc + "-" + anoNasc
	document.getElementById("dataNascimento").value = dataNasc
	if (validardata(dataNasc)) {
		erros += "";
	}
	else {
		document.getElementById('dia').focus();
		return false;
	}
	dataDoc = diaDoc + "-" + mesDoc + "-" + anoDoc
	document.getElementById("dataEmissaoDoc").value = dataDoc
	if (validardata(dataDoc)) {
		erros += "";
	}
	else {
		document.getElementById('diaBI').focus();
		return false;
	}
//
	var q = 0
	var flagTipoInscricao = 0
	while (q < 2)
	{
		if (tipoInscricao[q].checked == true)
		{
			flagTipoInscricao = 1;
		}
		q++;
	}
	if (flagTipoInscricao == 0)
	{
		erros += ". Indique-nos o 'Tipo de Inscrição'" + "\n";
	}
//
	if (nome=="")
	{
		erros += ". Preencha o campo 'Nome'" + "\n";
	}
	if (morada=="")
	{
		erros += ". Preencha o campo 'Morada'" + "\n";
	}
	if (codPostal=="")
	{
		erros += ". Preencha o campo 'Código Postal'" + "\n";
	}
	if (locPostal=="")
	{
		erros += ". Preencha o campo 'Localidade'" + "\n";
	}
//
	var j = 0
	var flagSexo = 0
	while (j < 2)
	{
		if (sexo[j].checked == true)
		{
			flagSexo = 1;
		}
		j++;
	}
	if (flagSexo == 0)
	{
		erros += ". Indique-nos o seu 'Sexo'" + "\n";
	}
//
	if (nif=="")
	{
		erros += ". Preencha o campo 'NIF'" + "\n";
	}
	if (freguesia=="")
	{
		erros += ". Preencha o campo 'Freguesia'" + "\n";
	}
	if (concelho=="")
	{
		erros += ". Preencha o campo 'Concelho'" + "\n";
	}
	if (distrito=="")
	{
		erros += ". Preencha o campo 'Distrito'" + "\n";
	}
	if ((telemovel=="") && (telefone==""))
	{
		erros += ". Preencha o campo 'Telefone' ou o campo 'Telemóvel'" + "\n";
	}
	if (email=="")
	{
		erros += ". Preencha o campo 'Endereço Electrónico'" + "\n";
	}
	if (tipoDocumento=="")
	{
		erros += ". Indique-nos o seu 'Documento de Identificação'" + "\n";
	}
	if (nacionalidade=="")
	{
		erros += ". Indique-nos a sua 'Nacionalidade'" + "\n";
	}
	if (naturalidade=="")
	{
		erros += ". Indique-nos a sua 'Naturalidade'" + "\n";
	}
	if (numDocumento=="")
	{
		erros += ". Preencha o campo 'N.º Documento de Identificação'" + "\n";
	}
	if (entidadeEmissora=="999")
	{
		erros += ". Indique-nos a Entidade Emissora do seu Doc. de Identificação" + "\n";
	}
//
	if (habilitacoes=="")
	{
		erros += ". Indique-nos a suas 'Habilitações Literárias'" + "\n";
	}
	var i = 0
	var flagExFormando = 0
	while (i < 2)
	{
		if (exFormando[i].checked == true)
		{
			flagExFormando = 1;
		}
		i++;
	}
	if (flagExFormando == 0)
	{
		erros += ". Indique-nos se foi 'Ex-formando do CICCOPN'" + "\n";
	}
//
	if (situacaoProfissional == "")
	{
		erros += ". Preencha o campo 'Situação Profissional Actual'" + "\n";
	}
//
	if ((situacaoProfissional == "trabalhador por conta de outrem") || (situacaoProfissional == "trabalhador por conta propria"))
	{
		if (profissao == "")
		{
			erros += ". Se está empregado, indique-nos a sua 'Profissão'" + "\n";
		}
		if (empresa == "")
		{
			erros += ". Se está empregado, indique-nos a sua 'Entidade Empregadora'" + "\n";
		}
		if (sectorActividade == "")
		{
			erros += ". Se está empregado, indique-nos o seu 'Sector de Actividade'" + "\n";
		}
	}



	if (erros=="") {
		formulario.submit();
	}
	else {
		window.alert("Por Favor Corrija os seguintes Dados: " + "\n" + "\n" + erros);
		return false;
	}
}
//
//function postalNatal() 
//{
//	var divNatal = document.getElementById("divNatal");
//	var resHorizontal = screen.width;
//	var resVertical = screen.height;	
//	var posicaoX = (resHorizontal - 600) / 2;
//	var posicaoY = ((resVertical - 440) / 2)-40;
//	if (posicaoY < 0) {
//		posicaoY = 0;
//	}
//	if (posicaoX < 0) {
//		posicaoX = 0;
//	}
//	divNatal.style.left = posicaoX;
//	divNatal.style.top = posicaoY;
//}
//
function destaqueEntrada()
{
	var divBanners = document.getElementById("ifr_banners");
	divBanners.style.display = "";
}
//
