<!--
//function rollover
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//_________________________________________________________________________________________


//inizio open popup
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//_________________________________________________________________________________________

//inizio data
function isValidDate(dateStr, noMS) {

// Verifica le date nel seguente formato :
// DD/MM/YY HH:MM || DD/MM/YYYY HH:MM || DD-MM-YY HH:MM ||  DD-MM-YYYY HH:MM

if (noMS) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
	}
else	{
	var datePat = /^(\d{1,2})(\/|-|)(\d{1,2})\2(\d{4})\s(\d{1,2})(\:)(\d{1,2})$/; 
	}
	
var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
	//alert(dateStr + " Date is not in a valid format.")
	return false;
}
// parse date into variables
month = matchArray[3];
day = matchArray[1];
year = matchArray[4];

if (month < 1 || month > 12) { // check month range
	//alert("Month must be between 1 and 12.");
	return false;
}

if (day < 1 || day > 31) {
	//alert("Day must be between 1 and 31.");
	return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	//alert("Month "+month+" doesn't have 31 days!")
	return false;
}
if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day>29 || (day==29 && !isleap)) {
		//alert("February " + year + " doesn't have " + day + " days!");
		return false;
		}
	}

return true;

}

function isValidTime(timeStr) {

// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
	//alert("Time is not in a valid format.");
	return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
	//alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
	return false;
}
if (hour <= 12 && ampm == null) {
	if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
		alert("You must specify AM or PM.");
		return false;
	}
}

if  (hour > 12 && ampm != null) {
	//alert("You can't specify AM or PM for military time.");
	return false;
}
if (minute < 0 || minute > 59) {
	//alert ("Minute must be between 0 and 59.");
	return false;
}

if (second != null && (second < 0 || second > 59)) {
	//alert ("Second must be between 0 and 59.");
	return false;
}
return true;

}

//_________________________________________________________________________________________

//funzione e-mail
function checkEMail(emailStr)
{
var emailPat=/^(.+)@(.+)$/ ;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var firstChars=validChars ;
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,4})\.(\d{1,4})\.(\d{1,4})\.(\d{1,4})\]$/ ;
var atom="(" + firstChars + validChars + "*" + ")";
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");


var matchArray=emailStr.match(emailPat);
if (matchArray==null)
	return false;
	
var user=matchArray[1];
var domain=matchArray[2];

if (user.match(userPat)==null)
    return false;
	
var IPArray=domain.match(ipDomainPat);

if (IPArray!=null) 
	{
	for (var i=1;i<=4;i++) 
		{
	    if (IPArray[i]>255)
			return false;
		}
    return true;
	}

var domainArray=domain.match(domainPat);
if (domainArray==null)
    return false;
	
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) 
   return false;

if (domArr[domArr.length-1].length==4 && len<2) 
   return false;

return true;
}
//_________________________________________________________________________________________

function RichiestaInfo(){

	if (frmMail.txtAzienda.value == "")
		{
		alert("Inserire il nome dell'azienda!");
		frmMail.txtAzienda.focus();
		return (false);
		}
		
	if (frmMail.txtNome.value.length < 2)
		{
		alert("Inserire il nome!");
		frmMail.txtNome.focus();
		return (false);
		}

	if (frmMail.txtCognome.value.length < 1)
		{
		alert("Inserire il cognome!");
		frmMail.txtCognome.focus();
		return (false);
		}

	if (frmMail.txtEmail.value == "")
		{
		alert("Inserire l'indirizzo e-mail!");
		frmMail.txtEmail.focus();
		return (false);
		}

	if (! checkEMail(frmMail.txtEmail.value))
		{
		alert("Verificare l'indirizzo e-mail!");
		frmMail.txtEmail.focus();
		return (false);
		}

	if (frmMail.txtRichiesta.value == "")
		{
		alert("Inserire la richiesta di informazioni!");
		frmMail.txtRichiesta.focus();
		return (false);
		}

	return (true);
	}
