/* RIA JS */
		if(location.href.indexOf('redazione75.ferroviedellostato.it')!=-1){
			google_key = 'ABQIAAAAZvrn_Tmc64NrWTy_M7v1jhQyOYtmtbCN0yb1TVi5uRO9buLV7xTShgRwjw3HKEjbCC5DuJbhZaxseA'; //redazione75.ferroviedellostato.it
		}else{
			if(location.href.indexOf('ferroviedellostato.it')!=-1){
				google_key = 'ABQIAAAAZvrn_Tmc64NrWTy_M7v1jhS8IQ1ruPwj0typlJn_k28oSIDudxQDJlNkl7Jb38L7wcat6Yh5uVsGYw'; //ferroviedellostato.it
			}else{
				if(location.href.indexOf('preview.e-tree.com')!=-1){
					google_key = 'ABQIAAAAZvrn_Tmc64NrWTy_M7v1jhQobq_SeGX0jcjAWfRt1oPK3RRl_xQ_BFAUpCM0QDQz8SlBMcdxOtg6GQ'; //preview.e-tree.com
				}else{
					google_key = '';
				}
			}
		}


 
/* Lista città */
var cities = { 
	"0":"Bari", 
	"1":"Benevento",
	"2":"Bologna",
	"3":"Brescia",
	"4":"Brindisi",
	"5":"Caserta",
	"6":"Ferrara",
	"7":"Firenze",
	"8":"Foggia",
	"9":"Lamezia",
	"10":"Lecce",
	"11":"Mestre",
	"12":"Milano",
	"13":"Napoli",
	"14":"Padova",
	"15":"Paola",
	"16":"Reggio Calabria",
	"17":"Roma",
	"18":"Rovigo",
	"19":"Salerno",
	"20":"Torino",
	"21":"Venezia",
	"22":"Verona",
	"23":"Vicenza",
	"24":"Villa San Giovanni"
};

var city2id = {
	"Bari":"0", 
	"Benevento":"1",
	"Bologna":"2",
	"Brescia":"3",
	"Brindisi":"4",
	"Caserta":"5",
	"Ferrara":"6",
	"Firenze":"7",
	"Foggia":"8",
	"Lamezia":"9",
	"Lecce":"10",
	"Mestre":"11",
	"Milano":"12",
	"Napoli":"13",
	"Padova":"14",
	"Paola":"15",
	"Reggio Calabria":"16",
	"Roma":"17",
	"Rovigo":"18",
	"Salerno":"19",
	"Torino":"20",
	"Venezia":"21",
	"Verona":"22",
	"Vicenza":"23",
	"Villa San Giovanni":"24"
}

/* Lista città */
var stations = { 
	"0":"Piazza Aldo Moro, Bari", 
	"1":"Piazza Colonna 4, Benevento",
	"2":"Piazza Medaglie d'Oro, Bologna ",
	"3":"Viale della Stazione, 54, Brescia",
	"4":"Piazza Francesco Crispi 1, Brindisi",
	"5":"Piazza Garibaldi, Caserta",
	"6":"Piazzale Stazione, 28, Ferrara",
	"7":"Piazza Stazione, Firenze",
	"8":"Piazzale V.Veneto 1, Foggia",
	"9":"Via Del Mare, Lamezia Terme",
	"10":"Viale Oronzo Quarta, Lecce",
	"11":"Piazzale Favretti, Venezia",
	"12":"Piazza Duca D'Aosta, Milano",
	"13":"Piazza Garibaldi, Napoli",
	"14":"Piazzale Stazione, 14, Padova",
	"15":"Piazza Stazione 1, Paola",
	"16":"Via Barlaam,1, Reggio Calabria ",
	"17":"Piazza dei Cinquecento, Roma",
	"18":"Piazza Riconscenza, 7, Rovigo",
	"19":"Piazza Vittorio Veneto, Salerno",
	"20":"Via Nizza ,2, Torino",
	"21":"Fondamenta S. Lucia Venezia, Venezia",
	"22":"Piazzale XXV Aprile, 6, Verona",
	"23":"Viale Venezia, 14/B, Vicenza",
	"24":"Piazza Stazione, 6/8, Villa S.Giovanni"
};


var name2typeEvent  = {
	"Sport":"0",
	"Concerti":"1",
	"Teatro":"2",	
	"Mostre":"3"
}

var typeEvent2Name  = {
	"0":"Sport",
	"1":"Concerti",
	"2":"Teatro",	
	"3":"Mostre"
}

/* Lista destinazioni */		
var destination  = { 
	"0":["17","5","1","8","4","10"],
	"1":["17","5","8","0","4","10"], 
	"2":["20","12","23","3","22","21","11","14","18","6","7","13","17","19"], 
	"3":["23","22","2","7","17"], 
	"4":["17","5","1","8","0","10"], 
	"5":["17","1","8","0","4","10"], 
	"6":["21","11","14","18","2","7","17"], 
	"7":["17","13","19","20","12","2","22","3","23","6","18","14","11","21"], 
	"8":["17","5","1","0","4","10"], 
	"9":["17","13","19","15","24","16"], 
	"10":["17","5","1","8","0","4"], 
	"11":["21","14","18","6","2","7","17"], 
	"12":["20","2","7","17","13","19"], 
	"13":["20","12","2","7","17","19","15","9","24","16"], 
	"14":["21","11","18","6","2","7","17"], 
	"15":["17","13","19","9","24","16"], 
	"16":["17","13","19","15","9","24"], 
	"17":["13","19","9","15","24","16","5","1","8","0","4","10","7","2","12","20","22","3","23","6","18","14","11","21"], 
	"18":["21","11","14","6","2","7","17"], 
	"19":["20","12","2","7","17","13","15","9","24","16"], 
	"20":["12","2","7","17","13","19"], 
	"21":["11","14","18","6","2","7","17"], 
	"22":["21","11","14","18","2","7","17"], 
	"23":["3","22","2","7","17"], 
	"24":["16","9","15","19","13","17"]
};

