function Senda() {
 var nome = document.formz.nome.value;
 var mail = document.formz.mail.value;
 var mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
 var oggetto = document.formz.oggetto.value;
 var testo = document.formz.testo.value; 
   	if ((nome == "") || (nome == "undefined")) {
		alert("You have to fill out the Name / Surname field.");
		document.formz.nome.focus();
	}
	else if ((mail == "") || (mail == "undefined")) {
		alert("You have to fill out the E-mail field.");
		document.formz.mail.focus();
	}
	else if (!mail_reg_exp.test(mail)) {
		alert("Please use a correct e-mail address.");
		document.formz.mail.focus();
	}
   	else if ((oggetto == "") || (oggetto == "undefined")) {
		alert("You have to fill out the Message subject field.");
		document.formz.oggetto.focus();
	}
   	else if ((testo == "") || (testo == "undefined")) {
		alert("You have to fill out the Message text field.");
		document.formz.testo.focus();
	}
	else {
	   document.formz.action = "contatti.php?id=sent";
	   document.formz.submit();
	}
}

function Sendpax() {
 document.formpax.action = "certificazioni.php?id=sent";
 document.formpax.submit();
}

function IsRightDate(dateStr)
{
	var datePat = /^((3[01]|[12]\d|0?[1-9])\/(0?[13578]|10|12)\/(\d\d)?\d\d|(30|[12]\d|0?[1-9])\/(0?[469]|11)\/(\d\d)?\d\d|(2[0-8]|[01]\d|0?[1-9])\/(0?2)\/(\d\d)?\d\d|29\/(0?2)\/(1200|1600|2000|2400|2800|00)|29\/(0?2)\/(\d\d)?(0[48]|[2468][048]|[13579][26]))$/;
    	var matchArray = dateStr.match(datePat); 
	return !(matchArray == null)
	
}

function Mandan() {
 var datanews = document.formad.datanews.value;
 var titolo = document.formad.titolo.value;
 var testo = document.formad.testo.value;
   	if ((datanews == "") || (datanews == "undefined") || (datanews == "data (formato: GG/MM/AA)")) {
		alert("Il campo Data è obbligatorio.");
		document.formad.datanews.focus();
	}	
	else if (!(IsRightDate(datanews))) {
		alert("Il campo Data deve rispettare il formato GG/MM/AA.");
		document.formad.datanews.focus();
   	}
   	else if ((titolo == "") || (titolo == "undefined")) {
		alert("Il campo Titolo è obbligatorio.");
		document.formad.titolo.focus();
	}
   	else if ((testo == "") || (testo == "undefined")) {
		alert("Il campo Testo è obbligatorio.");
		document.formad.testo.focus();
	}
	else {
	   document.formad.action = "admin.php?id=newsok";
	   document.formad.submit();
	}
}

function Mandaf() {
	document.formad.action = "admin.php?id=progok";
	document.formad.submit();
}

function Mandarn() {
	document.formad.action = "admin.php?id=newsrim";
	document.formad.submit();
}
