function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function CheckData1(form1) {

	if (document.form1.mm1.value=='04' || document.form1.mm1.value=='06' || document.form1.mm1.value=='09' || document.form1.mm1.value=='11'){
		if ( document.form1.gg1.value==31){
			document.form1.gg1.value=30;
		}
	}

	if (document.form1.mm1.value=='02'){
		if (document.form1.aa1.value=='2004' || document.form1.aa1.value=='2008' || document.form1.aa1.value=='2012' || document.form1.aa1.value=='2016' || document.form1.aa1.value=='2020' || document.form1.aa1.value=='2024' || document.form1.aa1.value=='2028' || document.form1.aa1.value=='2032'){
			if (document.form1.gg1.value>29){
				document.form1.gg1.value=29;
			}
		} else {
			if (document.form1.gg1.value>28){
				document.form1.gg1.value=28;
			}
		}
	}

	CheckDataMaggiore(form1);
}

function CheckData2(form1) {


	if (document.form1.mm2.value=='04' || document.form1.mm2.value=='06' || document.form1.mm2.value=='09' || document.form1.mm2.value=='11'){
		if (document.form1.gg2.value==31){
			document.form1.gg2.value=30;
		}
	}


	if (document.form1.mm2.value=='02'){
		if (document.form1.aa2.value=='2004' || document.form1.aa2.value=='2008' || document.form1.aa2.value=='2012' || document.form1.aa2.value=='2016' || document.form1.aa2.value=='2020' || document.form1.aa2.value=='2024' || document.form1.aa2.value=='2028' || document.form1.aa2.value=='2032'){
			if (document.form1.gg2.value>29){
				document.form1.gg2.value=29;
			}
		} else {
			if (document.form1.gg2.value>28){
				document.form1.gg2.value=28;
			}
		}
	}

	CheckDataMaggiore(form1);
}

function CheckDataMaggiore(form1) {
		if (document.form1.aa2.value<document.form1.aa1.value){
			document.form1.aa2.value=document.form1.aa1.value;
		}
	if (document.form1.aa2.value<=document.form1.aa1.value){
		if (document.form1.mm2.value<document.form1.mm1.value){
			document.form1.mm2.value=document.form1.mm1.value;
		}
	}
		
		if (document.form1.mm2.value==document.form1.mm1.value){
			if (document.form1.gg2.value<document.form1.gg1.value){
				document.form1.gg2.value=document.form1.gg1.value;
			}
		}
			if (document.form1.aa2.value==document.form1.aa1.value){
		if (document.form1.mm2.value==document.form1.mm1.value){
			if (document.form1.gg2.value<document.form1.gg1.value){
				document.form1.gg2.value=document.form1.gg1.value;
			}

		}
	}
}

function prenota(gg){
var today = new Date();
    yyyy = today.getFullYear();
    mm = today.getMonth()+1;
    ggg = today.getDate(); 
var c=0;

if(gg.aa1.value <= yyyy && gg.mm1.value <= mm && gg.gg1.value <= ggg){ 
alert("Attenzione: il giono di arrivo deve essere successiva alla data odierna"); 
c=1;
return (false); 
} 

if(gg.aa2.value <=yyyy && gg.mm2.value <= mm && gg.gg2.value <= ggg){ 
alert("Attenzione: il giono di partenza deve essere successiva alla data odierna"); 
c=1;
return (false); 
} 
		
if (gg.gg1.value==gg.gg2.value && gg.mm1.value==gg.mm2.value && gg.aa1.value==gg.aa2.value){
alert("Attenzione: Il giorno di arrivo deve essere successivo al giorno di partenza");
c=1;		
return (false);
}
hotel="";
if(gg.hotel){
	hotel="&hotel="+gg.hotel.value;
}
if (c==0){
window.open("http://194.177.116.136/seahotel/stanze.asp?gg1="+gg.gg1.value+"&mm1="+gg.mm1.value+"&aa1="+gg.aa1.value+"&gg2="+gg.gg2.value+"&mm2="+gg.mm2.value+"&aa2="+gg.aa2.value+"&persone="+gg.persone.value+hotel,"Prenota","top=10, left=10, width=600, height=700, status=no, menubar=no, toolbar=no, scrollbars=yes");
}
return false;
}
function assegna(){
var month=new Array(12)
month[0]="01"
month[1]="02"
month[2]="03"
month[3]="04"
month[4]="05"
month[5]="06"
month[6]="07"
month[7]="08"
month[8]="09"
month[9]="10"
month[10]="11"
month[11]="12"

	var today = new Date();
	var today2 = new Date();
	today.setDate(today.getDate()+1);
	today2.setDate(today2.getDate()+3);
    yy = today.getFullYear();
    mm = today.getMonth();
    gg = today.getDate(); 
    yy2 = today2.getFullYear();
    mm2 = today2.getMonth();
    gg2 = today2.getDate();
	document.getElementById("gg1").value=gg;
	document.getElementById("mm1").value=month[mm];
	document.getElementById("aa1").value=yy;
	document.getElementById("gg2").value=gg2;
	document.getElementById("mm2").value=month[mm2];
	document.getElementById("aa2").value=yy2;
	
}