var maxpeople = 0;var firstday = "";var lastday =  "";//document.step1.hotelselect.selectedIndex=0;function buildselect(theSelect, theMax){	var tSelected=theSelect.selectedIndex;	theSelect.options.length=0;	theSelect.options[0]=new Option("---");	theSelect.options[0].value=0;	for (i=1;i<=theMax;i++)		theSelect.options[theSelect.options.length]=new Option(i);	}	function displayinfo(theHotel){	var tName="info_" + theHotel;	document.getElementById('hotelinfo').innerHTML=document.getElementById(tName).innerHTML	}	function enable(theMaxPlaces, theFirstDay,theLastDay, theHotel){	document.getElementById("fields").style.display='block';	document.getElementById("submit").disabled=false;	maxpeople=theMaxPlaces;	firstday=theFirstDay;	lastday=theLastDay;	buildselect(document.step1.numbambini, theMaxPlaces);	buildselect(document.step1.numadulti, theMaxPlaces);	document.step1.hotel.value=theHotel;		calArrivo = new CalendarPopup();	calArrivo.setReturnFunction("setArrivoPopup");	//calArrivo.addDisabledDates(null, "2006-04-20");	calArrivo.firstday=firstday	calArrivo.lastday=lastday	calArrivo.addDisabledDates(null, firstday);	calArrivo.addDisabledDates(lastday, null);		calPartenza = new CalendarPopup();	calPartenza.firstday=firstday	calPartenza.lastday=lastday	calPartenza.setReturnFunction("setPartenzaPopup");	calPartenza.addDisabledDates(null, firstday);	calPartenza.addDisabledDates(lastday, null);	}	function disable(){	document.getElementById("fields").style.display='none';	document.getElementById("submit").disabled=true;	document.step1.hotelselect.selectedIndex=0;	}		var calArrivo = new CalendarPopup();//alert(calArrivo);calArrivo.setReturnFunction("setArrivoPopup");function setArrivoPopup(y,m,d) {	//alert(y + "/" + m + "/" + d)	document.step1.arrive_y.value=y;	document.step1.arrive_m.selectedIndex=m;	for (var i=0; i<document.step1.arrive_d.options.length; i++) {		if (document.step1.arrive_d.options[i].value==d) {			document.step1.arrive_d.selectedIndex=i;		}	}}var calPartenza = new CalendarPopup();calPartenza.setReturnFunction("setPartenzaPopup");function setPartenzaPopup(y,m,d) {	document.step1.departure_y.value=y;	document.step1.departure_m.selectedIndex=m;	for (var i=0; i<document.step1.departure_d.options.length; i++) {		if (document.step1.departure_d.options[i].value==d) {			document.step1.departure_d.selectedIndex=i;		}	}}function getDateString(y_obj,m_obj,d_obj) {	var y = y_obj.options[y_obj.selectedIndex].value;	var m = m_obj.options[m_obj.selectedIndex].value;	var d = d_obj.options[d_obj.selectedIndex].value;	if (y=="" || m=="") { return null; }	if (d=="") { d=1; }	return str= y+'-'+m+'-'+d;}function addZero(arg) {	if(arg < 10) return '0' + arg;		else return arg;	}	function checkForm(form){ 	var tErrors="";	//var adulti = parseInt(form.numadulti.options[form.numadulti.selectedIndex].value);	//var bambini_312 = parseInt(form.numbambini.options[form.numbambini.selectedIndex].value);	var adulti = form.numadulti.selectedIndex;	var bambini_312 = form.numbambini.selectedIndex;	var arrive = new Date();	var departure = new Date();			if (form.arrive_d.selectedIndex == 0){		tErrors+=s_indgcheckin + "\n\n";		}	if (form.arrive_m.selectedIndex == 0){		tErrors+=s_indmcheckin + "\n\n";		}	if (form.arrive_y.selectedIndex == 0){		tErrors+=s_indacheckin + "\n\n";		}	if (form.departure_d.selectedIndex == 0){		tErrors+=s_indgcheckout + "\n\n";		}	if (form.departure_m.selectedIndex == 0){		tErrors+=s_indmcheckout + "\n\n";		}	if (form.departure_y.selectedIndex == 0){		tErrors+=s_indacheckout + "\n\n";		}			arrive.setFullYear(form.arrive_y.options[form.arrive_y.selectedIndex].value, form.arrive_m.selectedIndex - 1, form.arrive_d.selectedIndex);	departure.setFullYear(form.departure_y.options[form.departure_y.selectedIndex].value, form.departure_m.selectedIndex - 1, form.departure_d.selectedIndex);		switch(form.arrive_m.selectedIndex) {		case 4:			if(form.arrive_d.selectedIndex > 30)				tErrors+=s_inddcheckinv + "\n\n";			break;		case 6:			if(form.arrive_d.selectedIndex > 30)				tErrors+=s_inddcheckinv + "\n\n";			break;		case 9:			if(form.arrive_d.selectedIndex > 30)				tErrors+=s_inddcheckinv + "\n\n";			break;		case 11:			if(form.arrive_d.selectedIndex > 30)				tErrors+=s_inddcheckinv + "\n\n";			break;		case 2:			if(form.arrive_d.selectedIndex > 29)				tErrors+=s_inddcheckinv + "\n\n";			else if((form.arrive_d.selectedIndex > 28) && ((parseInt(form.arrive_y.options[form.arrive_y.selectedIndex].value) % 4) != 0)){				tErrors+=s_inddcheckinv + "\n\n";				}			break;		}					switch(form.departure_m.selectedIndex) {		case 4:			if(form.departure_d.selectedIndex > 30)				tErrors+=s_inddcheckoutv;			break;		case 6:			if(form.departure_d.selectedIndex > 30)				tErrors+=s_inddcheckoutv;			break;		case 9:			if(form.departure_d.selectedIndex > 30)				tErrors+=s_inddcheckoutv;			break;		case 11:			if(form.departure_d.selectedIndex > 30)				tErrors+=s_inddcheckoutv;			break;		case 2:			if(form.departure_d.selectedIndex > 29)				tErrors+=s_inddcheckoutv;			else if((form.departure_d.selectedIndex > 28) && ((parseInt(form.departure_y.options[form.departure_y.selectedIndex].value) % 4) != 0))				tErrors+=s_inddcheckoutv;			break;		}					var firstdayI = parseInt(firstday.replace(/-/g, ''));	var lastdayI = parseInt(lastday.replace(/-/g, ''));	var arriveI = parseInt(form.departure_y.options[form.arrive_y.selectedIndex].value + addZero(form.arrive_m.selectedIndex) + addZero(form.arrive_d.selectedIndex));	var departureI = parseInt(form.departure_y.options[form.departure_y.selectedIndex].value + addZero(form.departure_m.selectedIndex) + addZero(form.departure_d.selectedIndex));		if((arriveI < firstdayI) || (arriveI > lastdayI)) tErrors+= s_datacheckinc + invertiData(firstday) + s_datacheckinc2 + invertiData(lastday) + ".\n\n";	if((departureI < firstdayI) || (departureI > lastdayI)) tErrors+= s_datacheckoutc + invertiData(firstday) + s_datacheckinc2 + invertiData(lastday) + ".\n\n";		if (form.numadulti.selectedIndex == 0){		tErrors += s_indadulti;		}	if((adulti + bambini_312) > maxpeople){		tErrors += s_totsup + maxpeople + s_totsup2;		}	if(arriveI >= departureI){		tErrors += s_gsucc;		}	if (tErrors!=""){		alert(tErrors);		return false;		}	return true;}function invertiData(arg) {	if(arg.length == 10) {		var giorno = arg.substring(8, 10);		var mese = arg.substring(5, 7);		var anno = arg.substring(0, 4);		return giorno + '-' + mese + '-' + anno;		}	else		return '';	}	
