function setRoomHome(nrooms, label_adults, label_children, label_children_age, label_room) {
	var myResults = '';
	
	if (nrooms > 1)	// se viene scelta pił di una camera...
	{
		for (var i=2; i<=nrooms; i++)	// preparo la stringa da accodare alla prima camera, contenente i campi necessari
		{
			myResults = myResults + '<li class="room'+ i +' roomTitle">'+ label_room +' '+ i +'</li>';
			
			myResults = myResults +	'<li class="room'+ i +' adults">'+
										'<label>'+ label_adults +'</label>'+
										'<select name="bform[reqRooms]['+ i +'][adults]">'+
											createSelect(6, 1, label_adults, "", 2)+
										'</select>'+
									'</li>'+
									'<li class="room'+ i +' children">'+
										'<label>'+ label_children +'</label>'+
										'<select name="bform[reqRooms]['+ i +'][child]" onchange="setChildAge(this.value,\'chdAge_'+ i +'\', '+ i +',\''+ label_children_age +'\');">'+
											createSelect(4, 0, label_children, "", 0)+
										'</select>'+
									'</li>'+
									'<li class="room'+ i +' childAge" id="chdAge_'+ i +'"></li>';
		}
		
		$('li.room1.roomTitle').remove();				// rimuovo il titolo della camera 1 (per evitare duplicazioni nel caso sia gią presente: vedi istruzione successiva)
		$('li.room1:first').before('<li class="room1 roomTitle">'+ label_room +' 1</li>');		// aggiungo il titolo della camera 1, prima del primo campo della camera 1
		$('li.room1:last').nextAll().remove();			// rimuovo tutti gli elementi dopo l'ultimo elemento della camera 1
		$('li.room1:last').after(myResults);			// aggiungo dopo l'ultimo elemento della camera 1, la stringa preparata in precedenza
	}
	else			// se viene scelta una sola camera...
	{
		$('li.room1.roomTitle').remove();				// rimuovo il titolo della camera 1
		$('li.room1:last').nextAll().remove();			// rimuovo tutti gli elementi dopo l'ultimo elemento della camera 1
	}
}


function setChildAge(nchild, chdid, roomn, label_children_age){
	var selectHtml = "";
	if(nchild > 0){
		selectHtml = '<label>'+ label_children_age +'</label>';
		for (var cc=1; cc<=nchild; cc++) {
			selectHtml =  selectHtml + '<select name="bform[reqRooms]['+roomn+'][childAge][' + cc + ']">' +
                '<option value="0">&lsaquo; 1</option>';
				for(var k=1; k<=18; k++){
					k_opt = k<10 ? "&nbsp;"+ k : k;
					selectHtml =  selectHtml + "\n" + '<option value="'+ k +'">'+ k_opt +'</option>';
				}
				selectHtml =  selectHtml + '</select>';
		}
	}

	if($('#'+chdid)){
		$('#'+chdid).html(selectHtml);
	}
}


function createSelect(num, init, label, labels, selected){
	if(label != ""){
		label = " "+ label;
	}
	if(labels != ""){
		labels = " "+ labels;
	} else {
		labels = label;
	}
	var mySel = "";
	for(var k=init; k<=num; k++){
		if(k!=init) label = labels;
		if (selected != 0 && selected == k){
			//mySel = mySel + "\n" + '<option value="'+ k +'" selected="selected">'+ k + label +'</option>';	// numero + nome
			mySel = mySel + "\n" + '<option value="'+ k +'" selected="selected">'+ k + '</option>';				// solo numero
		} else {
			//mySel = mySel + "\n" + '<option value="'+ k +'">'+ k + label +'</option>';	// numero + nome
			mySel = mySel + "\n" + '<option value="'+ k +'">'+ k + '</option>';				// solo numero
		}
	}
	return mySel;
}

$(document).ready(function(){
	$(".average, .best, .item, .votes, .count").hide();
});