//_________________________________________________________________________________________	
	
	
function check_registraz(frmReg){

	if (frmReg.txtNome.value.length < 2)
		{
		alert("Inserisci il tuo nome!");
		frmReg.txtNome.focus();
		return (false);
		}

	if (frmReg.txtCognome.value.length < 1)
		{
		alert("Inserisci il tuo cognome!");
		frmReg.txtCognome.focus();
		return (false);
		}

	if (frmReg.txtIndirizzo.value == "")
		{
		alert("Inserisci il tuo indirizzo!");
		frmReg.txtIndirizzo.focus();
		return (false);
		}
		
	if (frmReg.txtCap.value.length < 5)
		{
		alert("Inserisci il CAP correttamente!");
		frmReg.txtCap.focus();
		return (false);
		}
	
	if (frmReg.txtCitta.value == "")
		{
		alert("Inserisci la città in cui vivi!");
		frmReg.txtCitta.focus();
		return (false);
		}
	
	if (frmReg.txtProvincia.value == "")
		{
		alert("Inserisci la provincia!");
		frmReg.txtProvincia.focus();
		return (false);
		}
		
	if (frmReg.txtTelefono.value == "")
		{
		alert("Inserisci il numero di telefono!");
		frmReg.txtTelefono.focus();
		return (false);
		}

	if (frmReg.txtEmail.value == "")
		{
		alert("Inserisci l'indirizzo di e-mail!");
		frmReg.txtEmail.focus();
		return (false);
		}

	if (! checkEMail(frmReg.txtEmail.value))
		{
		alert("Verifica l'indirizzo di e-mail!");
		frmReg.txtEmail.focus();
		return (false);
		}
	
	if (frmReg.bPrivacy[0].checked == false)
		{
		alert("E\' obbligatorio accettare l\'informativa sulla privacy per potersi registrare!");
		frmReg.bPrivacy[0].focus();
		return (false);
		}		

	if (frmReg.txtUsername.value.length < 5)
		{
		alert("Inserisci la Username! (almeno 5 caratteri)");
		frmReg.txtUsername.focus();
		return (false);
		}

	if (frmReg.txtPassword.value.length < 5)
		{
		alert("Inserisci la password di accesso! (almeno 5 caratteri)");
		frmReg.txtPassword.focus();
		return (false);
		}

	if (frmReg.txtCpassword.value == "")
		{
		alert("Inserisci la password di conferma!");
		frmReg.txtCpassword.focus();
		return (false);
		}

	if (frmReg.txtPassword.value != frmReg.txtCpassword.value)
		{
		alert("La password di accesso e quella di conferma non coincidono!");
		frmReg.txtCpassword.focus();
		return (false);
		}

	return (true);
	}
	
	
//_________________________________________________________________________________________

function RichiestaInfoEs(){

	if (frmMail.txtAzienda.value == "")
		{
		alert("Insertar el nombre de la firma!");
		frmMail.txtAzienda.focus();
		return (false);
		}
		
	if (frmMail.txtNome.value.length < 2)
		{
		alert("Insertar tu nombre!");
		frmMail.txtNome.focus();
		return (false);
		}

	if (frmMail.txtCognome.value.length < 1)
		{
		alert("Insertar tu apellido!");
		frmMail.txtCognome.focus();
		return (false);
		}

	if (frmMail.txtEmail.value == "")
		{
		alert("Insertar e-mail!");
		frmMail.txtEmail.focus();
		return (false);
		}

	if (! checkEMail(frmMail.txtEmail.value))
		{
		alert("Comprobar tu e-mail!");
		frmMail.txtEmail.focus();
		return (false);
		}

	if (frmMail.txtRichiesta.value == "")
		{
		alert("Insertar solicitud de información!");
		frmMail.txtRichiesta.focus();
		return (false);
		}

	return (true);
	}
//_________________________________________________________________________________________	
//-->
