<!--
	//----- CONTROLLO: MAIL -------- 
	function checkEMail(objValue)
	{
		apos=objValue.indexOf("@");
		dotpos=objValue.lastIndexOf(".");
		lastpos=objValue.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
		{return false;}
		else {return true;}
	}
	//------------------------------ 

	function checkInteger(objValue)
	{
		//Returns true if value is a number or is NULL
		//otherwise returns false	

		if (objValue.length == 0)
			return true;

		//Returns true if value is an integer defined as
		//   having an optional leading + or -.
		//   otherwise containing only the characters 0-9.
		var decimal_format = ".";
		var check_char;

		//The first character can be + -  blank or a digit.
		check_char = objValue.indexOf(decimal_format)
		//Was it a decimal?
		if (check_char < 1)
		return checkNumber(objValue);
		else
		return false;
	}

	function checkRange(objValue, minValue, maxValue)
	{
		// check minimum
		if (minValue != null)
		{
			if (objValue < minValue)
			return false;
		}

		// check maximum
		if (maxValue != null)
		{
			if (objValue > maxValue)
			return false;
		}
		
		//All tests passed, so...
		return true;
	}

	function checkNumber(objValue)
	{
		//Returns true if value is a number defined as
		//   having an optional leading + or -.
		//   having at most 1 decimal point.
		//   otherwise containing only the characters 0-9.
		var start_format = " .+-0123456789";
		var number_format = " .0123456789";
		var check_char;
		var decimal = false;
		var trailing_blank = false;
		var digits = false;

		//The first character can be + - .  blank or a digit.
		check_char = start_format.indexOf(objValue.charAt(0))
		//Was it a decimal?
		if (check_char == 1)
			decimal = true;
		else if (check_char < 1)
			return false;
		//Remaining characters can be only . or a digit, but only one decimal.
		for (var i = 1; i < objValue.length; i++)
		{
			check_char = number_format.indexOf(objValue.charAt(i))
			if (check_char < 0)
				return false;
			else if (check_char == 1)
			{
				if (decimal)		// Second decimal.
					return false;
				else
					decimal = true;
			}
			else if (check_char == 0)
			{
				if (decimal || digits)	
					trailing_blank = true;
			// ignore leading blanks
			}
			else if (trailing_blank)
				return false;
			else
				digits = true;
		}	

		//All tests passed, so...
		return true
	}

	function checkDate(objValue)
	{
		//Returns true if value is a eurodate format or is NULL
		//otherwise returns false	

		if (objValue.length == 0)
			return true;

		//Returns true if value is a date in the dd/mm/yyyy format
		isplit = objValue.indexOf('/');

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.');
		}

		if (isplit == -1 || isplit == objValue.length)
			return false;

		sDay = objValue.substring(0, isplit);

		monthSplit = isplit + 1;

		isplit = objValue.indexOf('/', monthSplit);

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.', monthSplit);
		}

		if (isplit == -1 ||  (isplit + 1 )  == objValue.length)
			return false;

		sMonth = objValue.substring((sDay.length + 1), isplit);

		sYear = objValue.substring(isplit + 1);

		if (!checkInteger(sMonth)) //check month
			return false;
		else
		if (!checkRange(sMonth, 1, 12)) // check month
			return false;
		else
		if (!checkInteger(sYear)) //check year
			return false;
		else
		if (!checkRange(sYear, 1970, 2020)) //check year
			return false;
		else
		if (!checkInteger(sDay)) //check day
			return false;
		else
		if (!checkDay(sYear, sMonth, sDay)) //check day
			return false;
		else
			return true;
	}
	function checkDay(checkYear, checkMonth, checkDay)
	{

		maxDay = 31;

		if (checkMonth == 4 || checkMonth == 6 ||
				checkMonth == 9 || checkMonth == 11)
			maxDay = 30;
		else
		if (checkMonth == 2)
		{
			if (checkYear % 4 > 0)
				maxDay =28;
			else
			if (checkYear % 100 == 0 && checkYear % 400 > 0)
				maxDay = 28;
			else
				maxDay = 29;
		}

		return checkRange(checkDay, 1, maxDay); //check day
	}
	function checkMyDate1(objValue)
	{
		//Returns the right date if value is a eurodate format or is NULL
		//otherwise returns false	

		if (objValue.length == 0)
			return true;

		//Returns true if value is a date in the dd/mm/yyyy format
		isplit = objValue.indexOf('/');

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.');
		}

		if (isplit == -1 || isplit == objValue.length)
			return false;

		sDay = objValue.substring(0, isplit);

		monthSplit = isplit + 1;

		isplit = objValue.indexOf('/', monthSplit);

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.', monthSplit);
		}

		if (isplit == -1 ||  (isplit + 1 )  == objValue.length)
			return false;

		sMonth = objValue.substring((sDay.length + 1), isplit);

		sYear = objValue.substring(isplit + 1);

		if (!checkInteger(sMonth)) //check month
			return false;
		else
		if (!checkRange(sMonth, 1, 12)) // check month
			return false;
		else
		if (!checkInteger(sYear)) //check year
			return false;
		else
		if (!checkRange(sYear, 1970, 2020)) //check year
			return false;
		else
		if (!checkInteger(sDay)) //check day
			return false;
		else
		if (!checkDay(sYear, sMonth, sDay)) //check day
			return false;
		else
			return true;
	}

	function checkMyDate(objValue)
	{
		//Returns true if value is a eurodate format or is NULL
		//otherwise returns false	

		if (objValue.length == 0)
			return true;

		//Returns true if value is a date in the dd/mm/yyyy format
		isplit = objValue.indexOf('/');

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.');
		}

		if (isplit == -1 || isplit == objValue.length)
			return false;

		sDay = objValue.substring(0, isplit);

		monthSplit = isplit + 1;

		isplit = objValue.indexOf('/', monthSplit);

		if (isplit == -1)
		{
			isplit = objValue.indexOf('.', monthSplit);
		}

		if (isplit == -1 ||  (isplit + 1 )  == objValue.length)
			return false;

		sMonth = objValue.substring((sDay.length + 1), isplit);

		sYear = objValue.substring(isplit + 1);

		if (!checkInteger(sMonth)) //check month
			return false;
		else
			if (!checkRange(sMonth, 1, 12)) // check month
				return false;
			else
				if (!checkInteger(sYear)) //check year
					return false;
				else
					if (!checkRange(sYear, 1970, 2020)) //check year
						return false;
					else	
						if (!checkInteger(sDay)) //check day
							return false;
						else
							if (!checkDay(sYear, sMonth, sDay)) //check day
								return false;
							else
								return new Date(sYear,sMonth-1,sDay);
	}

	function validatereg()
	{
		if (document.frm.area.value=="")
		{
			alert("Il campo \"Area\" è obbligatorio.");
			document.frm.area.focus();
			return;
		}
		if (document.frm.nome.value=="")
		{
			alert("Il campo \"Nome\" è obbligatorio.");
			document.frm.nome.focus();
			return;
		}
		if (document.frm.cognome.value=="")
		{
			alert("Il campo \"Cognome\" è obbligatorio");
			document.frm.cognome.focus();
			return;
		}
		if (document.frm.nascita.value=="") 
		{
			alert("Il campo \"Data di Nascita\" è obbligatorio.");
			document.frm.nascita.focus();
			return;
		}
		if (checkMyDate1(document.frm.nascita.value)==false) 
		{
			alert("Inserire una data di nascita valida.");
			document.frm.nascita.focus();
			return;
		}
		if (document.frm.indirizzo.value=="")
		{
			alert("Il campo \"Indirizzo\" è obbligatorio.");
			document.frm.indirizzo.focus();
			return;
		}
		if (document.frm.cap.value=="")
		{
			alert("Il campo \"CAP\" è obbligatorio.");
			document.frm.cap.focus();
			return;
		}
		if (checkNumber(document.frm.cap.value)==false)
		{
			alert("Il campo \"CAP\" accetta solo valori numerici.");
			document.frm.cap.focus();
			return;
		}
		if (document.frm.citta.value=="")
		{
			alert("Il campo \"Città\" è obbligatorio.");
			document.frm.citta.focus();
			return;
		}
		if (document.frm.provincia[document.frm.provincia.selectedIndex].value=="")
		{
			alert("Il campo \"Provincia\" è obbligatorio.");
			document.frm.provincia.focus();
			return;
		}
		if (document.frm.nazione.value=="")
		{
			alert("Il campo \"Nazione\" è obbligatorio.");
			document.frm.nazione.focus();
			return;
		}
		if (document.frm.telefono.value=="")
		{
			alert("Il campo \"Telefono\" è obbligatorio.");
			document.frm.telefono.focus();
			return;
		}	
		if (document.frm.email.value=="")
		{
			alert("Il campo \"e-mail\" è obbligatorio");
			document.frm.email.focus();
			return;
		}
		if (checkEMail(document.frm.email.value)==false)
		{
			alert("Inserire un\'e-mail valida");
			document.frm.email.focus();
			return;
		}
		document.frm.submit();
	}
	function checkfrm()
	{
		if (document.frm.autorizza1.checked && document.frm.autorizza2.checked)
		{
			if (document.frm.cognome.value=="")
			{
				alert("Il campo \"Cognome\" è obbligatorio.");
				document.frm.cognome.focus();
				return;
			}
			if (document.frm.nome.value=="")
			{
				alert("Il campo \"Nome\" è obbligatorio.");
				document.frm.nome.focus();
				return;
			}
			if (document.frm.email.value=="")
			{
				alert("Il campo \"E-Mail\" è obbligatorio.");
				document.frm.email.focus();
				return;
			}
			if (checkEMail(document.frm.email.value)==false)
			{
				alert("Inserire una e-mail valida.");
				document.frm.email.focus();
				return;
			}
			document.frm.submit();
		}
		else
		{
			alert("Non si può inviare la richiesta di informazioni se non si dà l\'autorizzazione al trattamento dei dati personali.");
			return;
		}
	}
//-->