// FUNZIONI PER LA MAPPA V3
var infowindow,maps;var setDirection={options:{dirContainer:document.getElementById('dirContainer'),dirService:"",dirRenderer:"",myMarker:"",mapId:"",zoom:"",mapType:"",showCursor:""},set:function(mapId,optiones,zoom,mapType,showCursor){setDirection.options.mapId=mapId;setDirection.options.zoom=zoom;setDirection.options.mapType=mapType;setDirection.options.showCursor=showCursor;setDirection.options.myMarker=new Array();for(names in optiones)setDirection.options.myMarker[names]=optiones[names];setDirection.options.myMarker['infowindow']='<div id="ballon"><h5>'+setDirection.options.myMarker['labelTitle']+'</h5>'+setDirection.options.myMarker['infowindow']+'<br /><br />'+setDirection.options.myMarker['labelCalculate']+'<br /><a href="javascript:;" onclick="setDirection.init(\'<h5>'+setDirection.options.myMarker['labelTitle']+'</h5><br />'+setDirection.options.myMarker['labelCalculate']+'\', \''+setDirection.options.myMarker['labelFrom']+'\', \''+setDirection.options.myMarker['labelTo']+'\', \'FROM\', \''+setDirection.options.myMarker['lat']+', '+setDirection.options.myMarker['lon']+'\');" title="'+setDirection.options.myMarker['labelCalculate']+'"><strong>'+setDirection.options.myMarker['labelFrom']+'</strong></a> - <a href="javascript:;" onclick="setDirection.init(\'<h5>'+setDirection.options.myMarker['labelTitle']+'</h5><br />'+setDirection.options.myMarker['labelCalculate']+'\', \''+setDirection.options.myMarker['labelFrom']+'\', \''+setDirection.options.myMarker['labelTo']+'\', \'TO\', \''+setDirection.options.myMarker['lat']+', '+setDirection.options.myMarker['lon']+'\');" title="'+setDirection.options.myMarker['labelCalculate']+'"><strong>'+setDirection.options.myMarker['labelTo']+'</strong></a></div>';setDirection.openMap();},openMap:function(){var latlng=new google.maps.LatLng(setDirection.options.myMarker['lat'],setDirection.options.myMarker['lon']);if(setDirection.options.mapType==undefined)setDirection.options.mapType="ROADMAP";if(setDirection.options.showCursor==undefined)setDirection.options.showCursor=false;var myOptions={disableDefaultUI:setDirection.options.showCursor,mapTypeControl:false,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},zoom:setDirection.options.zoom,center:latlng,mapTypeId:google.maps.MapTypeId[setDirection.options.mapType]};maps=new google.maps.Map(document.getElementById(setDirection.options.mapId),myOptions);var myLatLng=new google.maps.LatLng(setDirection.options.myMarker['lat'],setDirection.options.myMarker['lon']);var marker=new google.maps.Marker({position:myLatLng,map:maps,icon:setDirection.options.myMarker['icon'],zIndex:10000});if(setDirection.options.myMarker['infowindow']!=""){infowindow=new google.maps.InfoWindow({content:setDirection.options.myMarker['infowindow'],maxWidth:350,position:myLatLng,zIndex:100});infowindow.open(maps,infowindow);google.maps.event.addListener(marker,"click",function(){infowindow.open(maps,infowindow);});}},init:function(myText,from,to,direction,latLan){if(document.getElementById('ballon')){setDirection.options.dirService=new google.maps.DirectionsService();setDirection.options.dirRenderer=new google.maps.DirectionsRenderer();var myFormDirection,textDirection;if(direction=="FROM"){myFormDirection='<form name="direction" action="javascript:;" method="get"><input id="from-input" type="hidden" value="'+latLan+'" />';myFormDirection+='<input id="to-input" type="text" value="" class="inputE" />';myFormDirection+='<input class="inputB" onclick="setDirection.getDirections(document.getElementById(\'from-input\').value, document.getElementById(\'to-input\').value);" type="button" value=">" /></form>';textDirection=myText+'<br /><strong>'+from+'</strong> - <a href="javascript:;" onclick="setDirection.init(\''+myText+'\', \''+from+'\', \''+to+'\', \'TO\', \''+latLan+'\');"><strong>'+to+'</strong></a>'+myFormDirection;}else{myFormDirection='<form name="direction" action="javascript:;" method="get"><input id="from-input" type="text" value="" class="inputE" />';myFormDirection+='<input id="to-input" type="hidden" value="'+latLan+'" />';myFormDirection+='<input class="inputB" onclick="setDirection.getDirections(document.getElementById(\'from-input\').value, document.getElementById(\'to-input\').value);" type="button" value=">" /></form>';textDirection=myText+'<br /><a href="javascript:;" onclick="setDirection.init(\''+myText+'\', \''+from+'\', \''+to+'\', \'FROM\', \''+latLan+'\');"><strong>'+from+'</strong></a> - <strong>'+to+'</strong>'+myFormDirection;}document.getElementById('ballon').innerHTML=textDirection;}},getDirections:function(fromStr,toStr){var dirRequest={origin:fromStr,destination:toStr,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.DirectionsUnitSystem.METRIC,provideRouteAlternatives:true};setDirection.options.dirService.route(dirRequest,setDirection.showDirections);},showDirections:function(dirResult,dirStatus){if(dirStatus!=google.maps.DirectionsStatus.OK){if(typeof(dirStatusErrora)!=undefined){alert(dirStatusError+"\n(Google reports: "+dirStatus+")");}else{alert("The address entered was not found\n(Google reports: "+dirStatus+")");}return;}setDirection.openMap();$('html,body').animate({scrollTop:$('#'+setDirection.options.mapId).offset().top-20},1000);setDirection.options.dirRenderer.setMap(null);setDirection.options.dirRenderer.setMap(maps);$('#dirContainer').html('');setDirection.options.dirRenderer.setPanel(document.getElementById('dirContainer'));setDirection.options.dirRenderer.setDirections(dirResult);}}
// FINE MAPPA
