﻿function data(){
	var day="";
	var month="";
	var myweekday="";
	var year="";
	mydate = new Date();
	myday = mydate.getDay();
	mymonth = mydate.getMonth();
	myweekday= mydate.getDate();
	weekday= myweekday;
	myyear= mydate.getYear();
	year = myyear
	if(myday == 0)
	day = " Domingo, "      
	else if(myday == 1)
	day = " Segunda-feira, "
	else if(myday == 2)
	day = " Terça-feira, "   
	else if(myday == 3)
	day = " Quarta-feira, "   
	else if(myday == 4)
	day = " Quinta-feira, "
	else if(myday == 5)
	day = " Sexta-feira, "
	else if(myday == 6)
	day = " Sábado, "
	if(mymonth == 0) {
	month = "Janeiro "}
	else if(mymonth ==1)
	month = "Fevereiro "
	else if(mymonth ==2)
	month = "Março "
	else if(mymonth ==3)
	month = "Abril "
	else if(mymonth ==4)
	month = "Maio "
	else if(mymonth ==5)
	month = "Junho "
	else if(mymonth ==6)
	month = "Julho "
	else if(mymonth ==7)
	month = "Agosto "
	else if(mymonth ==8)
	month = "Setembro "
	else if(mymonth ==9)
	month = "Outubro "
	else if(mymonth ==10)
	month = "Novembro "
	else if(mymonth ==11)
	month = "Dezembro "
	
	var today = new Date ()
	var hrs = today.getHours();
	
	return document.write(day + myweekday + " de " + month + "de 2008");
}

function FrontPage_Form1_Validator(theForm)
{
	  if (theForm.Nome.value == "")
	  {
		alert("Introduza um valor para o campo 'Nome'.");
		theForm.Nome.focus();
		return (false);
	  }
	
	  if (theForm.Nome.value.length < 4)
	  {
		alert("Introduza pelo menos 4 caracteres no campo 'Nome'.");
		theForm.Nome.focus();
		return (false);
	  }
	
	  if (theForm.Freguesia.selectedIndex == 0)
	  {
		alert("A primeira opção \"Freguesia\" não é uma selecção válida. Escolha uma das outras opções.");
		theForm.Freguesia.focus();
		return (false);
	  }
	
	  if (theForm.Telefone.value == "")
	  {
		alert("Introduza um valor para o campo 'phone'.");
		theForm.Telefone.focus();
		return (false);
	  }
	
	  if (theForm.Telefone.value.length < 9)
	  {
		alert("Introduza pelo menos 9 caracteres no campo 'phone'.");
		theForm.Telefone.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-,";
	  var checkStr = theForm.Telefone.value;
	  var allValid = true;
	  var validGroups = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		if (ch == ",")
		{
		  allNum += ".";
		  decPoints++;
		}
		else
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Introduza apenas caracteres do tipo dígito no campo 'Telefone'.");
		theForm.phone.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Introduza um número válido no campo 'Telefone'.");
		theForm.phone.focus();
		return (false);
	  }
	
	  return (true);
}

function ver(num){
	var i;
	var id="conteudo_"+num;
	var obj=document.getElementById(id);
	var status=obj.style.display;
	var img = "img_"+num;
	if(status=="none"){obj.style.display="inline";document.getElementById(img).src='images/plus.png';}
	else{obj.style.display="none";document.getElementById(img).src='images/minus.png';}
	for (i=1;i<=3;i++){
		id="conteudo_"+i;
		obj=document.getElementById(id);
		status=obj.style.display;
		img = "img_"+i;
		if (i==num){
			if(status=="none"){
				obj.style.display="none";
				document.getElementById(img).src='images/plus.png';
			}
			else{
				obj.style.display="inline";
				document.getElementById(img).src='images/minus.png';
			}
		}
		else{
			obj.style.display="none";
			document.getElementById(img).src='images/plus.png';
		}	
	}
}