function LoadDestinations(rlm) {
//Questa funzione viene caricata all'avvio delal pagina e riempe la combobox


if (document.FormRicerca.Ricerca_in[1].checked) { 
	
	for (var i=0;i<=globalc;i++) {
		document.FormRicerca.Destinazione.options[i] = new Option(Destinazioni[i],Destinazioni[i],false,false);
		document.FormRicerca.Destinazione.options[i].selected = false;
	}
	document.FormRicerca.Destinazione.options.length = i;
}
else {
	var maxrlm=0;
	for (var i=0;i<=globalc;i++) {
		if (reallastminute[i] == "s") {
			document.FormRicerca.Destinazione.options[maxrlm] = new Option(Destinazioni[i],Destinazioni[i],false,false);
			document.FormRicerca.Destinazione.options[maxrlm].selected = false;
			maxrlm++;
		}
	}
	document.FormRicerca.Destinazione.options.length = maxrlm;
}
document.FormRicerca.Destinazione.options[0].selected = true;
}
function popUp(z){

window.open(z,'','scrollbars=1,statusbar=0,personalbar=0,toolbar=0,menubar=0,width=640,height=500,screenX=20,screenY=20,top=20,left=20');

}

function VerificaDataDal() {

	giorno = document.FormRicerca.da_g.options.selectedIndex + 1;
	mese = document.FormRicerca.da_m.options.selectedIndex + 1;
   anno = document.FormRicerca.da_a.options[document.FormRicerca.da_a.options.selectedIndex].value;
	
	if ((mese==4 || mese == 6 || mese == 9 || mese == 11) && giorno>30 ) {
		document.FormRicerca.da_g.options.selectedIndex = 29;
	}
	
	if (mese == 2) {
		if (anno%4 == 0) {
			if (giorno > 29) document.FormRicerca.da_g.options.selectedIndex = 28;
		}
		else {
			if (giorno > 28) document.FormRicerca.da_g.options.selectedIndex = 27;
		}	
	}
}

function VerificaDataAl() {

	giorno = document.FormRicerca.a_g.options.selectedIndex + 1;
	mese = document.FormRicerca.a_m.options.selectedIndex + 1;
   anno = document.FormRicerca.a_a.options[document.FormRicerca.a_a.selectedIndex].value;
	
	if ((mese==4 || mese == 6 || mese == 9 || mese == 11) && giorno>30 ) {
		document.FormRicerca.a_g.selectedIndex = 29;
	}
	
	if (mese == 2) {
		if (anno%4 == 0) {
			if (giorno > 29) document.FormRicerca.a_g.selectedIndex = 28;
		}
		else {
			if (giorno > 28) document.FormRicerca.a_g.selectedIndex = 27;
		}	
	}
}

function ImpostaData() {


oggi = new Date();

gg = oggi.getDate();
mm = oggi.getMonth();
yy = oggi.getFullYear()-2008;

document.FormRicerca.da_g.options[gg-1].selected = true;
document.FormRicerca.da_m.options[mm].selected = true;
document.FormRicerca.da_a.options[yy].selected = true;

document.FormRicerca.a_g.options[gg-1].selected = true;
document.FormRicerca.a_m.options[mm].selected = true;
document.FormRicerca.a_a.options[yy+1].selected = true;

}
LoadDestinations(0);
ImpostaData();
