	function formatDate(check){
		start= document.getElementById("startDay").value + "/" + document.getElementById("startMonth").value+ "/" + document.getElementById("startYear").value;
		document.getElementById("COMBO_INIZIOMM_AA").value = start;
		end= document.getElementById("endDay").value + "/" + document.getElementById("endMonth").value+ "/" + document.getElementById("endYear").value;
		document.getElementById("combo_finemm_aa").value = end;
		document.getElementById("action_var").value ='hotelQueryGet';
		
		
		if(document.getElementById("combo_bambini1").value=="1"){
		document.getElementById("combo_bambini_eta11").value ="01";
		}
		
		if(document.getElementById("combo_bambini1").value=="2"){
		document.getElementById("combo_bambini_eta11").value ="01";
		document.getElementById("combo_bambini_eta12").value ="02";
		}
		
		maxPax = document.getElementById("combo_adulti1").value * 1 + document.getElementById("combo_bambini1").value * 1 ;
		
		if(maxPax>4){
			alert("Errore - Numero massimo di posti letto in camera superato");
			return false;
		}
		else{
		if(check=="1"){
		if(document.getElementById("COD_LOCALITA").value=="*"){
			alert("Errore - Scegli una destinazione");
		}
		else{
			document.FHOTEL.submit();
		}
		}
		}
		}
	
	function formatDateEx(){
		if(formatDate()!=false){
		document.getElementById("action_var").value ='hotelPrenNewAdv';
		document.FHOTEL.submit();
		}
	}

	function setCercaTreno(q,v){
		var i;
		for(i=0;i<document.getElementById(q).options.length;i++){
		//alert(document.getElementById(q).options[i].value);
			if(document.getElementById(q).options[i].value==v){
				document.getElementById(q).options.selectedIndex=i;
				break;
			}
		}
	}
	function zeroFill(q,z){
		q=String(q);
		while(q.length<z)q="0"+q;
		return q;
	}
	now=new Date();
	d=zeroFill(now.getDate(),2);
	dp=zeroFill(now.getDate()+1,2);
	m=zeroFill(now.getMonth()+1,2);
	Y=now.getFullYear();
	H=zeroFill(now.getHours(),2);
	if(H>=15 && document.FHOTEL) {
		d++;
		dp++;
	}
	i=zeroFill(now.getMinutes(),2);
//alert(d+"/"+m+"/"+Y+" "+H+":"+i)
	if(document.getElementById("datag")){
		setCercaTreno("datag",d);
		setCercaTreno("datam",m);
		setCercaTreno("dataa",Y);
		setCercaTreno("timsh",H);
		setCercaTreno("timsm",i);
	}
	if(document.getElementById("giorno")){
		setCercaTreno("giorno",d);
		setCercaTreno("mese",m);
		setCercaTreno("anno",Y);
		setCercaTreno("ora",H);
		setCercaTreno("minuto",i);
	}
	if(document.getElementById("dateDay")){
		setCercaTreno("dateDay",d);
		setCercaTreno("dateMonth",m);
		setCercaTreno("dateYear",Y);
		setCercaTreno("timeHour",H);
		setCercaTreno("timeMinute",i);
	}
	if(document.getElementById("startDay")){
		setCercaTreno("startDay",d);
		setCercaTreno("startMonth",m);
		setCercaTreno("startYear",Y);
		setCercaTreno("endDay",dp);
		setCercaTreno("endMonth",m);
		setCercaTreno("endYear",Y);
	}

	
	
	function chkDateGGS() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;

		if ((dayStart >= dayEnd) & (monthStart == monthEnd)) {
			dayEnd=parseInt(dayStart)+1;
			if (dayEnd==32) {
				dayEnd=01;
				monthEnd=parseInt(monthStart)+1;
				if (monthEnd==13) {
					monthEnd=01;
					yearEnd=parseInt(yearStart)+1;
				}
			}
		}
		
	if (String(dayEnd).length == 1) {
		dayEnd="0"+dayEnd;
	}
	if (String(monthEnd).length == 1) {
		monthEnd="0"+monthEnd;
	}
		
	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;

//end function		
}

function chkDateMMS() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;
	
	if (monthStart > monthEnd) {
		dayEnd=parseInt(dayStart)+1;
		if (dayEnd==32) {
			dayEnd=01;
			monthEnd=parseInt(monthStart)+1;
			if (monthEnd==13) {
				monthEnd=01;
				yearEnd=parseInt(yearStart)+1;
			}
		}
		monthEnd=monthStart;
	}
	
	if (String(dayEnd).length == 1) {
		dayEnd="0"+dayEnd;
	}
	if (String(monthEnd).length == 1) {
		monthEnd="0"+monthEnd;
	}

	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;
	
	chkDateGGS();
//end function		
}

function chkDateYYYYS() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;
	
	if (yearStart > yearEnd) {
		yearEnd=yearStart;
	}
	
	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;
	
	chkDateMMS();
//end function		
}


function chkDateGGE() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;

		if ((dayStart >= dayEnd) & (monthStart == monthEnd)) {
			dayStart=parseInt(dayEnd)-1;
			if (dayStart==00) {
				dayStart=31;
				monthStart=parseInt(monthEnd)-1;
				if (monthStart==00) {
					monthStart=12;
					yearStart=parseInt(yearEnd)-1;
				}
			}
		}
		
	if (String(dayStart).length == 1) {
		dayStart="0"+dayStart;
	}
	if (String(monthStart).length == 1) {
		monthStart="0"+monthStart;
	}
		
	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;

//end function		
}

function chkDateMME() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;
	
	if (monthStart > monthEnd) {
		dayStart=parseInt(dayEnd)-1;
		if (dayStart==00) {
			dayStart=31;
			monthStart=parseInt(monthEnd)-1;
			if (monthStart==00) {
				monthStart=12;
				yearStart=parseInt(yearEnd)-1;
			}
		}
		monthStart=monthEnd;
	}
	
	if (String(dayStart).length == 1) {
		dayStart="0"+dayStart;
	}
	if (String(monthStart).length == 1) {
		monthStart="0"+monthStart;
	}

	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;
	
	chkDateGGE();
//end function		
}

function chkDateYYYYE() {
	dayStart=document.getElementById("startDay").value;
	dayEnd=document.getElementById("endDay").value;
	monthStart=document.getElementById("startMonth").value;
	monthEnd=document.getElementById("endMonth").value;
	yearStart=document.getElementById("startYear").value;
	yearEnd=document.getElementById("endYear").value;
	
	if (yearStart > yearEnd) {
		yearStart=yearEnd;
	}
	
	document.getElementById("startDay").value=dayStart;
	document.getElementById("endDay").value=dayEnd;
	document.getElementById("startMonth").value=monthStart;
	document.getElementById("endMonth").value=monthEnd;
	document.getElementById("startYear").value=yearStart;
	document.getElementById("endYear").value=yearEnd;
	
	chkDateMME();
//end function		
}
