function checkValues(){
	var espressione = /^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$/;
	stringa = document.getElementById("checkin").value;
	if (espressione.test(stringa)){// "stringa" rispetta le specifiche
		stringa1 = document.getElementById("checkout").value;
		if (espressione.test(stringa1)){// "stringa1" rispetta le specifiche
			if (document.getElementById("checkin").value >= document.getElementById("checkout").value){
				alert ("Error, check-in date cannot be greater than check-out date.");
				document.getElementById("checkin").focus();
				return false;
			}else { // stringa e stringa1 OK,  stringa < stringa1
					cin = document.getElementById("checkin").value;
					cout = document.getElementById("checkout").value;
					var now = new Date();
					var toDate = new Date();
					ccin = cin.split("-");
					toDate.setFullYear(ccin[0],ccin[1]-1,ccin[2]);
					
					if (now>toDate) { 
						alert ("Error. You cannot book in the past.")
						document.getElementById("checkin").focus();
						return false;
					}else{
					
						var oneMonthDate = new Date();
						ccout = cout.split("-");
						oneMonthDate.setFullYear(ccout[0],ccout[1]-1,ccout[2]);
						
						var oneMonthlater = new Date();
						oneMonthlater.setFullYear(ccin[0],ccin[1]-1,ccin[2]);
						oneMonthlater.setMonth(oneMonthlater.getMonth() + 1);
						
						if ( oneMonthlater < oneMonthDate ) {
							alert ("Error. You cannot book more than 30 days.")
							return false;
						} else {
							room_num = document.getElementById("room_num").value;
							if (room_num==""){
									alert ("Error. You must enter a valid number of rooms (from 1 to 5).")
									document.getElementById("room_num").focus();
									return false;
								}else if ((room_num<0)||(room_num>5)) {
									alert ("Error. You must enter a valid number of rooms (from 1 to 5).")
									document.getElementById("room_num").focus();
									return false;
								}else{
								
									window.document.forms['hotelP'].action = "/prenotazioneLive/hotels.asp"
									window.document.forms['hotelP'].submit();
									return true;
								}
						}
					}
			}
		} else {// "stringa" NON rispetta le specifiche
			alert("Please check if the check-out date is correct.\bIt must match the \"yyyy-mm-dd\" format.");
			document.getElementById("checkout").focus();
			return false;
		}
	} else {// "stringa" NON rispetta le specifiche
		alert("Please check if the check-in date is correct.\bIt must match the \"yyyy-mm-dd\" format.");
		document.getElementById("checkin").focus();
		return false;
	}
}
function chkToValue(){
	if(document.getElementById("checkin").value >= document.getElementById("checkout").value) {
		var tosDate = new Date();
		var toxDate = new Date();
		ci = document.getElementById("checkin").value;
		cci = ci.split("-");
		tosDate.setFullYear(cci[0],cci[1]-1,cci[2]);
		co = toxDate.setDate(tosDate.getDate() + 1);
		cco = co.split("-");
		document.getElementById("checkout").value = cco[0] +"-"+ cco[1]-1 +"-"+ cco[2];
		document.getElementById("checkout").focus();
		alert ("Error, check-in date cannot be greater than check-out date.");
		}
}
