// JavaScript Document
<!--
function okNum(field) {
	var instr=field.value
	var ok = true;
			for(var i=0; i<instr.length; i++) {
			if( (instr.charAt(i)<'0') || (instr.charAt(i)>'9')){
				ok = false; 
				alert("Field value is wrong, please enter a valid input.");
				field.value="";
				field.focus();
				break;
			}
		}
	return ok;
}


function checkdata(gg,mm,aa) {
	var data=new Date();
	var anno = aa;
	var mese = mm;
	var giorno = gg;
	var max;
	var ok = true;
	var bisestile = false;
	gg_corrente  = data.getDate();
	mm_corrente =data.getMonth()+1;
	aa_corrente  = data.getYear();
  	if ( (anno.length>0) && (anno.length < 4) ){
		alert ( "Year should be a four digit number, please enter a valid input.");
		ok =  false;  
		return ok;
	}

	if ( (giorno>31)  || ( giorno<1 )){    
		alert ('Please enter a valid input value for day.');
		ok =  false;  
		return ok;
	}

	if ( (mese>12) || ( mese<1)){
		alert ('Please enter a valid input value for month.');
		ok =  false;;
		return ok;
	}

	if (anno%4==0){
		if (anno%100==0) {
			if(anno%400==0) {
				bisestile = true;
			}
			else bisestile = false;
		}
		else bisestile = true;
	}
	else bisestile = false;	

	switch (mese) {
		case '1':
		case '3':
		case '5':
		case '7':
		case '8':
		case '10':
		case '12':     
		case '01':
		case '03':
		case '05':
		case '07':
		case '08':
			max=31;
			break;         
		case '4':
		case '6':
		case '9':
		case '04':
		case '06':
		case '09':
		case '11':         
			max=30;
			break;           
		default:           
			max = 28;               
             
		if (bisestile=="true") {
			max = 29;
		}   
	}

	if (giorno > max) {
		alert('Date format is wrong, please enter a valid input.');
		ok =  false;
		return ok;
	}
	
	if ( anno < aa_corrente) {
		chk1=true;
	}	

	if ( anno == aa_corrente) {
		if ( mese < mm_corrente ) {
			chk2=true;
		}	 
	}

	if ( anno == aa_corrente) {
		if ( mese ==  mm_corrente ) {
			if ( giorno < gg_corrente ) {
				chk3=true;
			}
		}	 
	}

	
return ok;
}


function checkemail(field) {
var ok=true;
var email=field.value;

				var at_pos_l = email.indexOf('@');
				var at_pos_r = email.lastIndexOf('@')
				if (at_pos_l <= -1) {alert("Email address without @.");ok=false;field.focus()}
				else {
						if (at_pos_l != at_pos_r ) {
							alert("Email address with multiple @.");ok=false;field.focus();
						}
						if ((at_pos_l == 0) || (at_pos_l == email.length-1)) {
							alert("Email address with @ in a wrong position.");ok=false;field.focus();}
					}

return ok;
}

function reDate(dmy) {
	var d=dmy.split(/\D+/);
	return new Date(d[2],d[1]-1,d[0]);
}

function checkbookform(modulo) {
   var ret_val=true;
   var nome=modulo.nome.value
   var cognome=modulo.cognome.value
   var indirizzo=modulo.indirizzo.value
   var citta=modulo.citta.value
   var cap=modulo.cap.value
   var telefono=modulo.telefono.value
   var cellulare=modulo.cellulare.value
   var email=modulo.email.value
   var captchacode=modulo.captchacode.value
   var arrivo=modulo.date23.value
   var partenza=modulo.date24.value


if (ret_val) {
	if (nome.length < 1) {
		alert("Please fill out with your name.");
		ret_val=false;
		modulo.nome.focus();
	}
}


if (ret_val) {
	if (cognome.length < 1) {
		alert("Please fill out with your surname.");
		ret_val=false;
		modulo.cognome.focus();
	}
}


if (ret_val) {
	if (indirizzo.length < 1) {
		alert("Please fill out with your address.");
		ret_val=false;
		modulo.indirizzo.focus();
	}
}


if (ret_val) {
	if (citta.length < 1) {
		alert("Please fill out with your town.");
		ret_val=false;
		modulo.citta.focus();
	}
}



if (ret_val) {
	if (modulo.provincia.options[0].selected) {
		alert("Select a province.");
		ret_val = false;
		modulo.provincia.focus();
	} else {
		if ((!modulo.stato.options[82].selected && !modulo.provincia.options[1].selected) || (modulo.stato.options[82].selected && modulo.provincia.options[1].selected)) {
			alert("If you select an italian province, please select  \'Italy\' in the country field.\n\nIf you select an abroad country, please select \'Abroad\' in the province field.");
			ret_val = false;
			modulo.provincia.focus();
		}
	}
}


if (ret_val) {
	if (cap.length < 1) {
		alert("Please fill out with your ZIP Code.");
		ret_val=false;
		modulo.cap.focus();
	}
}


if (ret_val) {
	if (telefono.length < 1) {
		alert("Please fill out with your phone number.");
		ret_val=false;
		modulo.telefono.focus();
	}
}


if (ret_val) {
	if (cellulare.length < 1) {
		alert("Please fill out with your mobile number.");
		ret_val=false;
		modulo.cellulare.focus();
	}
}



if (ret_val) {
	if (email.length < 1) {
		alert("Please fill out with your email address.");
		ret_val=false;
		modulo.email.focus();
	}
	else ret_val=checkemail(document.bookform.email)
}


if (ret_val) {
	if (reDate(arrivo) > reDate(partenza)) {
		alert("Arrival date is after departure date.");
		ret_val=false;
	}
}


if (ret_val) {
	if (captchacode.length < 5) {
		alert("Please insert the security code.");
		ret_val=false;
		modulo.captchacode.focus();
	}
}


if (ret_val) {
	if (modulo.privacy[0].checked==false) {
		alert("Please check your privacy acceptance.");
		ret_val=false;
	}
}   

   return ret_val
}
//-->