var Ria = {
	init: function(){
		loading = new Image(287,46);
		loading.src = "/cms-file/common/img/loading.gif";
		bgStep1 = new Image(385,616);
		bgStep1.src = "/cms-file/common/img/ria-bg-bis.jpg";  
		bgRiaBig = new Image(305,270);
		bgRiaBig.src = "/cms-file/common/img/ria-dx-bg-big.png";
		bgRiaMid = new Image(285,270);
		bgRiaMid.src = "/cms-file/common/img/ria-dx-bg-mid.png";
		bgRiaSmall = new Image(260,270);
		bgRiaSmall.src = "/cms-file/common/img/ria-dx-bg-small.png";
		Ria.loadXmlTicketOne();
		//Ria.loadXmlVenere();
		cityTo = null;
		cityFrom = null;
		dateFrom = null;
		dateReturn = null;
		hotel_chose = false;
		todaydate=new Date();
		todaydate_giorno = todaydate.getDate();
		todaydate_mese = todaydate.getMonth();
		todaydate_mese++;
		todaydate_anno = todaydate.getFullYear();
		
		

	},
	checkDate : function(giorno,mese,anno){
		var action = false	
		if (anno >= todaydate_anno) action = true;
		else action = false;
		
		if (action == true && anno == todaydate_anno){
			if(mese >=todaydate_mese) action = true;
			else action = false;
		}
		
		if (action == true && anno == todaydate_anno && mese == todaydate_mese){
			if(giorno >= todaydate_giorno) action=true;
			else action = false;
		}
		
		if (action == true && first == true) action = true;
		else if( action==true && return_year!=''){
			if(mod_start == true){
				if (anno <= return_year) action = true;
				else action = false;
				
				if (action == true && anno == return_year){
					if(mese <= return_month) action = true;
					else action = false;
				}
				
				if (action == true && anno == return_year && mese == return_month){
					if(giorno <= return_day) action=true;
					else action = false;
				}
				
			}
			else{
				if (anno >= start_year) action = true;
				else action = false;			
				if (action == true && anno == start_year){
					if(mese >= start_month) action = true;
					else action = false;
				}			
				if (action == true && anno == start_year && mese == start_month){
					if(giorno >= start_day) action=true;
					else action = false;
				}			
			}
		}	
		return action
	},
	getData : function(d){
		// da >> 2010-03-23 12:01		
		date = d.substr(0,10);		
		anno = date.split('-')[0].substr(2,2);
		mese = date.split('-')[1];
		giorno = date.split('-')[2];		
		return giorno+'/'+mese+'/'+anno;
		// a >> 23/03/10
	},	
	getHour : function(d){
		// da >> 2010-03-23 12:01		
		hour = d.substr(11,5);
		return hour;
		// a >> 12:01
	},	
	startRia : function(){
		$('ria').style.width = "963px";
		$('ria-bg').style.width = "963px";
		$('ria-banner').fade({ duration: 0.4, from: 1, to: 0 });
		$('fourLinks').fade({ duration: 0.4, from: 1, to: 0 });
		$('ria-step2').style.display = "none";
		$('ria-step3').style.display = "none";
		bgSlide = $$('.ria-bg-dx')[0];		
		new Effect.Morph(bgSlide, {
		  style: 'width:952px;',
		  duration: 0.4,
		  afterFinishInternal:function(){
			$('ria-cont').style.width = "963px";			
			$$('.colDx')[0].style.width = "620px";					
			$('side_right').style.display = "none";		
			$('cont-ria').style.backgroundImage = 'url(/cms-file/common/img/ria-bg.jpg)';
			$('cont-ria').style.display = "block";
			$('ria-step1').style.display = "block";
			$('changeCity').style.display = "block";
		  }
		});
		cityTo = null;
		cityFrom = null;
		dateFrom = null;
		dateReturn = null;
		hotel_chose = false;
		if($('active_return')) $('active_return').checked = false;
	},	
	resetRia : function(){
		if($("list")){$("list").scrollTop = 0;}
		$('ria-step3').style.display = "none";	
		$('ria-step2').style.display = "none";		
		$('ria-step1').style.display = "block";	
		$('changeCity').style.display = "block";
		$('boxNoEventTo').style.display = "none";
		$('boxNoEventFrom').style.display = "none";
		if($('dest')){Element.remove($('dest'));}
		if($('eventSelected')){Element.remove($('eventSelected'));}		
		if($('returnSelected')){ Element.remove($('returnSelected')); }
		$$('.ria-cloud')[0].className = 'ria-cloud big';
		$$('.ria-cloud')[0].style.backgroundImage = 'url(/cms-file/common/img/ria-dx-bg-big.png)';		
		if($('next')){ Element.remove($('next')); }
		if($('checkVenere')){ Element.remove($('checkVenere')); }
		if($('divHotels')){Element.remove($('divHotels'));}
		if($('ria_calendar-cont')){Element.remove($('ria_calendar-cont'));}
		cityTo = null;
		cityFrom = null;
		$('eventi').style.display = "none";
		this.backFromEvent();
		$('titSx').innerHTML = 'DOVE VUOI ANDARE?';
		dateFrom = null;
		dateReturn = null;
		hotel_chose = false;
		if($('active_return')) $('active_return').checked = false;
	},
	closeRia : function(){
		if($("list")){$("list").scrollTop = 0;}
		$('ria-step3').style.display = "none";	
		$('ria-step2').style.display = "none";
		$('ria-step1').style.display = "none";	
		$('ria-banner').style.display = "block";
		$('fourLinks').style.display = "block";
		$('ria-cont').style.width = "677px";
		$('ria').style.width = "677px";	
		$$('.ria-bg-dx')[0].style.width = "667px";
		$$('.colDx')[0].style.width = "332px";
		$('ria-bg').style.width = "688px";	
		$('side_right').style.display = "block";
		$('cont-ria').style.backgroundImage = 'url(/cms-file/common/img/ria-bg.jpg)';
		$('cont-ria').style.display = "none";
		if($('dest')){Element.remove($('dest'));}
		if($('eventSelected')){ Element.remove($('eventSelected')); }
		if($('returnSelected')){ Element.remove($('returnSelected')); }
		$$('.ria-cloud')[0].className = 'ria-cloud big';
		$$('.ria-cloud')[0].style.backgroundImage = 'url(/cms-file/common/img/ria-dx-bg-big.png)';
		if($('selectedEvent')){Element.remove($('selectedEvent'));}
		if($('chooseEvent')){Element.remove($('chooseEvent'));}
		this.backFromEvent();
		$('eventi').style.display = "none";	
		if($('next')){ Element.remove($('next')); }
		if($('checkVenere')){ Element.remove($('checkVenere')); }
		if($('divHotels')){Element.remove($('divHotels'));}
		if($('ria_calendar-cont')){Element.remove($('ria_calendar-cont'));}
		resetCal();
		dateFrom = null;
		dateReturn = null;
		hotel_chose = false;
		if($('active_return')) $('active_return').checked = false;
		$('titSx').innerHTML = 'DOVE VUOI ANDARE?';
	},
	chooseCity : function(e){
		name = cities[e];		
		$('nameCity').innerHTML = name;	
		var fileName = "destinazione_"+e+".swf"
		var flashvars2 = {};
	    var params2 = {wmode: "transparent"};
	    var attributes2 = {};                                        
	    swfobject.embedSWF("/cms-file/video/frecciarossa/"+fileName, "stella", "300", "259", "9.0.0", "/cms-file/video/frecciarossa/expressInstall.swf", flashvars2, params2, attributes2);
		$('cont-ria').style.backgroundImage = 'url(/cms-file/common/img/ria-bg-bis.jpg)';
		$('ria-step1').style.display = "none";
		$('ria-step2').style.display = "block";
		this.showEventByCity(e);
	},
	chooseCloud : function(e){
		if($('boxCloud').style.display == 'none'){
			this.backFromEvent();
			this.chooseCloud(e);		
		}else{
			destCity = cities[e];
			if(!$('dest')){
				$('nameCity').insert ({'after':'<div id="dest"><span class="nd">2.</span> Arrivi a <strong id="nameCityDest">'+destCity+'</strong></div>'});
				
			}else{
				$('nameCityDest').innerHTML = destCity;	
			}
			this.showEventToCity(e);			
		}
	},
	gotoClouds : function(e){
		if(e.className=='active'){
			nameEvent = e.id.split('-')[1];
			$('titCloud').insert ({'bottom':'<a title="back" id="back" href="javascript:;" onclick="Ria.backFromEvent();">back <span>&raquo;</span></a>'});			
			$('textCloud').style.display = "none";
			$('boxCloud').style.display = "none";
			$('eventi').style.display = "block";
			$('eventiTit').innerHTML = "";
			$('eventiTit').insert({'top':'<h2>'+nameEvent+'</h2>'});			
			if(cityTo!=null){
			$('eventiTit').insert({'bottom':'<div class="label"><label for="filter">Ordina per</label> <select class="filter" name="filter" onchange="Ria.filter(this,0);"> <option value="0" selected="selected">Data</option> <option value="2">Evento</option> </select> </div>'});			
				if(data.cities.city[cityTo].event){
					if($('tabEventi')){Element.remove($('tabEventi'));}
					var tabella = new Element('table', { id: "tabEventi", className:"sortable", width:"100%", cellspacing:"0"});	
					var tabellaHead = new Element('thead');
					var tabellaTrHead = new Element('tr');
					var celTH1 = new Element('th').update('1');
					var celTH2 = new Element('th').update('2');
					var celTH3 = new Element('th').update('3');
					var celTH4 = new Element('th').update('4');
					tabellaTrHead.appendChild(celTH1);
					tabellaTrHead.appendChild(celTH2);
					tabellaTrHead.appendChild(celTH3);
					tabellaTrHead.appendChild(celTH4);
					tabellaHead.appendChild(tabellaTrHead);
					var tabellaBody = new Element('tbody');					
					citFromXml = data.cities.city;
					if(citFromXml[cityTo].event){
						for(x=0;x<citFromXml[cityTo].event.length;x++){
							if(citFromXml[cityTo].event[x]["@attributes"].type==name2typeEvent[nameEvent]){								
								var dateEvent = this.getData(citFromXml[cityTo].event[x]["start-date"]); 
								var ggEvent = dateEvent.split('/')[0];
								var mmEvent = dateEvent.split('/')[1];
								var yyEvent = dateEvent.split('/')[2];
								/* se maggiore o ugale a oggi */									
								if(this.checkDate(ggEvent,mmEvent,20+yyEvent)){								
									var row = new Element('tr');									
									var cel1 = new Element('td',{valign:'top'}).update(this.getData(citFromXml[cityTo].event[x]["start-date"]));
									var cel2 = new Element('td',{valign:'top', nowrap:'nowrap'}).update('h - '+this.getHour(citFromXml[cityTo].event[x]["start-date"]));
									var cel3 = new Element('td',{valign:'top'}).update('<strong>'+citFromXml[cityTo].event[x].name+'</strong>');
									var cel4 = new Element('td',{valign:'top'}).update("<input type=\"radio\" name=\"event\" value=\""+citFromXml[cityTo].event[x]['start-date']+"|"+citFromXml[cityTo].event[x]['place-name']+"|"+citFromXml[cityTo].event[x].name+"|"+citFromXml[cityTo].event[x]['address-name']+" "+citFromXml[cityTo]['@attributes'].type+"|"+citFromXml[cityTo]['@attributes'].type+"|"+citFromXml[cityTo].event[x]["@attributes"].id+"|"+citFromXml[cityTo].event[x].url+"\" onclick=\"Ria.showEventSelected(this);\" />");
								
									
									row.appendChild(cel1);
									row.appendChild(cel2);
									row.appendChild(cel3);									
									row.appendChild(cel4);									
									tabellaBody.appendChild(row);							
								}							
							}
						}			
					}
				}
			}else{
				if(cityFrom){				
					$('eventiTit').insert({'bottom':'<div class="label"><label for="filter">Ordina per</label> <select class="filter" name="filter" onchange="Ria.filter(this);"> <option selected="selected" value="1">Città</option> <option value="0">Data</option> <option value="2">Evento</option> </select> </div>'});
				
					dest = destination[cityFrom];
					if($('tabEventi')){Element.remove($('tabEventi'));}
					var tabella = new Element('table', { id: "tabEventi", className:"sortable", width:"100%", cellspacing:"0"});
					var tabellaHead = new Element('thead');
					var tabellaTrHead = new Element('tr');
					var celTH1 = new Element('th').update('1');
					var celTH2 = new Element('th').update('2');
					var celTH3 = new Element('th').update('3');
					var celTH4 = new Element('th').update('4');
					tabellaTrHead.appendChild(celTH1);
					tabellaTrHead.appendChild(celTH2);
					tabellaTrHead.appendChild(celTH3);
					tabellaTrHead.appendChild(celTH4);
					tabellaHead.appendChild(tabellaTrHead);
					var tabellaBody = new Element('tbody');				
					for(i=0; i<dest.length; i++){											
						citFromXml = data.cities.city;
						if(citFromXml[dest[i]].event){
							for(x=0;x<citFromXml[dest[i]].event.length;x++){
								if(citFromXml[dest[i]].event[x]["@attributes"].type==name2typeEvent[nameEvent]){
									var dateEvent = this.getData(citFromXml[dest[i]].event[x]["start-date"]); 
									var ggEvent = dateEvent.split('/')[0];
									var mmEvent = dateEvent.split('/')[1];
									var yyEvent = dateEvent.split('/')[2];
									/* se maggiore o ugale a oggi */									
									if(this.checkDate(ggEvent,mmEvent,20+yyEvent)){
										var row = new Element('tr');									
										var cel1 = new Element('td',{valign:'top'}).update(this.getData(citFromXml[dest[i]].event[x]["start-date"]));
										var cel2 = new Element('td',{valign:'top', className:'city'}).update(citFromXml[dest[i]]["@attributes"].type);
										var cel3 = new Element('td',{valign:'top'}).update(citFromXml[dest[i]].event[x].name);
										var cel4 = new Element('td',{valign:'top'}).update("<input type=\"radio\" name=\"event\" value=\""+citFromXml[dest[i]].event[x]['start-date']+"|"+citFromXml[dest[i]].event[x]['place-name']+"|"+citFromXml[dest[i]].event[x].name+"|"+citFromXml[dest[i]].event[x]['address-name']+" "+citFromXml[dest[i]]['@attributes'].type+"|"+citFromXml[dest[i]]['@attributes'].type+"|"+citFromXml[dest[i]].event[x]["@attributes"].id+"|"+citFromXml[dest[i]].event[x].url+"\" onclick=\"Ria.showEventSelected(this);\" />");
										row.appendChild(cel1);
										row.appendChild(cel2);
										row.appendChild(cel3);
										row.appendChild(cel4);										
										tabellaBody.appendChild(row);	
									}										
								}
							}			
						}						
					}
					cityTo = null;
				}
			}
			tabella.appendChild(tabellaHead);
			tabella.appendChild(tabellaBody);
			$('list').appendChild(tabella);	
			sorttable.makeSortable(tabella);
		}
	},
	backFromEvent : function(e){		
		if($('back')){Element.remove($('back'));}
		if($('selectedEvent')){Element.remove($('selectedEvent'));}
		if($('chooseEvent')){Element.remove($('chooseEvent'));}
		$('textCloud').style.display = "block";
		$('boxCloud').style.display = "block";
		$('eventi').style.display = "none";
	},
	loadXmlTicketOne : function(){
	$('ria-banner').style.visibility='hidden'
		new Ajax.Request('/cms-file/html/frecciarossa/ticketone.json', {
			method: 'get',
			onSuccess: function(t){
				data = t.responseText.evalJSON(true);
				Ria.loadXmlVenere();
			}
		});   
	},
	loadXmlVenere : function(){
		new Ajax.Request('/cms-file/html/frecciarossa/venere.json', {
			method: 'get',
			onSuccess: function(t){
				$('ria-banner').style.visibility='visible'
				Element.remove($('ria-banner-loading'));
				dataV = t.responseText.evalJSON(true);
			}
		});   
	},
	showEventByCity : function(e){
		cityFrom = e;
		$('cl-Sport').className = "";
		$('cl-Concerti').className = "";
		$('cl-Teatro').className = "";
		$('cl-Mostre').className = "";
		singleCity = String(destination[e]).split(',');	
		sport = 0;
		concerti = 0;
		teatro = 0;
		mostre = 0;
		for(var i=0;i<singleCity.length;i++){		
			n = singleCity[i];
			if(data.cities.city[n].event){//prendo solo destinazioni con eventi	
				for(x=0;x<data.cities.city[n].event.length;x++){				
					var typeEvent = data.cities.city[n].event[x]["@attributes"].type;
					
					var dateEvent = this.getData(data.cities.city[n].event[x]["start-date"])
					var ggEvent = dateEvent.split('/')[0];
					var mmEvent = dateEvent.split('/')[1];
					var yyEvent = dateEvent.split('/')[2];
					
					if(this.checkDate(ggEvent,mmEvent,20+yyEvent)){
						if(typeEvent=='0'){sport++;}				
						if(typeEvent=='1'){concerti++;}				
						if(typeEvent=='2'){teatro++;}				
						if(typeEvent=='3'){mostre++;}		
					}					
				}			
			}		
		}		
		tot = sport+concerti+teatro+mostre;
		var font = new Array();
		var cl = new Array();
		for(i=0;i<4;i++){
			if(i==0){t = sport;}
			if(i==1){t = concerti;}
			if(i==2){t = teatro;}
			if(i==3){t = mostre;}		
			font[i] = Math.ceil((100*t)/tot);
			if(t==0){
				font[i] = 0; cl[i] = "disable";
			}else{
				font[i] = Math.ceil((100*t)/tot); cl[i] = "active";
			}
			if(font[i]>24){font[i]=24;}
			if(font[i]<12){font[i]=12;}		
		}		
		$('cl-Sport').setStyle({fontSize:font[0]+'px'});
		$('cl-Concerti').setStyle({fontSize:font[1]+'px'});
		$('cl-Teatro').setStyle({fontSize:font[2]+'px'});
		$('cl-Mostre').setStyle({fontSize:font[3]+'px'});
		Element.addClassName($('cl-Sport'),cl[0]);
		Element.addClassName($('cl-Concerti'),cl[1]);
		Element.addClassName($('cl-Teatro'),cl[2]);
		Element.addClassName($('cl-Mostre'),cl[3]);
		if(cl[0]=='disable' && cl[1]=='disable' && cl[2]=='disable' && cl[3]=='disable'){
			$('boxCloud').style.display = "none";
			$('boxNoEventFrom').style.display = "block";			
		}else{		
			$('boxCloud').style.display = "block";
			$('boxNoEventFrom').style.display = "none";			
		}		
		cityTo = null;		
	},
	showEventToCity : function(e){
		cityTo = e;
		$('cl-Sport').className = "";
		$('cl-Concerti').className = "";
		$('cl-Teatro').className = "";
		$('cl-Mostre').className = "";
		n = e;	
		sport2 = 0;
		concerti2 = 0;
		teatro2 = 0;
		mostre2 = 0;	
		if(data.cities.city[n].event){//prendo solo destinazioni con eventi	
			for(x=0;x<data.cities.city[n].event.length;x++){				
				var typeEvent = data.cities.city[n].event[x]["@attributes"].type;				
				var dateEvent = this.getData(data.cities.city[n].event[x]["start-date"])
				var ggEvent = dateEvent.split('/')[0];
				var mmEvent = dateEvent.split('/')[1];
				var yyEvent = dateEvent.split('/')[2];					
				if(this.checkDate(ggEvent,mmEvent,20+yyEvent)){
					if(typeEvent=='0'){sport2++;}				
					if(typeEvent=='1'){concerti2++;}				
					if(typeEvent=='2'){teatro2++;}				
					if(typeEvent=='3'){mostre2++;}
				}
			}			
		}		
		tot2 = sport2+concerti2+teatro2+mostre2;		
		var font2 = new Array();
		var cl2 = new Array();
		for(i=0;i<4;i++){
			if(i==0){t2 = sport2; if(sport2==0){}}
			if(i==1){t2 = concerti2; if(concerti2==0){}}
			if(i==2){t2 = teatro2; if(teatro2==0){}}
			if(i==3){t2 = mostre2; if(mostre2==0){}}
			if(t2==0){font2[i] = 0;	cl2[i] = "disable";}else{font2[i] = Math.ceil((100*t2)/tot2); cl2[i] = "active";}
			if(font2[i]>24){font2[i]=24;}
			if(font2[i]<12){font2[i]=12;}
		}		
		$('cl-Sport').setStyle({fontSize:font2[0]+'px'});
		$('cl-Concerti').setStyle({fontSize:font2[1]+'px'});
		$('cl-Teatro').setStyle({fontSize:font2[2]+'px'});
		$('cl-Mostre').setStyle({fontSize:font2[3]+'px'});
		Element.addClassName($('cl-Sport'),cl2[0]);
		Element.addClassName($('cl-Concerti'),cl2[1]);
		Element.addClassName($('cl-Teatro'),cl2[2]);
		Element.addClassName($('cl-Mostre'),cl2[3]);
		if(cl2[0]=='disable' && cl2[1]=='disable' && cl2[2]=='disable' && cl2[3]=='disable'){
			$('boxCloud').style.display = "none";
			$('boxNoEventTo').style.display = "block";			
		}else{		
			$('boxCloud').style.display = "block";
			$('boxNoEventTo').style.display = "none";			
		}		
	},
	filter : function(e,b){
		if(b==1){
			sorttable.cicla($('tabHotels').getElementsByTagName('th')[e.options[e.selectedIndex].value]);
		}else{
			sorttable.cicla($('tabEventi').getElementsByTagName('th')[e.options[e.selectedIndex].value]);
		}
	},
	showEventSelected : function(e){		
		time = e.value.split('|')[0];
		date = this.getData(time);
		hour = this.getHour(time);
		loc = e.value.split('|')[1];
		nameEv = e.value.split('|')[2];
		indirizzo = e.value.split('|')[3];
		citta = e.value.split('|')[4];	
		idEv = e.value.split('|')[5];
		urlEv = e.value.split('|')[6];
		var stringa = nameEv+'|'+loc+'|'+indirizzo+'|'+date+' '+hour;
		stringa = stringa.replace(/\'/g,'\'');
		cityTo = city2id[citta];
		var destDiv = new Element('div', {id:"selectedEvent"}).update("<span>Hai scelto</span>:<br /><strong>"+citta+"</strong><br /><strong>"+nameEv+"</strong><br />Data: <strong>"+date+"</strong> - "+hour+"<br />Dove: <strong>"+loc+"</strong><br /><div class='btns'><a href='javascript:;' onclick='Ria.popInfo(\"0\",\""+stringa+"\");' title='Vedi Mappa'><img src='/cms-file/common/img/btn_vedi-mappa.gif' alt='Vedi Mappa' /></a></div>");
		var chooseEvent = new Element('div',{id:"chooseEvent"}).update('<a href="javascript:;" onclick="Ria.add2trip();" title="AGGIUNGI AL TUO VIAGGIO" class="add2trip">+ AGGIUNGI AL TUO VIAGGIO</a><br /><a href="javascript:;" onclick="Ria.chooseCloud('+cityTo+');" id="otherEvent" title="Esplora altre opportunità su '+citta+'">Esplora altre opportunità su '+citta+'</a>');
		$('eventi').insert({'after':destDiv});
		$('eventi').insert({'after':chooseEvent});
		$('eventi').style.display = "none";		
		$('back').onclick = function(){
			cityTo = null;
			if($('chooseEvent')){Element.remove($('chooseEvent'));}
			if($('selectedEvent')){Element.remove($('selectedEvent'));}
			if($('back')){Element.remove($('back'));}
			$('eventi').style.display = "block";
			$('titCloud').insert ({'bottom':'<a title="back" id="back" href="javascript:;" onclick="Ria.backFromEvent();">back <span>&raquo;</span></a>'});	
			inputs = $('tabEventi').getElementsByTagName('input');
			for(i=0;i<inputs.length;i++){		
				inputs[i].checked = false;	
			}
		}	
	},
	popInfo : function(type,attr){
		scroll(0,0);	
		var selects = $$('SELECT');
		for (var i = 0;i<selects.length;i++){
			selects[i].style.visibility='hidden';
		}
		
		popup = new Element('div', { id: "popup", className:"popup",style:'height:'+Element.getHeight(document.body)+'px'});	
		popup_bg = new Element('div', { className:"popup_bg",style:'height:'+Element.getHeight(document.body)+'px'}).update('&nbsp;');
		popup_layer = new Element('div', { className:"popup_layer"});
		popup_layer_bg = new Element('div', { className:"popup_layer_bg png"})
		popup_layer_bottom = new Element('img',{className:"png", src:"/cms-file/common/img/popup_layer_btt.png" });
		
		close_button = new Element('div', { className:"close_button"}).update('<a href="javascript:;" onclick="Ria.closePopInfo();">CHIUDI <span>X</span></a>');
		
		if ( type == 0 ){
			var info_event = attr.split('|');
			var indirizzo = info_event[2].replace(/\ /g,'+');
					
			var intestazione = new Element('div', { className:"intestazione"}).update(info_event[0]);
			var subintestazione = new Element('div', { className:"subintestazione"}).update(info_event[1]+' '+info_event[3]);
			var corpo_popup = new Element('div');
			var sep = new Element('div');

		}else{
		//hotel	
			for (var i=0;i<dataV.hotels.hotel.length;i++){
				if ( dataV.hotels.hotel[i].id == attr ){
					var myhotel = dataV.hotels.hotel[i];				
				}
			}
			
			var nome_hotel = 'Hotel '+myhotel.name;
			var stelle_hotel = myhotel.rating;
			var html_stelle_hotel = '<div style="display:inline; white-space:nowrap">';
			for (var i=0;i<stelle_hotel;i++){
				html_stelle_hotel +=' <img src="/cms-file/common/img/icoStella.gif">';	
			}
			html_stelle_hotel += '</div>';
			//GENERICA
			//var camera = myhotel.rooms.room[0].description+' a partire da '+myhotel.rooms.room[0].roomPriceList+'&euro; (Tasse incluse)';
			//SOLO PER ITALIANO
			var stanza = myhotel.rooms.room;
			if (stanza[0]) stanza = stanza[0];
			
			var camera = stanza.description.replace('Double','doppia')+' a partire da '+stanza.roomPriceList+'&euro; (Tasse incluse)';
			
			var descrizione_hotel = myhotel.description;
			var immagine_hotel = myhotel.photoUrl;
			var indirizzo = myhotel.address.replace(/\ /g,'+')+' '+myhotel.city;
			
			var book_url = stanza.bookUrl;
	
	
			var intestazione = new Element('div', { className:"intestazione"}).update(nome_hotel+html_stelle_hotel);
			var subintestazione = new Element('div', { className:"subintestazione"}).update(camera);
			var corpo_popup = new Element('div',{ className:"corpo_popup"})
			var hotel_img = new Element('img',{ className:"hotel_img",src:immagine_hotel})
			
			var sep = new Element('div',{className:'sep_popup'}).update('&nbsp');
			corpo_popup.appendChild(hotel_img);
			corpo_popup.innerHTML+=descrizione_hotel;
			
		}	
			img_map_cacheSrc = "http://maps.google.com/maps/api/staticmap?zoom=15&size=310x310&markers=size:mid|color:0xe11605|label: |"+indirizzo+"&sensor=false&key="+google_key;
						
			var img_map = new Image(310,310);
			
			img_map.src = img_map_cacheSrc;
			img_map.className = 'img_map';
				
			var map = new Element('div', { className:"popup_map"})
			var link_map = new Element('a',{href:"http://maps.google.it/maps?f=q&source=s_q&hl=it&q="+indirizzo+"&ie=UTF8&cd=1&geocode=FXVDtQIdq-m0AA&split=0&hq=&hnear="+indirizzo+"&z=15",target:'_blank'});
			
			link_map.appendChild(img_map);
			img_map.style.backgroundImage = 'url('+img_map_cacheSrc+')';
			map.appendChild(link_map);
			
			popup_layer_bg.appendChild(close_button);
			popup_layer_bg.appendChild(intestazione);
			popup_layer_bg.appendChild(subintestazione);
			popup_layer_bg.appendChild(corpo_popup);
			popup_layer_bg.appendChild(sep);
			popup_layer_bg.appendChild(map);
			
			popup_layer.appendChild(popup_layer_bg)
			popup_layer.appendChild(popup_layer_bottom);
			popup.appendChild(popup_bg);
			popup.appendChild(popup_layer);
			document.body.appendChild(popup);
		
		
	},
	closePopInfo : function(){	
		if($('popup')){ Element.remove($('popup')); }
		var selects = $$('SELECT');
		for (var i = 0;i<selects.length;i++){
			selects[i].style.visibility='visible';
		}
	},
	add2trip : function(){
		$$('.add2trip')[0].style.display = "none";
		$('stella').style.display  = "none";
		$('back').style.display = "none";
		$('changeCity').style.display = "none";
		$('otherEvent').style.display = "none";		
		var p = new Element('p',{id:"textAfterSelect"}).update('Biglietto aggiunto al pacchetto viaggio.');
		$$('.add2trip')[0].insert({'after':p});		
		destCity = cities[cityTo];
		if(!$('dest')){
			$('nameCity').insert ({'after':'<div id="dest"><span class="nd">2.</span> Arrivi a <strong id="nameCityDest">'+destCity+'</strong></div>'});
		}		
		if($$('.ria-cloud')[0].className == 'ria-cloud big'){
			$$('.ria-cloud')[0].className = 'ria-cloud mid';
			$$('.ria-cloud')[0].style.backgroundImage = 'url(/cms-file/common/img/ria-dx-bg-mid.png)';
		}		
		if(nameEv.length>57){
			evento = nameEv.substr(0,57)+'...';		
		}else{		
			evento = nameEv;		
		}		
		$('dest').insert({'after':'<div id="eventSelected"><span class="nd">3.</span> Evento <strong id="nameEventDest">' + date + ' ' + evento + '</strong></div>'});
		$('ria-step2').insert({'bottom':'<a href="javascript:;" onclick="Ria.next(\'v\');" title="Avanti" id="next"><img src="/cms-file/common/img/btn_avanti.png" alt="Avanti" class="png" /></a>'});
		
		$('ria-step2').insert({'bottom':'<div id="ria_calendar-cont"><h2 id="titleCalendar">Seleziona la data di <span id="destCal">partenza</span></h2><div id="ria_calendar"></div><input type="hidden" name="data_partenza" id="data_partenza" /><input type="hidden" name="data_arrivo" id="data_arrivo" /><p class="active_return"><input type="checkbox" name="active_return" id="active_return" onclick="Ria.activeReturn();" /> <label for="active_return">Acquista anche il ritorno</label></p></div>'});
		dd = time.split('-')[2]; 
		mm = time.split('-')[1];
		yyyy = time.split('-')[0];
		$('titSx').innerHTML = 'QUANDO VUOI PARTIRE?';	
		openCal(dd.substr(0,2),mm,yyyy);		
	},
	activeReturn  : function(){
		active_return();
		if($('active_return').checked){			
			if($('destCal')){
				$('destCal').innerHTML = 'destinazione';
			}
		}else{
			if($('destCal')){
				$('destCal').innerHTML = 'partenza';
			}
		}
	
	},
	next : function(e){
		if(e=='v'){
			if($('active_return').checked){
				if($('data_arrivo').value!=''){
					if($('checkVenere')){Element.remove($('checkVenere'));}
					dataArrivo = $('data_arrivo').value;
					if($('ria_calendar-cont')){Element.remove($('ria_calendar-cont'));}
					var diVenere = new Element('div',{id:'checkVenere'}).update('<br /><input type="checkbox" onclick="Ria.chooseHotel(this);" value="venere" id="showVenere" /> <p><label for="showVenere">Consulta la lista di hotel convenzionati Venere.com per '+cities[cityTo]+'</label></p><div class="clear"></div><br /><br />');
					
					var imgX = new Image();
					imgX.src = "/cms-file/common/img/banner_venere.gif";
					
					var imgVenere = new Element('img',{src:'/cms-file/common/img/banner_venere.gif',id:'imgVenere',alt:'In collaborazione con Venere.com'});
					$('titSx').innerHTML = 'Vuoi ospitalità alberghiera?';
					
					$('ria-step2').appendChild(diVenere);	
					diVenere.appendChild(imgVenere);
					
					if($$('.ria-cloud')[0].className == 'ria-cloud mid'){
						$$('.ria-cloud')[0].className = 'ria-cloud small';
						$$('.ria-cloud')[0].style.backgroundImage = 'url(/cms-file/common/img/ria-dx-bg-small.png)';
					}
					$('eventSelected').insert({'after':'<div id="returnSelected"><span class="nd">4.</span>Torna da: <strong>'+cities[cityTo]+' - '+dataArrivo+'</strong></div>'})
					$('next').onclick = function(){Ria.next('a');};
				}else{
					alert("Hai deciso di acquistare anche il giorno di ritorno. Per procedere devi prima selezionarlo.");
				};
			}else{
				if($('checkVenere')){Element.remove($('checkVenere'));}
				if($('ria_calendar-cont')){Element.remove($('ria_calendar-cont'));}
				var diVenere = new Element('div',{id:'checkVenere'}).update('<input type="checkbox" onclick="Ria.chooseHotel(this);" value="venere" id="showVenere" /> <p><label for="showVenere">Consulta la lista di hotel convenzionati Venere.com per '+cities[cityTo]+'</label></p><div class="clear"></div><br /><br /><br />');
				var imgVenere = new Element('img',{src:'/cms-file/common/img/banner_venere.gif',id:'imgVenere',alt:'In collaborazione con Venere.com'});
				$('titSx').innerHTML = 'Vuoi ospitalità alberghiera?';
				diVenere.appendChild(imgVenere);
				$('ria-step2').appendChild(diVenere);
				$('next').onclick = function(){Ria.next('a');};
			};		
			
		}else{		
			if($('showVenere').checked==true){			
				var inputs = $('tabHotels').getElementsByTagName('input');
				for ( var i=0; i<inputs.length; i++ ){
					if ( inputs[i].type == 'radio' && inputs[i].checked == true ){
						hotel_chose = true;
						var input_hotel = inputs[i];
					}
				}
				
				if ( hotel_chose == true ){
					var info_hotel = input_hotel.value.split('|');
					nameH = info_hotel[0];
					indirizzoH = info_hotel[1];
					urlH = info_hotel[2];
					this.goToReport();
				}
				else{	
					alert('Devi scegliere prima l\'hotel');
				}
					
				
			}else{
				this.goToReport();
			}
		}
	},
	backtoHotel : function(){
		$('ria-step3').style.display = "none";	
		$('ria-step2').style.display = "block";
	},
	goToReport : function(){
		$('ria-step2').style.display = "none";	
		$('ria-step3').style.display = "block";
		var riep_tit = new Element('div',{className:'riep_tit'}).update('Riepilogo della tua ipotesi di viaggio:');
		var riep_box1 = new Element('div',{className:'riep_box'});
		var riep_box1_p = new Element('p').update('<span>A.</span> Parti da <strong>'+cities[cityFrom]+'</strong> il '+dateStart+'</strong>');
		var lettera = 'B.';
		var lettera2 = 'C.';
		riep_box1.appendChild(riep_box1_p);
		
		var link_trenitalia = 'http://orario.trenitalia.com/b2c/nppPriceTravelSolutions.do?car=0&stazin='+cities[cityFrom].replace(/\ /g,'+')+'&stazout='+cities[cityTo].replace(/\ /g,'+')+'&datag='+dateStart.split('/')[0]+'&datam='+dateStart.split('/')[1]+'&dataa='+dateStart.split('/')[2]+'&timsh=10&stazin_r=&stazout_r=&timsm=59&timsm_r=59&lang=it&nreq=5&channel=tcom&lang_r=it&nreq_r=5&npag=1&npag_r=1&channel_r=tcom'
		
		if(dateReturn){
			var riep_box1_p2 = new Element('p').update('<span>B.</span> Torni da <strong>'+cities[cityTo]+'</strong> il '+dateReturn+'</strong>');	
			lettera = 'C.';
			var lettera2 = 'D.';
			riep_box1.appendChild(riep_box1_p2);
			var link_trenitalia = 'http://orario.trenitalia.com/b2c/nppPriceTravelSolutions.do?car=A&stazin='+cities[cityFrom].replace(/\ /g,'+')+'&stazout='+cities[cityTo].replace(/\ /g,'+')+'&datag='+dateStart.split('/')[0]+'&datam='+dateStart.split('/')[1]+'&dataa='+dateStart.split('/')[2]+'&timsh=10&datag_r='+dateReturn.split('/')[0]+'&datam_r='+dateReturn.split('/')[1]+'&dataa_r='+dateReturn.split('/')[2]+'&timsh_r=10&stazin_r='+cities[cityTo].replace(/\ /g,'+')+'&stazout_r='+cities[cityFrom].replace(/\ /g,'+')+'&timsm=59&timsm_r=59&lang=it&nreq=5&channel=tcom&lang_r=it&nreq_r=5&npag=1&npag_r=1&channel_r=tcom'
		}

		var link_treni = new Element('a',{className:'riep_vaia_img', href:link_trenitalia,target:'_blank'}).update('<img src="/cms-file/common/img/riep_vaia.gif" style="background:url(/cms-file/common/img/riep_vaia.gif) top left no-repeat" />');
		riep_box1.appendChild(link_treni);
		
		var riep_sep = new Element('div',{className:'riep_sep png'}).update('&nbsp;');
		var riep_sep2 = new Element('div',{className:'riep_sep png'}).update('&nbsp;');
		var riep_sep3 = new Element('div',{className:'riep_sep png'}).update('&nbsp;');
		
		if(nameEv){//se non ho selezionato l'evento
			var riep_box2 = new Element('div',{className:'riep_box'}).update('<p><span>'+lettera+'</span> Evento <strong>'+nameEv+'</strong> il <strong>'+date+'</strong>, ore <strong>'+hour+'</strong></p>');
			var link_evento = new Element('a',{className:'riep_vaia_img', href:urlEv, target:'_blank'}).update('<img src="/cms-file/common/img/riep_vaia.gif" style="background:url(/cms-file/common/img/riep_vaia.gif) top left no-repeat" />');
			riep_box2.appendChild(link_evento);
		}
		if($('showVenere').checked==true && hotel_chose==true){//se non ho selezionato l'hotel
			var riep_box3 = new Element('div',{className:'riep_box'}).update('<p><span>'+lettera2+'</span> Alloggi all\'<strong>Hotel '+nameH+'</strong> di <strong>'+cities[cityTo]+'</strong>');	
			
			var link_hotel = new Element('a',{className:'riep_vaia_img', href:urlH, target:'_blank'}).update('<img src="/cms-file/common/img/riep_vaia.gif" style="background:url(/cms-file/common/img/riep_vaia.gif) top left no-repeat" />');
			var link_hotel2 = new Element('a',{className:'riep_modifica_img', id:'riep_modifica', href:'javascript:;', onclick:'Ria.backtoHotel();' }).update('<img src="/cms-file/common/img/riep_modifica.gif" style="background:url(/cms-file/common/img/riep_modifica.gif) top left no-repeat;" />');
			
			riep_box3.appendChild(link_hotel);
			riep_box3.appendChild(link_hotel2);
			
			var indirizzo_da = stations[cityTo].replace(/\ /g,'+');
			var indirizzo_a = indirizzoH.replace(/\ /g,'+');
			
			var google_link  = 'http://maps.google.it/maps?f=d&source=s_d&saddr='+indirizzo_da+'&daddr='+indirizzo_a+','+cities[cityTo]+'&hl=it';
			
	
			var percorso_hotel = new Element('a',{href:google_link, target:'_blank'});
			var img_percorso_hotel = new Element('img',{
				src:'/cms-file/common/img/btn_percorsodallastazione.gif', 
				alt:'trova percorso dalla stazione',
				style:'background:url(/cms-file/common/img/btn_percorsodallastazione.gif) top left no-repeat; width:203px; height:23px;'
			});
			
			
			riep_box3.appendChild(percorso_hotel);
			percorso_hotel.appendChild(img_percorso_hotel);
			
		}
		$('ria-step3').innerHTML = '';
		$('ria-step3').appendChild(riep_tit);
		$('ria-step3').appendChild(riep_box1);
		$('ria-step3').appendChild(riep_sep);
		if(riep_box2){
			$('ria-step3').appendChild(riep_box2);
			$('ria-step3').appendChild(riep_sep2);
		}
		if(riep_box3){
			$('ria-step3').appendChild(riep_box3);
			$('ria-step3').appendChild(riep_sep3);
			$('riep_modifica').onclick = function(){ Ria.backtoHotel(); };
		}
		
	},
	chooseHotel : function(e){
		if(e.checked==true){
			$('chooseEvent').style.display = 'none';
			$('selectedEvent').style.display = 'none';			
			if($('divHotels')){Element.remove($('divHotels'));}
			var divHotels = new Element('div',{id:'divHotels'});
			var headHotels = new Element('div',{id:'headHotels'}).update('Alberghi:');
			var contHotels = new Element('div',{id:'contHotels'});
			var tabella = new Element('table', { id: "tabHotels", className:"sortable", width:"100%", cellspacing:"0"});	
			var tabellaHead = new Element('thead');
			var tabellaTrHead = new Element('tr');
			var celTH1 = new Element('th').update('1');
			var celTH2 = new Element('th').update('2');
			var celTH3 = new Element('th').update('3');
			var celTH4 = new Element('th').update('4');
			tabellaTrHead.appendChild(celTH1);
			tabellaTrHead.appendChild(celTH2);
			tabellaTrHead.appendChild(celTH3);
			tabellaTrHead.appendChild(celTH4);
			tabellaHead.appendChild(tabellaTrHead);
			var tabellaBody = new Element('tbody');	

			
			
			for (i=0; i<dataV.hotels.hotel.length; i++){				
				if ( dataV.hotels.hotel[i].city == cities[cityTo] ){
					var row = new Element('tr');
					if(dataV.hotels.hotel[i].rooms.room[0])	var bookUrl = dataV.hotels.hotel[i].rooms.room[0].bookUrl;
					else var bookUrl = dataV.hotels.hotel[i].rooms.room.bookUrl;

					StartDay = dateStart.split('/')[0];
					StartMonth = dateStart.split('/')[1];
					StartYear = dateStart.split('/')[2];
										
					if(dateReturn){
						EndDay = dateReturn.split('/')[0];
						EndMonth = dateReturn.split('/')[1];
						EndYear = dateReturn.split('/')[2];
					}else{
						EndDay = date.split('/')[0];
						EndMonth = date.split('/')[1];
						EndYear = '20'+date.split('/')[2];
						var campodata = EndDay+"/"+EndMonth+"/"+EndYear; //GIORNO DA CUI CALCOLARE IL DOMANI
						var separ = campodata.split(/[\/\.\-]/);
						var giorno = new Date(separ[2], parseInt(separ[1],10)-1, separ[0]);
						giorno.setDate(giorno.getDate()+1);
						EndDay = giorno.getDate();
						if(EndDay<10){ EndDay = '0'+EndDay;}
						EndMonth = giorno.getMonth();
						EndMonth++;
						if(EndMonth<10){ EndMonth='0'+EndMonth;}
						EndYear = giorno.getFullYear();							
					}
										
					bookUrl = bookUrl.split('&sd=')[0] +'&sd='+ StartDay +'&sm='+ StartMonth +'&sy='+ StartYear +'&ed='+ EndDay +'&em='+ EndMonth +'&ey='+ EndYear +'&pval='+ bookUrl.split('&pval=')[1];
					
					var cel1 = new Element('td',{valign:'middle', className:'addPaddLeft'}).update("<input type=\"radio\" name=\"hotel\" value=\""+dataV.hotels.hotel[i].name+"|"+dataV.hotels.hotel[i].address+"|"+bookUrl+"\" onclick=\"\" />");
					var cel2 = new Element('td',{valign:'middle', sorttable_customkey:dataV.hotels.hotel[i].minCostOfStay, className:'addPadd'}).update('<img width="42" height="42" src="'+dataV.hotels.hotel[i].photoUrl+'" alt="'+dataV.hotels.hotel[i].name+'" />');
					var cel3 = new Element('td',{valign:'middle', className:'addPadd'}).update('<strong>Hotel '+dataV.hotels.hotel[i].name+'</strong><br />Da <strong>'+dataV.hotels.hotel[i].minCostOfStay+'&euro;</strong> a notte');
					var cel4 = new Element('td',{valign:'middle'}).update('<a href="javascript:;" onclick="Ria.popInfo(1,'+dataV.hotels.hotel[i].id+')" title="Dettagli"><img src="/cms-file/common/img/btn_dettagli.gif" alt="Dettagli" /></a>');
					row.appendChild(cel1);
					row.appendChild(cel2);
					row.appendChild(cel3);									
					row.appendChild(cel4);									
					tabellaBody.appendChild(row);
				}
			}
			tabella.appendChild(tabellaHead);
			tabella.appendChild(tabellaBody);
			contHotels.appendChild(tabella);
			divHotels.appendChild(headHotels);
			divHotels.appendChild(contHotels);
			$$('.ria-cloud')[0].appendChild(divHotels);
			
			$('headHotels').insert({'bottom':'<div class="label"> <label for="filter">Ordina per</label> <select class="filter" name="filter" onchange="Ria.filter(this,1);"> <option value="1" selected="selected">Prezzo</option> <option value="2">Nome</option> </select> </div>'});
			
			sorttable.makeSortable(tabella);			
		}else{
			if($('divHotels')){Element.remove($('divHotels'));}
			$('chooseEvent').style.display = 'block';
			$('selectedEvent').style.display = 'block';
		}	
	}
}

