	//----
	var CERCA_PRENOTA_MAX_ROOMS = 1;
	var CERCA_PRENOTA_MAX_CHILDREN = 4;	
	var STILE_FIXED = "scroll"
	var STILE_FIRSTPAGE = "noScroll"
	var STILE_PAGER = "noScroll"
	var searchLock = 0;
	var data_search = '';
	var notti_search = '';
	var persone_search = '';
	var bambini_search = '';
	var idScheda = '';
	var etaBimbi_1 = '';
	var etaBimbi_2 = '';
	var etaBimbi_3 = '';
	var etaBimbi_4 = '';
	var styleCSS = '';
	var visSearchBox = '0';
	var Feratel='';
	var prezzoTXT = '';
	var labelPrezzoBox = '';
	var thisIsFirstLoad = true;
	
	var addressMyPopup;
	
	var IE7 = (navigator.appVersion.indexOf ("MSIE 7 .")==- 1)? false : true;
	
	Event.observe(window,'load',start);
	
	
	var boxCerca;
	var boxNL;
	
	function start()
	{
	
		if (visSearchBox == "1") {
			$('searchBoxWide').style.display = 'block';
			
			//se c'è prezzo
			if (prezzoTXT != ''){
				$('prezzoTXT').innerHTML = "&euro; " + prezzoTXT.split(',')[0];
				$('labelPrezzoBox').innerHTML = labelPrezzoBox;
				$('prezzoDispo').style.display = 'block';
			}			
			
		}else{
			return;
		}
		
		$('idcms').value = idScheda;

		if ($("cP_form")!=null){
			boxCerca = true;
		}else{
			boxCerca = false;
		}		
		
		if ($("formNl")!=null){
			boxNL = true;
		}else{
			boxNL = false;
		}				
		
		
		//setParTraceFromRequest();
								
		
		//box ricerca e NL---------------------------------
		if (boxCerca){
			setBoxCerca();		
		}
		if (boxNL){
			setBoxNL();				
		}
		
		// CREO IL POPUP
		var myHTMLPopup = "<div id='prenotaPopup' class='popUp' style='width:740px;height:500px;display:none;padding:10px'>";
		myHTMLPopup =  myHTMLPopup + "<div class='box'>";
		myHTMLPopup =  myHTMLPopup + '<div class="closeX"><a style="cursor:pointer" onclick="javascript:closeMyPrenota();">';
		myHTMLPopup =  myHTMLPopup + "<img src='http://appartamenti.visittrentino.it//st179/images/closeX.png' alt='*'  height='24' border='0'></a></div>";
		myHTMLPopup =  myHTMLPopup + "<iframe id='IFprenotaPopup' frameborder='0' scrolling='auto' class='loadPopUp'></iframe>";
		myHTMLPopup =  myHTMLPopup + "<div class='clear'></div>";
		myHTMLPopup =  myHTMLPopup + "<div class='dxTop'> </div>";
		myHTMLPopup =  myHTMLPopup + "<img src='http://appartamenti.visittrentino.it/st179/images/popUpDown.png' alt='*' class='close' height='24'>";
		myHTMLPopup =  myHTMLPopup + "<img src='http://appartamenti.visittrentino.it/st179/images/popUpDownDx.png' alt='*' class='DxBottom' height='32' width='24'>";
		myHTMLPopup =  myHTMLPopup + "</div>";
		myHTMLPopup =  myHTMLPopup + "</div>";

		new Insertion.Top(document.body,myHTMLPopup);

		
		// POSIZIONO IL DIV POPUP AL CENTRO
		if ($('prenotaPopup')){
			var myScrollTop = 0
			if (document.documentElement.scrollTop > 0){
				myScrollTop = document.documentElement.scrollTop;
			}else{
				myScrollTop = document.body.scrollTop;
			}

			$('prenotaPopup').style.top = ((((tellMeTheHeight() - $('prenotaPopup').getDimensions().height)/ 4) + myScrollTop)-300) + 'px';
			$('prenotaPopup').style.left = (((tellMeTheWidth() - $('prenotaPopup').getDimensions().width)/ 2)) + 'px';

		}
		
		
	}
	//---------------------------------------------------------------------------------------------
	
	function closeMyPrenota(){
		$('prenotaPopup').style.display ='none';
		$('IFprenotaPopup').src = '';
	}



	//***** FUNZIONI PER REPLACE TRACE DA REQUEST *************************************************
	
	function setParTraceFromRequest() { 
	
		var mediumReq = "";
		var sourceReq = "";
		var campaignReq = "";
		var SCHReq = "";
		var rep = false;
		
		var traceCMP;		
		var traceSource;
		var traceMedium;
		var traceCampaign;
		var traceSch;		
		//------
		var arrTracePar;
		
		//array con nome parametri trace
		arrTracePar = new Array();
		arrTracePar[0] = new Array('utm_source', '');
		arrTracePar[1] = new Array('utm_medium', '');
		arrTracePar[2] = new Array('utm_campaign', '');
		arrTracePar[3] = new Array('sch', '');		 		 		
		
	
	
		//verifico se in request presente almeno un parametro trace
		//se parametro presente salvo il valore in arrTracePar
		var query = window.location.search.substring(1); 
		var vars = query.split("&"); 
		for (var i=0;i<vars.length;i++) { 
			var pair = vars[i].split("=");
			for (var p=0;p<arrTracePar.length;p++) { 
				if (pair[0].toLowerCase()==arrTracePar[p][0]){
					arrTracePar[p][1] = pair[1];
					rep = true;					//almeno un par trace è presente in request
				}								
			}			
		} 
		
		//se almeno un parametro trace in request:
		//1.modifico tutti gli href del documento
		//2.modifico href del menu
		//3.modifico href serachbox
		if (rep){
			var url;
			var newUrl;		
			var arrLinkEl = document.getElementsByTagName("a");
			for (i=0; i < arrLinkEl.length ; i++  ) {
				//1.ciclo tutti href del documento
				url = arrLinkEl[i].getAttribute('href');
				if (url!=''){
					newUrl = replaceUrl(url, arrTracePar);					
					arrLinkEl[i].href = newUrl;
				}				
			}
			if (boxCerca){
				parTrace_searchbox = replaceUrl(parTrace_searchbox, arrTracePar);	
			}
			if (boxNL){
				parTrace_nl = replaceUrl(parTrace_nl, arrTracePar);	
			}
		}	
	} 



	function replaceUrl(url, arrTracePar){	
		var i;
		var pair;
		var newUrl;
		var c;
		var urlBase;				
		var urlParams;	
		var arrP;											
		var repStartChar;
		var foundT;
		var isTraceUrl;

		repStartChar = false;		
		isTraceUrl = false;		
		newUrl = '';
		if (url.substring(0,1)=='&'){	//per replace parTrace_menu...
			url = '?' + url.substring(1,url.length);
			repStartChar = true;
		}		
		if ((url.indexOf('?')==-1) ){// url senza parametri, non interessa
			return url;
		}
		urlBase = url.split("?")[0];				
		urlParams = url.split("?")[1];						
		newUrl = urlBase;		
		arrP = urlParams.split("&");										
		c = "?";
		for (i=0;i<arrP.length;i++) { 
			par = arrP[i].split("=");
			foundT = false;
			for (var p=0;p<arrTracePar.length;p++) { 
				if (par[0].toLowerCase()==arrTracePar[p][0]){					
					isTraceUrl = true;
					foundT = true;	
					if(arrTracePar[p][1]==''){									
						arrTracePar[p][1] = par[1];
					}
					if (p==3){
						//aggiungo il parametro al nuovo url solo se parametro SCH
						newUrl = newUrl + c + par[0] + '=' + arrTracePar[p][1];
						c = "&";						
					}
					break;			
				}
			}	
			if (!foundT){
				if ((par[0].toLowerCase()=='cmp')){				
					isTraceUrl = true;
				}else{
					newUrl = newUrl + c + par[0] + '=' + par[1];			
				}
			}
		}
		if (isTraceUrl){
			traceCMP = '';
			for (var p=0;p<arrTracePar.length;p++) { 
				if (p!=3){				//sch non deve essere aggiunto in CMP
					traceCMP = addTrace(traceCMP, arrTracePar[p][0], arrTracePar[p][1]);
				}
			}			
			newUrl = newUrl + c + 'CMP=' + traceCMP;
			//alert('CMP!');
			c = "&";
		}
		
		if (repStartChar){
			newUrl = '&' + newUrl.substring(1,newUrl.length);
		}		
		return(newUrl);								
	}



	function addTrace(CMP,namePar,valPar){
		if (valPar!=''){
			if (CMP == ''){
				CMP = '%3F' + namePar + '%3D'+valPar;
			}else{
				CMP = CMP + '%26'  + namePar + '%3D'+valPar;
			}
		}	
		return CMP;
	}


	//**********************************************************************************************	




	/****************************************************************************************/
	/** BOX NL**** **************************************************************************/
	/****************************************************************************************/

	function setBoxNL() {
		//=== bind button send NL ======					
		Event.observe('btnNL', 'click', function(event) {					
			iscriviNL(lang);
			return false;
		}); 		
			
		//=== bind submit NL  ======					
		Event.observe('formNl', 'submit', function(event) {		
			return Event.stop(event);        
			return false;
		}); 	
	}

	
	function iscriviNL(lang){
		var url = $("formNl").action + '?Email='+encodeURIComponent($("Email").value);
		if (parTrace_nl!=""){ 
			if (parTrace_nl.substring(0,1) == '?'){
				parTrace_nl = '&' + parTrace_nl.substring(1,parTrace_nl.length);
			}
			url = url + parTrace_nl;
		}	
				
		window.open(url);		
	}



	/****************************************************************************************/
	/** BOX RICERCA **************************************************************************/
	/****************************************************************************************/

	function setBoxCerca() {
	
		if (notti_search!=''){
			$('cP_default_numberOfNights').value = notti_search;
		}
		
		if (persone_search!=''){
			$('cP_default_room1_adults').value = persone_search;
		}
		
		if (bambini_search!=''){
			$('cP_default_room1_children').value = bambini_search;
		}
		
		$('cP_default_room1_age1').value = etaBimbi_1;
		$('cP_default_room1_age2').value = etaBimbi_2;
		$('cP_default_room1_age3').value = etaBimbi_3;
		$('cP_default_room1_age4').value = etaBimbi_4;
		
		cercaPrenota_restore_default_values();

		//observe dataFrom
		new Form.Element.Observer('cP_dateFrom',0.2,  
			function(el, value){		  	
				cercaPrenota_dateChanged(value);				
			}
		)

		//observe n° notti
		new Form.Element.Observer('cP_numberOfNights',0.2,
			function(el, value){
				cercaPrenota_nightsChanged(value);
			}
		)


		//observe adulti
		Event.observe('cP_room1_adults', 'change', function(event) {		
			showSubmitButton();
		}); 


		/*
		//observe n° alloggi
		new Form.Element.EventObserver('cP_rooms',
			function(el, value){		  	
				cercaPrenota_showRooms(value);
			}
		)
		*/
		

		//observe n° bambini
		new Form.Element.EventObserver('cP_room' + 1 + '_children',  
			function(el, value){		  						
				cercaPrenota_showChildrenAge(1, value);
			}
		)				
			
		
		//=== bind ok button ricerca ======					
		Event.observe('cP_submit', 'click', function(event) {		
			//cerca(lang);
			fSubmitRic();
			return false;
		}); 		
			
		//=== bind submit cerca ======					
		Event.observe('cP_form', 'submit', function(event) {		
			return Event.stop(event);        
			return false;
		}); 			
		
	}


	// *******************************************************************
	// Ripristino il valore di default. Serve per IE e il back del browser
	// che sovrascrive l'impostazione iniziale
	// *******************************************************************

	function cercaPrenota_restore_default_values(){
		// preparo gli oggetti
		var numberOfNights = $("cP_numberOfNights");
		var default_numberOfNights = $("cP_default_numberOfNights");
		
		var rooms = $("cP_rooms");
		var default_rooms = $("cP_default_rooms");
		
		var club = $("cP_club");
		var default_club = $("cP_default_club");
	
		var productTypes = new Array();
		var productTypesDefault = new Array()
		var adults = new Array();
		var adultsDefault = new Array();
		var children = new Array();
		var childrenDefault = new Array();
		var childrenAges = new Array();
		var childrenAgesDefault = new Array();
		for (var i = 1; i <= CERCA_PRENOTA_MAX_ROOMS; i++) {
			productTypes[i] = $("cP_room" + i + "_product_type");
			productTypesDefault[i] = $("cP_default_room" + i + "_product_type");
			
			adults[i] = $("cP_room" + i + "_adults");
			adultsDefault[i] = $("cP_default_room" + i + "_adults");
			
			children[i] = $("cP_room" + i + "_children");
			childrenDefault[i] = $("cP_default_room" + i + "_children");
			
			childrenAges[i] = new Array();
			childrenAgesDefault[i] = new Array();
			for (var j = 1; j <= CERCA_PRENOTA_MAX_CHILDREN; j++) {
				childrenAges[i][j] = $("cP_room" + i + "_age" + j);
				childrenAgesDefault[i][j] = $("cP_default_room" + i + "_age" + j);
			}
		}
		
		// aggiorno i valori
		numberOfNights.value = default_numberOfNights.value;
		rooms.value = default_rooms.value;
		if (club && default_club) {
			club.value = default_club.value;
		}
		
		for (var i = 1; i <= CERCA_PRENOTA_MAX_ROOMS; i++) {
			productTypes[i].value = productTypesDefault[i].value;
			adults[i].value = adultsDefault[i].value;
			children[i].value = childrenDefault[i].value;
			
			for (var j = 1; j <= CERCA_PRENOTA_MAX_CHILDREN; j++) {
				childrenAges[i][j].value = childrenAgesDefault[i][j].value;
			}
		}		
		
		// nascondo i campi non necessari
		var rooms = parseInt($('cP_default_rooms').value);
		cercaPrenota_showRooms(rooms);		
		
		
		//setto la data di arrivo e le notti
		caricaDate();	
	}

	
	
	// mostro i dati per le camere
	function cercaPrenota_showRooms(rooms) {
		
		var prefix = 'cP_room_row_';

		
		for (var i = 1; i <= CERCA_PRENOTA_MAX_ROOMS; i++) {
			var room = $(prefix + i);
			if (room) {
				
				if (i <= rooms) {
					room.style.display = '';	
					var children = $('cP_room' + i + '_children').value;
					cercaPrenota_showChildrenAge(i, children);
				} else {
					room.style.display = 'none';
					cercaPrenota_showChildrenAge(i, 0);
				}
			}
		}
	}


	// mostro i figli per una data camera
	function cercaPrenota_showChildrenAge(room, children) {
		var prefix = 'cP_child_row_';
		for (var i = 1; i <= CERCA_PRENOTA_MAX_CHILDREN; i++) {
			var child = $(prefix + room + '_' + i);
			
			if (child) {
				if (i <= children) {
					child.style.display = '';
				} else {
					child.style.display = 'none';
				}
			}
		}
		showSubmitButton();
	}


	function caricaDate(){			
		//* setto dataArrivo = oggi (oppure la data impostata dalla ricerca in elenco)
		if (data_search!=''){
			var my_date = new Date('20'+data_search.split("/")[2], (data_search.split("/")[1]-1), data_search.split("/")[0]);	
			
		}else{
			var my_date = new Date();
			my_date.setDate(my_date.getDate()+0);
		}
		
		$('cP_form').getInputs(null, 'dateFrom')[1].value =  formatData(my_date);

				
		//* setto dataPartenza = oggi +7
		my_date.setDate(my_date.getDate()+parseInt($('cP_default_numberOfNights').value));
		$("cP_endDate").innerHTML = formatData(my_date);
	}	



	function cercaPrenota_nightsChanged(notti){
		var strArrivo = $('cP_form').getInputs(null, 'dateFrom')[1].value;
		var dataPartenza = new Date('20'+strArrivo.split("/")[2], (strArrivo.split("/")[1]-1), strArrivo.split("/")[0]);	
		dataPartenza.setDate(dataPartenza.getDate()+parseInt(notti));
		
		$("cP_endDate").innerHTML = formatData(dataPartenza);
		
		showSubmitButton();
		
	}
	
	function cercaPrenota_dateChanged(strArrivo){
		var dataPartenza = new Date('20'+strArrivo.split("/")[2], (strArrivo.split("/")[1]-1), strArrivo.split("/")[0]);	
		dataPartenza.setDate(dataPartenza.getDate()+parseInt($('cP_numberOfNights').value));
		
		$("cP_endDate").innerHTML = formatData(dataPartenza);
		
		showSubmitButton();
		
	}	
			
	function formatData(data){
		var sGiorno = (data.getDate()<10) ? "0" + data.getDate().toString() : data.getDate().toString(); 
		var sMese = (data.getMonth()<9) ? "0" + (data.getMonth() + 1).toString() : (data.getMonth() + 1).toString();
		var sAnno = data.getFullYear().toString().substr(2);
		var fData = "".concat(sGiorno,"/",sMese,"/",sAnno); 
		return fData;	
	}
	
	
	
	
	function cerca(lang) {
		resettaNonVisibili()
		var rForm = $('cP_form');
		// data From ----------------------
		var dateFrom = $("cP_dateFrom").value;
		var elements = dateFrom.split('/');	dateFrom = elements[0] + '/' + elements[1] + '/20' + elements[2];		
		//compongo url form	---------------
		var url = "http://www.visittrentino.it/" + lang + "/dove_dormire/strutture/risultati?availability.dateFrom=" + dateFrom + "&availability.numberOfNights=" + $("cP_numberOfNights").value + "&availability.rooms=" + $("cP_rooms").value + "&destination=" + $("regionId").value + "&availability.club=" + $("cP_club").value + "&availability.accomodation=-1"  + "&availability.room_1.productType=" + $("cP_room1_product_type").value + "&availability.room_1.adults=" + $("cP_room1_adults").value + "&availability.room_1.children=" + $("cP_room1_children").value + "&availability.room_1.children.age_0=" + $("cP_room1_age1").value + "&availability.room_1.children.age_1=" + $("cP_room1_age2").value + "&availability.room_1.children.age_2=" + $("cP_room1_age3").value + "&availability.room_1.children.age_3=" + $("cP_room1_age4").value;
		if (parTrace_searchbox!=null)	url += parTrace_searchbox;
		window.open(url);
	}		
	

	function resettaNonVisibili(){	
		var vis;
		var productTypes = new Array();
		var productTypesDefault = new Array()
		var adults = new Array();
		var adultsDefault = new Array();
		var children = new Array();
		var childrenDefault = new Array();
		var childrenAges = new Array();
		var childrenAgesDefault = new Array();
		var nrBambini;
		
		var rooms = $("cP_rooms").value;

		for (var i = 1; i <= CERCA_PRENOTA_MAX_ROOMS; i++) {
			vis = true;
			if (parseInt(i)>parseInt(rooms)){
				vis = false;			
			}
									
			productTypes[i] = $("cP_room" + i + "_product_type");
			productTypesDefault[i] = $("cP_default_room" + i + "_product_type");			
			adults[i] = $("cP_room" + i + "_adults");
			adultsDefault[i] = $("cP_default_room" + i + "_adults");
			children[i] = $("cP_room" + i + "_children");
			childrenDefault[i] = $("cP_default_room" + i + "_children");
			if (!vis){
				productTypes[i].value = productTypesDefault[i].value;
				adults[i].value = adultsDefault[i].value;
				children[i].value = childrenDefault[i].value;	//nrBambini
				nrBambini = children[i].value
			}			
			
			childrenAges[i] = new Array();
			childrenAgesDefault[i] = new Array();
			// ciclo select età bambini
			for (var j = 1; j <= CERCA_PRENOTA_MAX_CHILDREN; j++) {
				childrenAges[i][j] = $("cP_room" + i + "_age" + j);
				childrenAgesDefault[i][j] = $("cP_default_room" + i + "_age" + j);
				if (parseInt(j)>parseInt(children[i].value)){
					childrenAges[i][j].value = childrenAgesDefault[i][j].value;
				}
			}
			
		}		
	}
	
	
		

	/****************************************************************************************/
	/** ALTRE **************************************************************************/
	/****************************************************************************************/	
	
	function openHome(){
		if (urlHome!="") window.open(urlHome);		
	}
	
	
	
	/***************************************************************************************/
	/* RICERCA (ISITE) *********************************************************************/
	/***************************************************************************************/
	
	function fSubmitRic()
	{
		var objForm
		var objFormfFiltri
		var StrParTypeStr
		var Url
		var check
		var idClubVal
		var ageBambini = '';
		
		if (!IE7) {
			//openPopupPrenota('','PRE',720,500);
		}

		objForm = document.getElementById("cP_form");
		objFormfFiltri = document.getElementById("fFiltri");
		
		if (objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value > 0) {
			for (var i = 1;i<=objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value;i++){
				ageBambini += eval('objForm.cP_room1_age'+i+'[objForm.cP_room1_age'+i+'.selectedIndex]').value + ';'
			}
			ageBambini = ageBambini.substring(0,ageBambini.length-1);
		}else{
			ageBambini = '';
		}

		var dateFrom = $("cP_dateFrom").value;
		var elements = dateFrom.split('/');	dateFrom = elements[0] + '/' + elements[1] + '/20' + elements[2];		

		Url = "/cms-01.00/lib/Obj/getDisponibilita.asp?IDcms="+ objForm.idcms.value +"&IDLocalita=0&Data=" + objForm.cP_dateFrom.value + "&nNotti=" + objForm.cP_numberOfNights[objForm.cP_numberOfNights.selectedIndex].value + "&nPersone=" + objForm.cP_room1_adults[objForm.cP_room1_adults.selectedIndex].value+ "&nBambini=" + objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value+'&ageB='+ageBambini + '&scheda=1&sty='+styleCSS;
		//window.open(Url);
		//return;
		//showWait();
		$('WtextRic').innerHTML = "<img src='/st179/images/loaderBox"+styleCSS+".gif'>Searching..."
		
		//fSubmitPrenota();
		//NB: 10 gennaio 2012 >> commentato "fSubmitPrenota()" e messa nuovamente la chiamata ajax (mail angelini su popup feratel)
		
		hideLoadinRic();
		
		new Ajax.Request(Url,
		{
						evalScripts: true,
						onComplete: function(requester){
									if ((requester.responseText == 'no price') || ((requester.responseText == '0')) || (requester.responseText == 'Non disponibile')){
										buildInfoButton();
									}else{
										//buildPrenotaButton();
										fSubmitPrenota();
									}
									
						}
		});
		
	}
	
	
	function showLoadinRic(){
		$('LoadingRic').style.display = 'block';
	}
	
	
	function hideLoadinRic(){
		$('LoadingRic').style.display = 'none';
	}
	
	
	
	function buildPrenotaButton(){
		var myButton;
		fSubmitPrenota();

	}
	
	
	function buildInfoButton(){
		var myButton;
		var myLink = '';
		if ($('ContButtonInfo')){
			myLink =  $('ContButtonInfo').down('a');
			//if(myLink == null)myLink = $('ContButtonInfo').readAttribute('InfoUrl2');
			myLink = $('ContButtonInfo').readAttribute('InfoUrl2');
		}
		$('ContNoPriceLink').innerHTML = myLink;
		if (!IE7) {
			//openPopupPrenota(pageTracker._getLinkerUrl(myLink.toString()), 'PRENOTA', 720, 500);
			openPopupPrenota(myLink.toString(), 'PRENOTA', 720, 500);
		}else{
			//openPopupPrenota(pageTracker._getLinkerUrl(myLink.toString()), 'PRENOTA', 720, 500);
			openPopupPrenota(myLink.toString(), 'PRENOTA', 720, 500);
		}
	}
	
	function linkInfoButton(){
	var myPage = $('ContNoPriceLink').innerHTML;
		myPage = myPage.replace(/&amp;/g,'&');
		//openPopup(myPage, 'INFO E PRENOTA', 720, 500);
		window.open(pageTracker._getLinkerUrl(myPage),'INFO E PRENOTA','width=720,height=500');
	}
	
	
	function showSubmitButton(){
		if (!thisIsFirstLoad){
			$('prezzoDispo').innerHTML ='';
		}
		thisIsFirstLoad = false;
	}
	
	
	
	function fSubmitPrenota()
	{
		var objForm
		var objFormfFiltri
		var StrParTypeStr
		var Url
		var check
		var idClubVal
		var ageBambini = '';

		objForm = document.getElementById("cP_form");
		objFormfFiltri = document.getElementById("fFiltri");
		
		var arrAge = objForm.cP_room1_age1[objForm.cP_room1_age1.selectedIndex].value+';'+objForm.cP_room1_age2[objForm.cP_room1_age2.selectedIndex].value+';'+objForm.cP_room1_age3[objForm.cP_room1_age3.selectedIndex].value+';'+objForm.cP_room1_age4[objForm.cP_room1_age4.selectedIndex].value;
		arrAge = arrAge.split(";")
		
		if (objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value > 0){
			for(var i=0;i<objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value;i++){
				if (i == (objForm.cP_room1_children[objForm.cP_room1_children.selectedIndex].value-1)){
					ageBambini = ageBambini + '' + arrAge[i];
				}else{
					ageBambini = ageBambini + '' + arrAge[i] + ',';
				}
			}
		}else{
			ageBambini = '';
		}
		

		var dateFrom = $("cP_dateFrom").value;
		var elements = dateFrom.split('/');	dateFrom = elements[0] + '/' + elements[1] + '/20' + elements[2];
		
		Url = "http://web.deskline.net/trentino/" + lang + "/book_accommodation/trn/"+Feratel+"/?PF=products&CS=white&blkArrivalDate=20"+elements[2]+''+elements[1]+''+elements[0]+"&blkNights="+objForm.cP_numberOfNights[objForm.cP_numberOfNights.selectedIndex].value+"&blkAdults="+objForm.cP_room1_adults[objForm.cP_room1_adults.selectedIndex].value+"&blkChildren="+ageBambini+"&blkMeal=&blkProductID=&CLR_CART=true&AspxAutoDetectCookieSupport=1";
		if (!IE7) {
			//addressMyPopup.location = pageTracker._getLinkerUrl(Url);
			//openPopupPrenota(pageTracker._getLinkerUrl(Url), 'PRENOTA', 720, 500);
			openPopupPrenota(Url, 'PRENOTA', 720, 500);
		}else{
			//openPopupPrenota(pageTracker._getLinkerUrl(Url), 'PRENOTA', 720, 500);
			openPopupPrenota(Url, 'PRENOTA', 720, 500);
		}
		//openPopup(Url, 'PRENOTA', 720, 500);

	}
	
	
	
	
	function openPopupPrenota(f,titolo,d,a){
		if(!window.focus){
			return true
		}
		var b;
		if(typeof(f)=="string"){
			b=f
		}else{
			b=f.href
		}

		var c="width="+d+",height="+a+",scrollbars=yes";
		var LangNumber

	
		if (lang == ''){
			lang =  'IT';
			LangNumber = '1'
		}
		
		if (lang.toLowerCase() == 'it'){
			LangNumber = '1';
		}else if (lang.toLowerCase() == 'en'){
			LangNumber = '2';
		}else if (lang.toLowerCase() == 'de'){
			LangNumber = '3';
		}else{
			LangNumber = '2';
		}
		
		
		b = b.replace(/\/IT\//i,'/'+lang.toLowerCase()+'/');
		b = b.replace(/l=1/i,'l='+LangNumber);
		b = b.replace(/IDF=20/i,'IDF=23');
		b = b.replace(/IDl=1/i,'IDl='+LangNumber);
		b = b.replace(/IDl=2/i,'IDl='+LangNumber);
		b = b.replace(/IDl=3/i,'IDl='+LangNumber);
		
		//addressMyPopup = window.open(b, '', c);
		if ($('prenotaPopup')){
			$('prenotaPopup').style.width = (d+20) + 'px';
			$('prenotaPopup').style.height = a + 'px';
			
			$('IFprenotaPopup').style.width = (d) + 'px';
			$('IFprenotaPopup').style.height = a + 'px';
			$('IFprenotaPopup').src = b;
			$('IFprenotaPopup').scrolling = 'auto';
			
			$('prenotaPopup').style.display = 'block';
		
		}else{
			window.open(b, '', c);
		}

		return false;
	};

	
	
//SCROLL POPUP DIV
window.onscroll = function()
{
	var myScrollTop = 0
	if (document.documentElement.scrollTop > 0){
		myScrollTop = document.documentElement.scrollTop;
	}else{
		myScrollTop = document.body.scrollTop;
	}
	
	//Scroll su box video
	if ($('prenotaPopup')){
		if ($('prenotaPopup').style.display != 'null'){
			if ($('prenotaPopup')){
				$('prenotaPopup').style.top = ((((tellMeTheHeight() - $('prenotaPopup').getDimensions().height)/ 4) + myScrollTop)-300) + 'px';
				$('prenotaPopup').style.left = (((tellMeTheWidth() - $('prenotaPopup').getDimensions().width)/ 2)) + 'px';
			}
		}
	}
	
}


//HEIGHT WINDOW
function tellMeTheHeight() {
        w = window;
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return height
}

//WIDTH WINDOW
function tellMeTheWidth() {
        w = window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        return width
}

////////////////////////////////////////////////////





