function setCity(tempCity){
 	var city = tempCity;
 	return city;
 }

function populateCountries() {
	var pm_2 = document.getElementById("country").options;
	var pm_3 = document.getElementById("city").options;
   	for (i=0; i<selection.length ; i+=3) {
		var cale = new Option (selection[i+1],i+2);
		pm_2[pm_2.length] = cale;
 	}
 	if(typeof( window[ 'city' ] ) == "undefined" ){
 	}else{
		var countCountry = 0;
		for(i=0; i<selection.length; i+=3){
			countCountry+=1;
			var countCity = 0;
			for(j=0; j<selection[i+2].length; j+=3){
				if(selection[i+2][j+1].toLowerCase()==city.toLowerCase()){
					pm_2.selectedIndex = countCountry;
					populateCities(i+2);
					pm_3.selectedIndex = countCity;
				}
				countCity+=1;
			}
		}
 	}
}

function populateCities(j) {
	var pm_2 = document.getElementById("city").options;
	if (j!="0") {
		pm_2.length = 0;
		for (var k = 0; k<selection[j].length; k+=3) {
			var calh = new Option (selection[j][k+1],selection[j][k+0]);
			pm_2[pm_2.length] = calh;
		}
	}
}

function setDefaultYear(){
 	aday = document.getElementById("giorno");
 	amonth = document.getElementById("mese");
 	ayear = document.getElementById("anno");
  	var now = new Date();
	now.setDate(now.getDate());
 	aday.selectedIndex = now.getDate();
 	amonth.selectedIndex = now.getMonth();
 	ayear.selectedIndex = now.getYear();
}

function setYears(){
	var pm_3 = document.getElementById("anno").options;
	var date = new Date();
	var year = date.getFullYear();
	document.getElementById("year").text = year;
	for (i=0; i<2 ; i+=1) {
		year = year+1;
		var caly = new Option (year,i);
		pm_3[pm_3.length] = caly;
 	}
}