chooseCloud = function(e){ Ria.chooseCloud(e); }
chooseCity = function(e){ Ria.chooseCity(e); }


var slide = {
 	init : function(){ 
		this.time='';
		this.delay=3000;
		this.margine_layer = 0;
		this.automatic_slide = false;
		this.HOWMANYSTEP = 1;
		this.drag = true;		
		var padri = $$('.slider');
		for (var i=0;i<padri.length;i++){
			slide.setVar(padri[i].getElementsByClassName('arrow_left')[0].getElementsByTagName('a')[0]);
			slide.checkArrowPosition();
			padri[i].setStyle({overflow:'hidden'});
		}
	},
	setVar : function(ele){
		if(ele != ''){ this.ele = ele; }	
		this.move = '';		
		if(this.padre!=this.ele.parentNode.parentNode){
			this.padre = this.ele.parentNode.parentNode;
			this.sliderCT = this.ele.parentNode.parentNode.getElementsByClassName('sliderCT')[0];
			this.layer = this.sliderCT.getElementsByClassName('layer');					
			this.grandezza = 0;
			this.grandezza_layer = 0;			
			if(this.automatic_slide == true){
				var firstLayer = this.layer[0].clone(true);				
				this.sliderCT.appendChild(firstLayer);
			}
			this.layer = this.sliderCT.getElementsByClassName('layer');			
			for( var i=0;i<this.layer.length;i++){
				this.grandezza_layer = this.layer[i].getWidth();
				this.grandezza += this.layer[i].getWidth();
				this.grandezza += this.margine_layer;				
			}			
			this.timeSlide();
		}
	},
	moveSlide : function(ele,direction){
		slide.setVar(ele);			
		if(direction=='left'){
			var nextStep = this.sliderCT.style.left.replace('px','')-parseInt(this.HOWMANYSTEP*(this.grandezza_layer+this.margine_layer))
			nextStep = 0-nextStep;
			if(nextStep<this.grandezza)	this.move='-'+parseInt(this.grandezza_layer+this.margine_layer);
		}
		else{
			if(this.sliderCT.style.left!='' && this.sliderCT.style.left!='0px' ){
				this.move='+'+parseInt(this.grandezza_layer+this.margine_layer);
			}
		}
		
		if(this.move!='' && this.drag == true){
			this.drag = false;
			new Effect.Move(
				this.sliderCT,{
				x:this.move,
				y:0,
				mode:'relative',
				duration:0.8,
				transition:Effect.Transitions.sinoidal,
					afterFinishInternal: function() { 
						slide.checkArrowPosition();
						slide.drag = true;
					}
				}
			)
			this.delay=3000;
			this.timeSlide();
		}
		else{
			this.sliderCT.style.left='0px';
			this.delay=0;
			this.timeSlide();
		}
		
	},
	checkArrowPosition : function(){
		this.padre.getElementsByClassName('arrow_right')[0].style.visibility='visible';
		this.padre.getElementsByClassName('arrow_left')[0].style.visibility='visible';
		if(this.sliderCT.style.left=='' || this.sliderCT.style.left=='0px' ){
			this.padre.getElementsByClassName('arrow_left')[0].style.visibility='hidden';			
		}		
		nextStep = this.sliderCT.style.left.replace('px','')-parseInt(this.HOWMANYSTEP*(this.grandezza_layer+this.margine_layer));
		nextStep = 0-nextStep;
		if(nextStep>=this.grandezza)  this.padre.getElementsByClassName('arrow_right')[0].style.visibility='hidden';
		
	},
	timeSlide : function(){	
		if (this.automatic_slide==true) this.time = setTimeout('slide.moveSlide(\'\',\'left\')',this.delay);
	},
	stopTimeSlide : function(){
		clearTimeout(this.time);	
	}
}

document.observe("dom:loaded", function() {
	Ria.init();
	slide.init();
	//intercetta();
});