<!--//

	function controlla(modulo)
	{
		var strErr="";
		
		if(modulo.capienza.selectedIndex==0)
		{
			strErr+="Please enter room type.\n";
		}
		
		if(modulo.camere.selectedIndex==0)
		{
			strErr+="Please enter number of rooms.\n";
		}
		
		if(modulo.fumatori.selectedIndex==0)
		{
			strErr+="Please enter smoking/non smoking room.\n";
		}
		
		if(modulo.dal_giorno.selectedIndex==0)
		{
			strErr+="The day of arrival field is obligatory.\n";
		}

		if(modulo.dal_mese.selectedIndex==0)
		{
			strErr+="The month of arrival field is obligatory.\n";
		}

		if(modulo.dal_anno.selectedIndex==0)
		{
			strErr+="The year of arrival field is obligatory.\n";
		}

		if(modulo.al_giorno.selectedIndex==0)
		{
			strErr+="The day of departure field is obligatory.\n";
		}

		if(modulo.al_mese.selectedIndex==0)
		{
			strErr+="The month of departure field is obligatory.\n";
		}

		if(modulo.al_anno.selectedIndex==0)
		{
			strErr+="The year of departure field is obligatory.\n";
		}

		if(modulo.dal_giorno.value<10)
		{
			dal_giorno="0"+modulo.dal_giorno.value;
		}
		else
		{
			dal_giorno=modulo.dal_giorno.value;
		}
		
		if(modulo.dal_mese.value<10)
		{
			dal_mese="0"+modulo.dal_mese.value;
		}
		else
		{
			dal_mese=modulo.dal_mese.value;
		}
		
		if(modulo.al_giorno.value<10)
		{
			al_giorno="0"+modulo.al_giorno.value;
		}
		else
		{
			al_giorno=modulo.al_giorno.value;
		}
		
		if(modulo.al_mese.value<10)
		{
			al_mese="0"+modulo.al_mese.value;
		}
		else
		{
			al_mese=modulo.al_mese.value;
		}
		
		dal_anno=modulo.dal_anno.value;
		al_anno=modulo.al_anno.value;
		
		data_dal="";
		data_al="";
		
		if(dal_giorno!="" && dal_mese!="" && dal_anno!="")
		{
			data_dal=dal_anno+"-"+dal_mese+"-"+dal_giorno;
		}
		
		if(al_giorno!="" && al_mese!="" && al_anno!="")
		{
			data_al=al_anno+"-"+al_mese+"-"+al_giorno;
		}
		
		if(data_dal!="" && data_al!="" && data_dal>=data_al)
		{
			strErr+="The date of arrival has to be back to the departure date.\n";
		}

		var strmade = "23:59:59 " + modulo.dal_mese.value
			+ "/" + modulo.dal_giorno.value + "/" + modulo.dal_anno.value;
		var dataoggi = new Date();
		var datamade = new Date(strmade);
		if(dataoggi >= datamade)
			strErr+="The period you have requested is finished!\n";
		if(strErr!="")
		{
			alert("Attention!\n\n" + strErr + "\nCheck the form!");
			return false;
		}
		else 
		{
			return true;
		}
	}


	function controlla_guest(obj)
	{
		var strErr="";
		
		if(obj.CMPnome.value=='')
		{
			strErr+="Please enter NAME\n\n";
		}
		
		if(obj.CMPcognome.value=='')
		{
			strErr+="Please enter FAMILY NAME\n\n";
		}		
		
		if(obj.CMPmessaggio.value=='')
		{
			strErr+="Please enter MESSAGE\n\n";
		}
		if(strErr!="")
		{
			alert("ATTENTION!\n\n" + strErr + "\nCheck form please!");
			return false;
		}
		else 
		{
			return true;
		}
	}



	function StartDateCheck() {
		var today = new Date();
		var day = today.getDate();
		var month = today.getMonth() + 1 ;
		var year = today.getFullYear();
		
		myf = document.prezzi; //prezzi è il nome del form in questione
	
		mysd = myf.dal_giorno.selectedIndex; // my start Day --> DALGIORNO
		if (mysd == 0) return true;
		
		mysm = myf.dal_mese.selectedIndex;  // my start Month --> DALMESE
		if (mysm == 0) return true;
		
		mysy = myf.dal_anno.value; // my start Month --> DALANNO
		if (mysy == 0) return true;
		
		tmp_m = myf.dal_mese.selectedIndex; // si immagazzina la variabile mese in una var temp --- my start Month --> DALMESE
		if (tmp_m == 0) return true;
		
		tmp_y = myf.dal_anno.selectedIndex; // si immagazzina la variabile anno in una var temp --- my start Year --> DALANNO
		if (tmp_y == 0) return true;

		if (mysm > 12) { mysy = mysy + 1; mysm = mysm - 12; }
	
		if (mysd == 31) {
			if ((mysm == 4) || (mysm == 6) || (mysm == 9) || (mysm == 11)) mysd = 30;
		}
		if ((mysd > 29) && (mysm == 2)) mysd = 29;
//		if (((mysy) %4 != 0) && (mysm == 2) && (mysd > 28)) mysd = 28;
		
		myf.dal_giorno.selectedIndex = mysd;
		
		myed = mysd + 1;
		myem = mysm;
		myey = mysy;
		if (myed > 31) myed = -1;
		if (myed == 31) {
			if ((myem == 4) || (myem == 6) || (myem == 9) || (myem == 11)) myed = -1;
		}
		if ((myed > 29) && (myem == 2)) myed = -1;
//		if (((myey-2) %4 != 0) && (myem == 2) && (myed > 28)) myed = -1;
		if (myed == -1) { myed = 1;	if (tmp_m == 12) {tmp_m = 1; tmp_y = tmp_y + 1 } else {tmp_m = tmp_m + 1}}
	
		myf.al_giorno.selectedIndex = myed;
		myf.al_mese.selectedIndex = tmp_m;
		myf.al_anno.selectedIndex = tmp_y;
	}
	
	function EndDateCheck() {
		var today = new Date();
		var day = today.getDate();
		var month = today.getMonth() + 1 ;
		var year = today.getFullYear();
		
		myf = document.prezzi; //prezzi è il nome del form in questione
	
		myed = myf.al_giorno.selectedIndex; // my start Day --> ALGIORNO
		if (myed == 0) return true;
		
		myem = myf.al_mese.selectedIndex;  // my start Month --> ALMESE
		if (myem == 0) return true;
		
		myey = myf.al_anno.value; // my start Month --> ALANNO
		if (myey == 0) return true;

		if (myem > 12) { myey = myey + 1; myem = myem - 12; }
	
		if (myed == 31) {
			if ((myem == 4) || (myem == 6) || (myem == 9) || (myem == 11)) myed = 30;
		}
		if ((myed > 29) && (myem == 2)) myed = 29;
//		if (((myey) %4 != 0) && (myem == 2) && (myed > 28)) myed = 28;
		
		myf.al_giorno.selectedIndex = myed;
	}
	
	function controllaform(obj, blReturnValue) {
		var ERRORE = ""
		
		for (key=0;key<obj.length;key++) {
			if (obj[key].name.toUpperCase().indexOf("CMP") >= 0 && !Disabled(obj[key])) ERRORE += isCompulsory(obj[key]);//campo obbligatorio
			if (obj[key].name.toUpperCase().indexOf("EML") >= 0 && obj[key].value != "") ERRORE += isEmail(obj[key]);//campo email
			if (obj[key].name.toUpperCase().indexOf("DTE") >= 0 && obj[key].value != "") ERRORE += isData(obj[key]);//campo data
			if (obj[key].name.toUpperCase().indexOf("NMB") >= 0 && obj[key].value != "") ERRORE += isNumber(obj[key]);//campo numerico intero positivo
			if (obj[key].name.toUpperCase().indexOf("CCP") >= 0 && obj[key].value != "") ERRORE += isCap(obj[key]);//campo CAP
			if (obj[key].name.toUpperCase().indexOf("TCL") >= 0 && obj[key].value != "") ERRORE += isCell(obj[key]);//campo cellulare
			if (obj[key].name.toUpperCase().indexOf("LNG") >= 0 && obj[key].value != "") ERRORE += isSignedDouble(obj[key]);//campo numerico decimale positivo/negativo
			if (obj[key].name.toUpperCase().indexOf("UID") >= 0 && obj[key].value != "") ERRORE += isUserID(obj[key]);//campo userID
			if (obj[key].name.toUpperCase().indexOf("PWD") >= 0 && obj[key].value != "") ERRORE += isPassword(obj[key]);//campo password
		}
		
		if (blReturnValue == false){
			if (ERRORE == "") return true;
		
			alert("ATTENTION!\n" + ERRORE + "\n\nCheck Form.");
			return false;
		}
		else{
			return ERRORE;
		}
		
	}
	
	function Disabled(obj){
		var z = obj.disabled;
		
		if(z==true || z==false){
			return obj.disabled;
		}
		else{//Netscape 4 non ha la proprietà disabled
			obj.disabled = false;
			return obj.disabled;
		}
	}
	
	function trimstr(str){
		while (str != (tmpstr=str.replace(/ +/,""))){
			str = tmpstr;
		}
		return str;
	}
	
	function FieldName(obj){
		var x = obj.name;
		if (x == "CMPnome"){x = x.replace("CMPnome", "name")};
		if (x == "CMPcognome"){x = x.replace("CMPcognome", "family name")};			
		x = x.replace("CMP", "");
		x = x.replace("NMB", "");
		x = x.replace("DTE", "");
		x = x.replace("CRC", "");
		x = x.replace("HDN", "");
		x = x.replace("EML", "");
		x = x.replace("CCP", "");
		x = x.replace("LNG", "");
		x = x.replace("UID", "");
		x = x.replace("PWD", "");
		x = x.charAt(0).toUpperCase() + x.substring(1, x.length);
		return x;
	}
		
	function isCompulsory(obj){
		if ((obj.type=="text"||obj.type=="textarea"||obj.type=="password") && obj.value=='') return "\n- Please enter '"+FieldName(obj)+"'.\n";
		if (obj.type.toLowerCase().indexOf("select")>=0 && obj.selectedIndex==0) return "\n- Please specify the type of '"+FieldName(obj)+"'.\n";
		return "";
	}
	
	function isData(obj){
		var val = trimstr(obj.value);
		var e = 0;
		obj.value=val;
		var re = new RegExp("^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$");
		var x = re.exec(val);
		
		if(x!=null){
			var dd = parseInt(RegExp.$1.replace("0", ""));
			var mm = parseInt(RegExp.$2);
			var yy = parseInt(RegExp.$3);
			var bis = 0;
			var maxg = 31;
			
			if((yy < 1753) || (yy > 10000))
				return "\n- L\'anno nel campo " + FieldName(obj) + " deve essere compreso tra 1753 e 9999.\n";
			
			if((mm < 0) || (mm > 12))
				return "\n- Il mese nel campo " + FieldName(obj) + " non è valido.\n";
			
			if(yy % 4 == 0)
				bis++;
			
			switch(mm){
				case 2 :
					maxg = 28 + bis;
					break;
				case 4 :
				case 6 :
				case 9 :
				case 11 :
					maxg--;
					break;
				default:
					break;
			}
			if((dd < 1) || (dd > maxg))
				return "\n- il giorno nel campo " + FieldName(obj) + " non è valido.\n";
			
			return "";
		}
		return "\n- La data nel campo " + FieldName(obj) + " non è valido.\n";
	}
	
	function isNumber(obj){
		var val = trimstr(obj.value);
		obj.value=val;
		if (val=="") return "";
		if (val.match(/^[0-9]*$/)==null && val!="") return "\n- The number in the "+FieldName(obj)+" is wrong.\n";
		return "";
	}

	function isSignedDouble(obj){
		var val = trimstr(obj.value);
		obj.value=val;
		if (val=="") return "";
		if (val.match(/^[-]{0,1}[0-9]*[,]{0,1}[0-9]*$/)==null && val!="") return "\n- Il Numero nel campo "+FieldName(obj)+" non è corretto.\n";
		return "";
	}
	
	function isEmail(obj) {
		var email = obj.value;	
		if ((tmpint = email.indexOf ('@',0)) == -1)
			return "\n- The at (@) is not in the field '" + FieldName(obj) + "'.\n";
		if (tmpint==0)
			return "\n- The mail address in the " + FieldName(obj) + "' can't start with the symbol '@'.\n";
		if ((tmpint2 = email.indexOf ('.',tmpint)) == -1) 
			return "\n- In the '" + FieldName(obj) + "' it is necessy insert a dot after the '@'.\n";
		if (tmpint2-tmpint==1)
			return "\n- The symbol '@.' in the field '" + FieldName(obj) + " 'is wrong.\n";
		if (tmpint2 == email.length-1)
			return "\n- The mail address in the field '" + FieldName(obj) + " 'can't finish with the symbol '.'\n";		
		return "";
	}
	
	function isCap(obj){
		var cap = trimstr(obj.value);
		obj.value = cap;
		if(cap.match(/^[0-9]{5}$/) == null) return "\n- Inserire un codice valido nel campo '" + FieldName(obj) + "'.\n"
		return "";
	}
	
	function isCell(obj){
		var val = trimstr(obj.value);
		obj.value=val;
		if (val=="") return "";
		if (val.match(/^[1-9]{1}[0-9]*$/)==null && val!="") return "\n- Il Numero nel campo '" + FieldName(obj) + "' non è corretto.\n";
		return "";
	}
	
	function isUserID(obj) {
		var strUID = obj.value;	
		if (strUID.indexOf(" ") >= 0)
			return "\n- Il campo '" + FieldName(obj) + "' non può contenere spazi.\n";
		return "";
	}
	
	function isPassword(obj) {
		var strPW = obj.value;	
		if (strPW.indexOf(" ") >= 0)
			return "\n- Il campo '" + FieldName(obj) + "' non può contenere spazi.\n";
		return "";
	}
	
//-->