// JavaScript Document
miaData = new Date();
var pm_2 = document.forms["main"];
var anni = new Array;
var giorni = new Array;
function populateYears() {
	for (i=0; i<3; i++) {
		anni[i] = miaData.getFullYear()+i;
		var cald = new Option (anni[i],anni[i]+"",false, false); 
		pm_2.anno.options[pm_2.anno.options.length] = cald;
	}
}
populateYears();
function populateDays() {
	for (i=1; i<32; i++) {
		giorni[i] = i;
		var calc = new Option (giorni[i],giorni[i]+"",false, false); 
		pm_2.giorno.options[pm_2.giorno.options.length] = calc;
	}
}
populateDays();
//var anni = new Array (2003, 2004, 2005);
var anno = miaData.getFullYear();
var mioAnno;
for (var i=0; i< anni.length; i++) {
	if(anni[i] == anno) {
		mioAnno = i;
	}
}

var giorniMesi = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var mese = miaData.getMonth();
var giorno = miaData.getDate() + 3;
if (giorno > giorniMesi[mese]) {
	giorno -= giorniMesi[mese];
	mese++;
	if (mese >11) {
		mioAnno++;
	}
}
function setData (anno, mese, giorno) {
	//alert ("anno = " + anno + " mese = " + mese + " giorno = " + giorno);
	pm_2.mese.selectedIndex = mese;
	pm_2.giorno.selectedIndex = giorno;
	pm_2.anno.selectedIndex = mioAnno;
}
setData (mioAnno, mese, giorno -1);
function setDataCalendario (anno, mese, giorno) {
	//alert ("anno = " + anno + " mese = " + mese + " giorno = " + giorno);
	pm_2.mese.selectedIndex = mese;
	pm_2.giorno.selectedIndex = giorno;
	var annoCalendario;
	for (var i=0; i< anni.length; i++) {
		if(anni[i] == anno) {
			annoCalendario = i;
		}
	}

	pm_2.anno.selectedIndex = annoCalendario;
}

function populateCountries() {

	if (typeof(selectedcountry) != "undefined"  && selectedcountry!= "") {
			pm_2.country.options.length=0;
			for (var i=0; i<selection.length ; i+=3) {
				if (selection[i] == selectedcountry) {
					var cala = new Option (selection[i+1],i+2); 
					pm_2.country.options[pm_2.country.options.length] = cala;
					populateCities (i+2);
				}
			}
			var cala = new Option ("--- All countries", "0");
			pm_2.country.options[pm_2.country.options.length] = cala;
	}
	for (i=0; i<selection.length ; i+=3) {
		var cale = new Option (selection[i+1],i+2); 
		pm_2.country.options[pm_2.country.options.length] = cale;
	
	} 
}



function populateCities(j) {
	if (j!="0") {
		
		pm_2.city.options.length = 0;
		if (window.selectedcity && selectedcity != "") {
			var calf = new Option (selectedcity,hclubname);
			pm_2.city.options[pm_2.city.options.length] = calf;
			var calg = new Option ("--- All cities", "0");
			pm_2.city.options[pm_2.city.options.length] = calg;
			selectedcity="";
		}
		for (var k = 0; k<selection[j].length; k+=3) {
			
			var calh = new Option (selection[j][k+1],selection[j][k+2]);
			pm_2.city.options[pm_2.city.options.length] = calh;
			
		}
	}
	
}



