/*
//Caricamento dei searchbox nelle homepage delle sezioni
function loadMenu(id,sez)
{
	tab_name = new Array();
	tab_name['hp'] = "motore";
	tab_name['vacanze'] = "vacanza";
	tab_name['voli'] = "voli";
	tab_name['hotel'] = "hotel";
	
	path_name = new Array();
	path_name['hp'] = "motori/home/";
	path_name['vacanze'] = "vacanza/motore/tabs/";
	path_name['voli'] = "voli/motore/tabs/";
	path_name['hotel'] = "hotel/motore/tabs/";
		
	for(i=1; i<6; i++)
	{
	   if(i == 5)	//tab my_tour
	   	 eval('document.images.menu'+i+'.src = "images/graphics/motori/home/motore_off_05.gif"');		
	   else
	   	 eval('document.images.menu'+i+'.src = "images/graphics/'+path_name[sez]+tab_name[sez]+'_off_0'+i+'.gif"');
	}
	
	if(id == 5)	//tab my_tour
	  eval('document.images.menu'+id+'.src = "images/graphics/motori/home/motore_on_05.gif"');
	else
	  eval('document.images.menu'+id+'.src = "images/graphics/'+path_name[sez]+tab_name[sez]+'_on_0'+id+'.gif"');

	x_loadMenu(id,sez,writeMenu);
}
*/
//Caricamento dei searchbox nelle homepage delle sezioni
function loadMenu(id,sez)
{	
			
	tab_name = new Array();
	tab_name['hp'] = "motore";
	tab_name['vacanze'] = "vacanza";
	tab_name['voli'] = "voli";
	tab_name['hotel'] = "hotel";
	
	path_name = new Array();
	path_name['hp'] = "motori/home/";
	path_name['vacanze'] = "vacanza/motore/tabs/";
	path_name['voli'] = "voli/motore/tabs/";
	path_name['hotel'] = "hotel/motore/tabs/";
		
	
	
	//questo array conterrà i path dei css per il calendario
	path_cal_css = new Array();
	path_cal_css[1] = "cal_dest_vacanza.css";				//vacanze
	path_cal_css[2] = "cal_dest_volo.css"; 		//voli
	path_cal_css[3] = "cal_dest_hotel.css";			//hotel
	path_cal_css[4] = "cal_dest_vacanza.css";			//hotel+voli
				
	for(i=1; i<6; i++)
	{
	   if(i == 5)	//tab my_tour
	   	 eval('document.images.menu'+i+'.src = "images/graphics/motori/home/motore_off_05.gif"');		
	   else
	   	 eval('document.images.menu'+i+'.src = "images/graphics/'+path_name[sez]+tab_name[sez]+'_off_0'+i+'.gif"');
	}
	
	if(id == 5)	//tab my_tour
	  eval('document.images.menu'+id+'.src = "images/graphics/motori/home/motore_on_05.gif"');	
	else
	  eval('document.images.menu'+id+'.src = "images/graphics/'+path_name[sez]+tab_name[sez]+'_on_0'+id+'.gif"');

	for(i=1; i<6; i++)
			document.getElementById('menuSez'+i).style.display = (i == id) ? "block" : "none";
				
			
	/*
	if(id != 4)
	{
		//se dalla home page seleziono il box voli, devo cambiare anche il numero di telefono da 
		//visualizzare nella colonna di sx
		if(id == 2 && sez == "hp")
		{
			document.getElementById('sp_info').style.display = "none";
			document.getElementById('sp_info_voli').style.display = "block";
		}
		else		
		 if(id != 2 && sez == "hp")
			{
				document.getElementById('sp_info').style.display = "block";
				document.getElementById('sp_info_voli').style.display = "none";
			}	 	
	}

	
	if(id == 4 && sez == "voli")
	{
		document.getElementById('sp_info').style.display = "block";
		document.getElementById('sp_info_voli').style.display = "none";
	}		
	
		
	//Questo if serve per cambiare il css al calendario per il box dell'home-page,
	//altrimenti rimarrebbe sempre quello delle vacanze ( primo tab aperto in home )	
	if(sez == "hp")	
	{
		var cells = document.getElementsByTagName("link"); 
		for (var i = 0; i < cells.length; i++) 
		{ 
		    str = cells[i].getAttribute("href"); 		    
		    if(str.indexOf("cal_dest") != -1 )
		    {
		    	//alert('gggggggggggggg'+path_cal_css[id])
		    	cells[i].href = 'http://saturno6/lmt6/style/'+path_cal_css[id];		    
		    }
		}
	}//fine 
	*/
	
	
	if(sez == "hp")	
	{
		//document.getElementById('id_calendar_css').href = '/style/'+path_cal_css[id];
		var i, a, main;
		  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
		  {
		    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
		      a.disabled = true;
		      if(a.getAttribute("title")+".css" == path_cal_css[id]) a.disabled = false;
		    }
		  }
	}
		
}//fine function loadMenu(id,sez)



//Scrive i searchbox nelle homepage delle sezioni
function writeMenu(ris)
{
  document.getElementById('menuContent').innerHTML = ris;
}

//Redireziona alla pagina desiderata
function redirect(url)
{
	if(url != "")
	  location.href = url;
}


//visualizza o nasconde un div
//NB bisogna sapere a priori lo stato del div.
//Una funzione simile è quella sotto DisplayContent che 
//visualizza un div se è nascosto e lo nasconde se è visualizzato
function DisplayTag(tagID,display)
{
	document.getElementById(tagID).style.display = display;
}


//questa funzione visualizza un div se è nascosto e lo nasconde se è visualizzato
function DisplayContent(tagID)
{	
	if(document.getElementById(tagID).style.display == 'block')
		document.getElementById(tagID).style.display = 'none';
	else
		document.getElementById(tagID).style.display = 'block';	
		
	//document.getElementById(tagID).focus();	
}

//Passando il form di riferimento e il nome del campo svuota il menu a tendina
function delSelect(form,name)
{
	eval("obj = document.forms['"+form+"']."+name+";");
	for(indice_del=obj.length; indice_del>=0; indice_del--)
		obj.options[indice_del] = null;	
}

//Passando il form di riferimento e il nome del campo svuota il menu a tendina
function delSelectID(id)
{
	obj = document.getElementById(id);
	for(indice_del=obj.length; indice_del>=0; indice_del--)
		obj.options[indice_del] = null;	
}

//Gli passo il nome di un form e il nome di un campo (radio) e restituisco il valore selezionato
function ValueRadioChecked(form,name)
{
	eval('var obj = document.forms["'+form+'"].'+name+';');

	for(y=0; y<obj.length; y++)
	{
		if(obj[y].checked)
			return obj[y].value;
	}
}

//passando tipo,nome e valore restituisco un oggetto input
function CreateTagFormPrintContract(type,name,value)
{
	var input = document.createElement("input");
	input.type = type;
	input.name = name;
	input.value = value;
	
	return input;
}


//Controlla che siano stati inseriti tutti i dati obbligatori prima della stampa del contratto
function ControlContractBookingLmt(form)
{
	dati_obbl_contraente = new Array('nome','cognome','data_nascita','telefono','cellulare','email');
	//dati_obbl_pax = new Array('nome','cognome','data_nascita','sesso','indirizzo','cap','citta','provincia','nazione');
	dati_obbl_pax = new Array('nome','cognome','data_nascita','cellulare');
	
	f = document.forms[form];
	
	var pax = f.pax.value;
	
	for(i=0; i<pax; i++)
	{
		dati_obbl = (i == 0) ? dati_obbl_contraente : dati_obbl_pax;
		for(y=0; y<dati_obbl.length; y++)
		{
			if(eval("f."+dati_obbl[y]+i+".value") == "")
				return false;
		}
	}
	
	return true;
}

//Costruisco e invio il form dei dati per la stampa del contratto
function OpenContractBookingLmt(form)
{
	if(!ControlContractBookingLmt(form))
	{
		alert("Inserire tutti i dati obbligatori");
		return false;
	}
	
	
	f = document.forms['formStampaContratto'];
	
	var pagamento = ValueRadioChecked(form,'pagamento');
	f.appendChild(CreateTagFormPrintContract('hidden','pagamento',pagamento));
	var fpagamento1 = pagamento;
	f.appendChild(CreateTagFormPrintContract('hidden','fpagamento1',fpagamento1));
	var contatto = ValueRadioChecked(form,'contatto');
	f.appendChild(CreateTagFormPrintContract('hidden','contatto',contatto));
	var voucher = ValueRadioChecked(form,'voucher');
	f.appendChild(CreateTagFormPrintContract('hidden','voucher',voucher));
	var privacy = ValueRadioChecked(form,'privacy');
	f.appendChild(CreateTagFormPrintContract('hidden','privacy',privacy));
	contatto = (contatto == 1) ? contatto+"::"+document.forms[form].contatto_email.value : contatto+"::"+document.forms[form].contatto_telefono.value;
	f.appendChild(CreateTagFormPrintContract('hidden','contatti',contatto));
	voucher = (voucher == 1) ? voucher+"::"+document.forms[form].voucher_email.value : voucher+"::"+document.forms[form].voucher_telefono.value;
	f.appendChild(CreateTagFormPrintContract('hidden','voucher',voucher));
	
	var min_partecipanti = document.forms['formPrenotazione'].minimo_partecipanti.value;
	f.appendChild(CreateTagFormPrintContract('hidden','minimo_partecipanti',min_partecipanti));
	var tempo = document.forms['formPrenotazione'].tempo.value;
	f.appendChild(CreateTagFormPrintContract('hidden','tempo',tempo));
	var precisazione_tempo = document.forms['formPrenotazione'].precisazione_tempo.value;
	f.appendChild(CreateTagFormPrintContract('hidden','precisazione_tempo',precisazione_tempo));

	var pax = document.forms[form].pax.value;
	for(i=0; i<pax; i++)
	{
		f.appendChild(CreateTagFormPrintContract('hidden','nome_'+(i+1),eval("document.forms['"+form+"'].nome"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','cognome_'+(i+1),eval("document.forms['"+form+"'].cognome"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','data_di_nascita_'+(i+1),eval("document.forms['"+form+"'].data_nascita"+i+".value")));
/*		
		f.appendChild(CreateTagFormPrintContract('hidden','sesso_'+(i+1),ValueRadioChecked(form,'sesso'+i)));
		f.appendChild(CreateTagFormPrintContract('hidden','indirizzo_'+(i+1),eval("document.forms['"+form+"'].indirizzo"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','cap_'+(i+1),eval("document.forms['"+form+"'].cap"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','citta_'+(i+1),eval("document.forms['"+form+"'].citta"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','provincia_'+(i+1),eval("document.forms['"+form+"'].provincia"+i+".value")));
		f.appendChild(CreateTagFormPrintContract('hidden','nazione_'+(i+1),eval("document.forms['"+form+"'].nazione"+i+".value")));
*/		
		if(i == 0)
		{
			f.appendChild(CreateTagFormPrintContract('hidden','tel_'+(i+1),eval("document.forms['"+form+"'].telefono"+i+".value")));
			f.appendChild(CreateTagFormPrintContract('hidden','tel2_'+(i+1),eval("document.forms['"+form+"'].cellulare"+i+".value")));
			f.appendChild(CreateTagFormPrintContract('hidden','email_'+(i+1),eval("document.forms['"+form+"'].email"+i+".value")));
		}
	}
	f.submit();
}


/**********************************MENU A TENDINA VOLI LAST MINUTE********************************/

var status = "close";
var canClose = false;

//visualizza il menu a tendina delle destinazioni dei voli last minute
function actionList(action,lista)
{
	
	document.getElementById('list_int_dest').style.display = "none";
	if((action == "open") && (status == "open"))
	{
		action = "close";
		document.getElementById('layerdata_da').style.display = "inline";
		document.getElementById('layerdata_a').style.display = "inline";
	}
	if(action == "open") { 
		document.getElementById('list_'+lista+'_dest').style.display = "inline";
		document.getElementById('layerdata_da').style.display = "none";
		document.getElementById('layerdata_a').style.display = "none";
		canClose = false; 
	}
	status = action;	
}

//chiude il menu a tendina dei voli last minute
function closeList(e)
{
	if((status == "open") && (canClose == true))
	{
		document.getElementById('list_int_dest').style.display = "none";
		document.getElementById('layerdata_da').style.display = "inline";
		document.getElementById('layerdata_a').style.display = "inline";
		status = "close";
	}
	canClose = true;
}

function InsertValueInField(value,IdInputText,IdInputHidden,divName)
{	
	temp = value.split("|");
	
	document.getElementById(IdInputText).value = temp[1];
	
	if(IdInputHidden != "")
		document.getElementById(IdInputHidden).value = value;
	
	hideDestinations(divName);
}

document.onclick = closeList;
/**********************************MENU A TENDINA********************************/




/******************************   DETTAGLIO VACANZE   ***********************************/
//Questa funzione verrà richiamata nella pagina dett_vacanze quando, una volta visualizzate
//3 foto, 1 grande e due piccole, cliccando su quella piccola, questa dovrà essere
//visualizzata nel box grande e quella grande prenderà il posto di quella piccola
function ChangeImg(obj)
{
	//recupero l'immagine grande
	var img_big = document.getElementById('dett_vacanza_img_big').src;
	//recupero il path della foto piccola
	
	document.getElementById('dett_vacanza_img_big').src = obj.src.replace("/medium/", "/huge/");
	obj.src = img_big.replace("/huge/", "/medium/");
		

	
	/*
	//recupero l'immagine grande
	var img_big = document.getElementById('dett_vacanza_img_big').src;
	//recupero il path della foto piccola
	img_big = img_big.replace("/large/", "/small/");
	
	//visualizzo la foto piccola nello spazio grande
	document.getElementById('dett_vacanza_img_big').src = "";
	document.getElementById('dett_vacanza_img_big').src = path_img;
	
	//visualizzo l'immagine che prima era grande, nel box piccolo	
	var ind = 'dett_vacanza_img_small_'+pos;
	document.getElementById(ind).src = "";
	document.getElementById(ind).src = img_big;
	*/
}


//Questa funzione è utilizzata nel menu di sx delle ricerca vacanze
//Nel caso in cui si stata fatta un ricerca per tag tematici, farà scegliere se rifare la ricerca passando come
//parametro un tag o una destinazione
function sceltaDestTem(obj)
{
	formName = obj.form.name;
	if(obj.value == "dest")
	{
		document.forms[formName].destinazione.disabled = false;
		document.forms[formName].tag.disabled = true;
	}
	else
	{
		document.forms[formName].destinazione.disabled = true;
		document.forms[formName].tag.disabled = false;
	}
}

//Questa funzione è usata nella pagina di dettaglio vacanze e crea l'html per l'invio della richiesta extra
function sceltaRichiesteExtra(obj)
{
	var num_pax = 0;
	var show_price = true;
	var valore1 = "";
	var valore2 = "";	
	for (i=0; i < document.forms['richieste_particolari'].extra0.length; i++) 
	{ 
		obj = document.forms['richieste_particolari'].extra0[i];
		if (obj.checked == true) 
		{ 
			if(obj.value == "singola")
				num_pax = valore2 = valore1 = '1';
			if(obj.value == "tripla")
				num_pax = valore2 = valore1 = '3';
			if(obj.value == "doppia_bambino")
				num_pax = valore2 = valore1 = '3';
			if(obj.value == "quadrupla_bambino")
				num_pax = valore2 = valore1 = '4';
				
			document.forms['formPax1'].extra0.value = obj.value;
			document.forms['formPax2'].extra0.value = obj.value;				
		} 
	}
	
	if(num_pax == 0)
	{
		num_pax = (num_min_pax) ? num_min_pax : "2";
		valore1 = '<input name="pax" id="pax1" type="text" class="form_label" size="15" value="'+num_pax+'" />';
		valore2 = '<input name="pax" id="pax2" type="text" class="form_label" size="15" value="'+num_pax+'" />';
		show_price = true;		
	}
	else
	  show_price = false;
	
	document.getElementById('contentFormPax1').innerHTML = valore1;
	document.getElementById('contentFormPax2').innerHTML = valore2;	
	
	if(document.getElementById('extra_1').checked == true)
	{
		document.forms['formPax1'].extra1.value = document.getElementById('extra_1').value;
		document.forms['formPax2'].extra1.value = document.getElementById('extra_1').value;	
		show_price = false;
	}
	else
	{
		document.forms['formPax1'].extra1.value = "";
		document.forms['formPax2'].extra1.value = "";	
	}
	  
	  
	if(show_price == false)
	{
		document.getElementById('box_prezzo').style.display = "none";
		document.getElementById('dicitura_prezzo').style.display = "none";
		document.getElementById('dicitura_tasse1').style.display = "none";
		document.getElementById('dicitura_richieste_extra').style.display = "";
	}
	else
	{
		document.getElementById('box_prezzo').style.display = "";
		document.getElementById('dicitura_prezzo').style.display = "";
		document.getElementById('dicitura_tasse1').style.display = "";
		document.getElementById('dicitura_richieste_extra').style.display = "none";			
	}
}

/******************************   DETTAGLIO VACANZE   ***********************************/

var config_calendari = new Array();
config_calendari[0] = new Array('data_da','data_a');
config_calendari[1] = new Array('date_checkin','date_checkout');
config_calendari[2] = new Array('andata','ritorno');
config_calendari[3] = new Array('andata_voli_voli','ritorno_voli_voli');
config_calendari[4] = new Array('andata_voli_lowcost','ritorno_voli_lowcost');
config_calendari[5] = new Array('andata_voli_bestprice','ritorno_voli_bestprice');
config_calendari[6] = new Array('data_daData','data_aData');
config_calendari[7] = new Array('data_daPrezzo','data_aPrezzo');
config_calendari[8] = new Array('data_daRisultati','data_aRisultati');

function disabilitaDateDa(date,y,m,d,divName) {
	
	var calName = "";
	for(i=0; i<config_calendari.length; i++)
	{
		if(config_calendari[i][1] == divName)
			calName = config_calendari[i][0];
	}
	
	try
	{
	    fromDate = new Date( 
	            document.getElementById(calName).value.substr( 6 ),
	            document.getElementById(calName).value.substr( 3, 2 ) - 1,
	            document.getElementById(calName).value.substr( 0, 2 ) 
	    );
	}
	catch(e)
	{
		alert(e+" => "+calName+" => "+divName);
	}

        
    if( date.getYear() < fromDate.getYear() ||
        date.getYear() == fromDate.getYear() && date.getMonth() < fromDate.getMonth() ||
        date.getYear() == fromDate.getYear() && date.getMonth() == fromDate.getMonth() && date.getDate() < fromDate.getDate() )
        return true;
          
    return false;
}

var calNameGlobal;
//passando una data di inizio la copia nel box di ritorno
function reloadData(date)
{
	divName = date.nameDivBase;
	var calName = "";
	for(i=0; i<config_calendari.length; i++)
	{
		if(config_calendari[i][0] == divName)
			calName = config_calendari[i][1];
	}	
	
	calNameGlobal = calName;
	var p = date.params;
	date.hide();
	
	x_SumMonth(date.date.print(p.ifFormat),writeReloadData);
}

function reloadDataVoli(date)
{
	divName = date.nameDivBase;
	var calName = "";
	for(i=0; i<config_calendari.length; i++)
	{
		if(config_calendari[i][0] == divName)
			calName = config_calendari[i][1];
	}	
	
	var p = date.params;
	date.hide();
		
	document.getElementById(calName).value = date.date.print(p.ifFormat);
}


function writeReloadData(data)
{
	if(document.getElementById(calNameGlobal))
	  document.getElementById(calNameGlobal).value = data;
}


/******************************************************************************************************************/

var destinazioneForm;
var localitaForm;
var labelForm;
//var data_daForm;
//var data_aForm;
var prezzoForm;
var prezzo_daForm;
var prezzo_aForm;
var aeroportoForm;
var tipoForm;
var durataForm;
var minpaxForm;


var campoLaunchRq;
var sezioneLaunchRq;


function launchReloadBoxVacanze(field,type)
{
	
	campoLaunchRq = field;
	sezioneLaunchRq = type;	
	
	destinazioneSend = destinazioneForm = (document.getElementById('destinazione'+sezioneLaunchRq)) ? document.getElementById('destinazione'+sezioneLaunchRq).value : '';
	localitaSend = localitaForm = (document.getElementById('localita'+sezioneLaunchRq)) ? document.getElementById('localita'+sezioneLaunchRq).value : '';
	labelSend = labelForm = (document.getElementById('label'+sezioneLaunchRq)) ? document.getElementById('label'+sezioneLaunchRq).value : '';
	tagSend = tagForm = (document.getElementById('tag'+sezioneLaunchRq)) ? document.getElementById('tag'+sezioneLaunchRq).value : '';
	//data_da = (document.getElementById('data_da'+sezioneLaunchRq)) ? document.getElementById('data_da'+sezioneLaunchRq).value : '';
	//data_a = (document.getElementById('data_a'+sezioneLaunchRq)) ? document.getElementById('data_a'+sezioneLaunchRq).value : '';
	//prezzoForm = (document.getElementById('prezzo'+sezioneLaunchRq)) ? document.getElementById('prezzo'+sezioneLaunchRq).value : '';
	prezzo_daSend = prezzo_daForm = (document.getElementById('prezzo_da'+sezioneLaunchRq)) ? document.getElementById('prezzo_da'+sezioneLaunchRq).value : '';
	prezzo_aSend = prezzo_aForm = (document.getElementById('prezzo_a'+sezioneLaunchRq)) ? document.getElementById('prezzo_a'+sezioneLaunchRq).value : '';
	aeroportoSend = aeroportoForm = (document.getElementById('aeroporto'+sezioneLaunchRq)) ? document.getElementById('aeroporto'+sezioneLaunchRq).value : '';
	tipoSend = tipoForm = (document.getElementById('tipo'+sezioneLaunchRq)) ? document.getElementById('tipo'+sezioneLaunchRq).value : '';	
	durataSend = durataForm = (document.getElementById('durata'+sezioneLaunchRq)) ? document.getElementById('durata'+sezioneLaunchRq).value : '';
	minpaxSend = minpaxForm = (document.getElementById('minpax'+sezioneLaunchRq)) ? document.getElementById('minpax'+sezioneLaunchRq).value : '';

	
	
	//if(document.getElementById('label'+sezioneLaunchRq))
	  //document.getElementById('label'+sezioneLaunchRq).disabled = true;
	//if(document.getElementById('tag'+sezioneLaunchRq))
	  //document.getElementById('tag'+sezioneLaunchRq).disabled = true;	  
  	//if(document.getElementById('data_da'+sezioneLaunchRq))
  	  //document.getElementById('data_da'+sezioneLaunchRq).disabled = true;
  	//if(document.getElementById('data_a'+sezioneLaunchRq))
  	  //document.getElementById('data_a'+sezioneLaunchRq).disabled = true;
  	//if(document.getElementById('prezzo'+sezioneLaunchRq))
  	  //document.getElementById('prezzo'+sezioneLaunchRq).disabled = true;
    if(document.getElementById('prezzo_da'+sezioneLaunchRq))
      document.getElementById('prezzo_da'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('prezzo_a'+sezioneLaunchRq))
  	  document.getElementById('prezzo_a'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('aeroporto'+sezioneLaunchRq))
  	  document.getElementById('aeroporto'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('tipo'+sezioneLaunchRq))
  	  document.getElementById('tipo'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('durata'+sezioneLaunchRq))
  	  document.getElementById('durata'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('minpax'+sezioneLaunchRq))	
  	  document.getElementById('minpax'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('button'+sezioneLaunchRq))	
  	  document.getElementById('button'+sezioneLaunchRq).disabled = true;  	  
  	

  	 if(campoLaunchRq == 'destinazione' && sezioneLaunchRq == 'Risultati')
	   tagSend = prezzo_daSend = prezzo_aSend = aeroportoSend = tipoSend = durataSend = minpaxSend = "";
	//document.getElementById('dettaglio_risultati').innerHTML = "Caricamento...";
	
	//document.getElementById('dettaglio_risultati'+sezioneLaunchRq).innerHTML = '<img src="/images/graphics/loading/loader.gif" alt="Caricamento..." />';
	
	//alert(destinazioneSend+","+localitaSend+","+tagSend+","+prezzo_daSend+","+prezzo_aSend+","+aeroportoSend+","+tipoSend+","+durataSend+","+minpaxSend+","+type);
  	//x_ReloadBoxVacanze(destinazioneSend,localitaSend,tagSend,prezzo_daSend,prezzo_aSend,aeroportoSend,tipoSend,durataSend,minpaxSend,type,"",compileBoxVacanze);
}

function compileBoxVacanze(ris)
{
	//document.getElementById('prova').innerHTML = ris;
	
	//alert(campoLaunchRq);
	var field;
	field = ris.split(";;");
	
	for(i=0; i<field.length; i++)
	{
		temp_field = field[i].split("==");
		field_name = temp_field[0];

		//alert(field_name);
		
		
		if(field_name == "prezzo" && campoLaunchRq != "prezzo" && document.getElementById('prezzo_da'+sezioneLaunchRq) && document.getElementById('prezzo_a'+sezioneLaunchRq))
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			  
			delSelectID("prezzo_da"+sezioneLaunchRq);
			delSelectID("prezzo_a"+sezioneLaunchRq);

			opzione = new Option("- Seleziona -","");
			document.getElementById('prezzo_da'+sezioneLaunchRq).options[0] = opzione;			
			
			opzione = new Option("- Tutti -","");
			document.getElementById('prezzo_a'+sezioneLaunchRq).options[0] = opzione;
			
			ind1 = 1;
			ind2 = 1;
			for(y=0; y<temp_value_field.length; y++)
			{
				temp_value = temp_value_field[y].split("_");
				
				if(temp_value[0] != "")
				{
					opzione = new Option(temp_value[0],temp_value[0]);
					document.getElementById('prezzo_da'+sezioneLaunchRq).options[ind1] = opzione;
				
					if(prezzo_daForm == temp_value[0])
					  document.getElementById('prezzo_da'+sezioneLaunchRq).options[ind1].selected = true;
					  
					ind1++;
				}
				  
				if(temp_value[1] != "")
				{
					opzione = new Option(temp_value[1],temp_value[1]);
					document.getElementById('prezzo_a'+sezioneLaunchRq).options[ind2] = opzione;
					
					if(prezzo_aForm == temp_value[1])
					  document.getElementById('prezzo_a'+sezioneLaunchRq).options[ind2].selected = true;
					  
					ind2++;					  
				}
			}
		}
		
		
		if(field_name == "minpax" && campoLaunchRq != "minpax" && document.getElementById('minpax'+sezioneLaunchRq))
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("minpax"+sezioneLaunchRq);

			opzione = new Option("- Tutti -","");
			document.getElementById('minpax'+sezioneLaunchRq).options[0] = opzione;
			
			for(y=0; y<temp_value_field.length; y++)
			{
				temp_value = temp_value_field[y].split("_");
				opzione = new Option(temp_value[1],temp_value[0]);
				document.getElementById('minpax'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(minpaxForm == temp_value[0])
				  document.getElementById('minpax'+sezioneLaunchRq).options[(y+1)].selected = true
			}
		}
		
		
		if(field_name == "durata" && campoLaunchRq != "durata" && document.getElementById('durata'+sezioneLaunchRq))
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("durata"+sezioneLaunchRq);
			
			opzione = new Option("- Tutti -","");
			document.getElementById('durata'+sezioneLaunchRq).options[0] = opzione;
			
			for(y=0; y<temp_value_field.length; y++)
			{
				temp_value = temp_value_field[y].split("_");
				opzione = new Option(temp_value[1],temp_value[0]);
				document.getElementById('durata'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(aeroportoForm == temp_value[0])
				  document.getElementById('durata'+sezioneLaunchRq).options[(y+1)].selected = true
			}
		}	
		
		if(field_name == "aeroporto" && campoLaunchRq != "aeroporto" && document.getElementById('aeroporto'+sezioneLaunchRq))
		{
			
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("aeroporto"+sezioneLaunchRq);

			opzione = new Option("- Tutti -","");
			document.getElementById('aeroporto'+sezioneLaunchRq).options[0] = opzione;
			
			for(y=0; y<temp_value_field.length; y++)
			{
				temp_value = temp_value_field[y].split("_");
				temp_value[0] = temp_value[0].replace(/,/g,"|");
				temp_value[1] = temp_value[1].replace(/,/g,"|");
				opzione = new Option(temp_value[1],temp_value[0]);
				document.getElementById('aeroporto'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(aeroportoForm == temp_value[0])
				  document.getElementById('aeroporto'+sezioneLaunchRq).options[(y+1)].selected = true
			}
		}
		
		if(field_name == "destinazione" && (campoLaunchRq != "destinazione" && campoLaunchRq != "") && tagForm == "" && document.getElementById('destinazione'+sezioneLaunchRq))
		{
			
			//tab = document.getElementById('link_box_destinazioni');
			if(temp_field[1] != "")
			  document.getElementById('box_disp').style.display = "";
			tab = document.getElementById('dest_disp');
			tab.innerHTML = temp_field[1];
		}
		
		if(field_name == "tipo" && campoLaunchRq != "tipo" && document.getElementById('tipo'+sezioneLaunchRq) && document.getElementById('tipo'+sezioneLaunchRq).tagName == "SELECT")
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("tipo"+sezioneLaunchRq);

			opzione = new Option("- Tutti -","");
			document.getElementById('tipo'+sezioneLaunchRq).options[0] = opzione;

			for(y=0; y<temp_value_field.length; y++)
			{
				temp_value = temp_value_field[y].split("_");
				opzione = new Option(temp_value[1],temp_value[0]);
				document.getElementById('tipo'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(tipoForm == temp_value[0])
				  document.getElementById('tipo'+sezioneLaunchRq).options[(y+1)].selected = true;
			}
		}
		
		if(field_name == "durata" && campoLaunchRq != "durata" && document.getElementById('durata'+sezioneLaunchRq))
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("durata"+sezioneLaunchRq);

			opzione = new Option("- Tutti -","");
			document.getElementById('durata'+sezioneLaunchRq).options[0] = opzione;

			for(y=0; y<temp_value_field.length; y++)
			{
				opzione = new Option(temp_value_field[y],temp_value_field[y]);
				document.getElementById('durata'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(durataForm == temp_value_field[y])
				  document.getElementById('durata'+sezioneLaunchRq).options[(y+1)].selected = true;
			}
		}	
		
		if(field_name == "minpax" && campoLaunchRq != "minpax" && document.getElementById('minpax'+sezioneLaunchRq))
		{
			var temp_value_field = new Array();
			if(temp_field[1])
			  temp_value_field = temp_field[1].split("|");
			
			delSelectID("minpax"+sezioneLaunchRq);

			opzione = new Option("- Tutti -","");
			document.getElementById('minpax'+sezioneLaunchRq).options[0] = opzione;

			for(y=0; y<temp_value_field.length; y++)
			{
				opzione = new Option(temp_value_field[y],temp_value_field[y]);
				document.getElementById('minpax'+sezioneLaunchRq).options[(y+1)] = opzione;
				if(minpaxForm == temp_value_field[y])
				  document.getElementById('minpax'+sezioneLaunchRq).options[(y+1)].selected = true;
			}
		}			
	}
	
	
	
	if(document.getElementById('label'+sezioneLaunchRq))
	  document.getElementById('label'+sezioneLaunchRq).disabled = false;
	  
	if(document.getElementById('tag'+sezioneLaunchRq))
	  document.getElementById('tag'+sezioneLaunchRq).disabled = false;	  
  	//if(document.getElementById('data_da'+sezioneLaunchRq))
  	  //document.getElementById('data_da'+sezioneLaunchRq).disabled = false;
  	//if(document.getElementById('data_a'+sezioneLaunchRq))
  	  //document.getElementById('data_a'+sezioneLaunchRq).disabled = false;
  	//if(document.getElementById('prezzo'+sezioneLaunchRq))
  	  //document.getElementById('prezzo'+sezioneLaunchRq).disabled = false;
    if(document.getElementById('prezzo_da'+sezioneLaunchRq))
      document.getElementById('prezzo_da'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('prezzo_a'+sezioneLaunchRq))
  	  document.getElementById('prezzo_a'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('aeroporto'+sezioneLaunchRq))
  	  document.getElementById('aeroporto'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('tipo'+sezioneLaunchRq))
  	  document.getElementById('tipo'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('durata'+sezioneLaunchRq))
  	  document.getElementById('durata'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('minpax'+sezioneLaunchRq))	
  	  document.getElementById('minpax'+sezioneLaunchRq).disabled = false;
  	if(document.getElementById('button'+sezioneLaunchRq))	
  	  document.getElementById('button'+sezioneLaunchRq).disabled = false;
  	
  	if(document.getElementById('dettaglio_risultati'+sezioneLaunchRq))
  	  document.getElementById('dettaglio_risultati'+sezioneLaunchRq).innerHTML = '';
  	  
  	  
	//launchPreviewSearchVacanze();
	//document.getElementById('prova').innerHTML = ris;
}

function ReloadBoxLocalita(val)
{
	if(val == "")
	{
		document.getElementById('label_dlocalita').style.display = (val != "") ? "" : "none";
		document.getElementById('elenco_dlocalita').style.display = (val != "") ? "" : "none";
	}
	else	
	  x_ReloadBoxLocalita(val,compileBoxLocalita);
}

function compileBoxLocalita(ris)
{
	document.getElementById('label_dlocalita').style.display = "";
	document.getElementById('elenco_dlocalita').style.display = "";	
	//document.getElementById('prova').innerHTML = ris;
	document.getElementById('elenco_dlocalita').innerHTML = ris;
	
	temp_loc = ris.split("<li>");
	rows = (temp_loc.length-1);
	
	if(rows > 8)
		document.getElementById('elenco_dlocalita').style.overflow = "auto";

	if(rows <= 8)
		document.getElementById('elenco_dlocalita').style.overflow = "hidden";
	
}

function updateDate(data1,data2)
{
	document.forms[formName].data_da.value = data1;
    document.forms[formName].data_a.value = data2;
	launchReloadBoxVacanze(formName,"");
}

function launchReloadBoxVacanzeAndSetDestination(destVal,inputId,divName,flag)
{
	setDestination(destVal,'label'+sectionName,divName);
	
	if(flag == true)
	{
		if(document.getElementById('destinazione'+sezioneLaunchRq))
		  document.getElementById('destinazione'+sezioneLaunchRq).value = "";
	
		if(document.getElementById('localita'+sezioneLaunchRq))
		  document.getElementById('localita'+sezioneLaunchRq).value = "";		
		
	  	if(document.getElementById('data_da'+sezioneLaunchRq))
	  	  document.getElementById('data_da'+sezioneLaunchRq).value = "";
	  	if(document.getElementById('data_a'+sezioneLaunchRq))
	  	  document.getElementById('data_a'+sezioneLaunchRq).value = "";
	
	    if(document.getElementById('prezzo_da'+sezioneLaunchRq))
	      delSelectID("prezzo_da"+sezioneLaunchRq);
	  	if(document.getElementById('prezzo_a'+sezioneLaunchRq))
	  	  delSelectID("prezzo_a"+sezioneLaunchRq);
	  	if(document.getElementById('aeroporto'+sezioneLaunchRq))
	  	  delSelectID("aeroporto"+sezioneLaunchRq);
	  	if(document.getElementById('tipo'+sezioneLaunchRq))
	  	{
	  		if(document.getElementById('tipo'+sezioneLaunchRq).options)
	  	  	  delSelectID("tipo"+sezioneLaunchRq);
	  	  	else
	  	  	{
	  	  	  document.getElementById('tipo'+sezioneLaunchRq).value = "TRAS";
	  	  	  tipo = "TRAS";
	  	  	}
	  	}
	  	
	  	if(document.getElementById('durata'+sezioneLaunchRq))
	  	  delSelectID("durata"+sezioneLaunchRq);
	  	if(document.getElementById('minpax'+sezioneLaunchRq))	
	  	  delSelectID("minpax"+sezioneLaunchRq);
	}
	
	if(document.getElementById(inputId+sectionName))
	  document.getElementById(inputId+sectionName).value = destVal;
	  
	if(inputId == "localita" && document.getElementById('dloc') && document.getElementById('destinazione'+sectionName))
	  document.getElementById('destinazione'+sectionName).value = document.getElementById('dloc').value;
	
	
	launchReloadBoxVacanze(inputId,sectionName);
}


function launchReloadBoxVacanzeAndSetDestinationAlternative(destVal,inputId,divName,sezione)
{
	formName = getNameForm("destinazione");
	name = formName;
	setDestination(destVal,inputId,divName,sezione);
		
	//formName è una variabile globale che contiene il nome del form per cui si sta facendo la richiesta asincrona.
	//rivalorizzo la variabile nel caso venga passato il valore dai campi aeroporto o prezzo.
  	destinazione = document.forms[name].destinazione.value;
  	prezzo = "";
  	aeroporto = "";
  	data_da = document.forms[name].data_da.value;
  	data_a = document.forms[name].data_a.value;
  	tipo = "";
  	tag = "";
  	
  	document.forms[name].destinazione.disabled = true;
  	document.forms[name].aeroporto.disabled = true;
  	document.forms[name].tipo.disabled = true;
  	document.forms[name].prezzo.disabled = true;
  	
  	prezzoForm = document.forms[name].prezzo.value;
	aeroportoForm = document.forms[name].aeroporto.value;
	destinazioneForm = destinazione;
	tipoForm = document.forms[name].tipo.value;
	
	campoLaunchRq = "destinazione";
	
	document.getElementById('dettaglio_risultati').innerHTML = "Caricamento...";
	//alert(destinazione+"---"+prezzo+"---"+aeroporto+"---"+tipo);
  	x_ReloadBoxVacanze(destinazione,prezzo,aeroporto,tipo,tag,compileBoxVacanze);		
}


var formName = "";

//recupera il nome del form partendo dall'ID di un INPUT
function getNameForm(inputId)
{
  node = document.getElementById(inputId);
  while(1)
  {
 	temp = node.parentNode;
 	node = temp;
 	
 	if(node.tagName == "FORM")
 	{
 		return node.name;
 	}
  }
  return "";
  
}

function resetBoxVacanze(type)
{
	
	sezioneLaunchRq = type
	tipo = "";
	campoLaunchRq = "-";
	
	//if(document.getElementById('destinazione'+sezioneLaunchRq))
	  //document.getElementById('destinazione'+sezioneLaunchRq).disabled = true;
	//if(document.getElementById('localita'+sezioneLaunchRq))
	  //document.getElementById('localita'+sezioneLaunchRq).disabled = true;
	if(document.getElementById('label'+sezioneLaunchRq))
	  document.getElementById('label'+sezioneLaunchRq).disabled = true;
	if(document.getElementById('tag'+sezioneLaunchRq))
	  document.getElementById('tag'+sezioneLaunchRq).disabled = true;
  	//if(document.getElementById('data_da'+sezioneLaunchRq))
  	  //document.getElementById('data_da'+sezioneLaunchRq).disabled = true;
  	//if(document.getElementById('data_a'+sezioneLaunchRq))
  	  //document.getElementById('data_a'+sezioneLaunchRq).disabled = true;
  	//if(document.getElementById('prezzo'+sezioneLaunchRq))
  	  //document.getElementById('prezzo'+sezioneLaunchRq).disabled = true;
    if(document.getElementById('prezzo_da'+sezioneLaunchRq))
      document.getElementById('prezzo_da'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('prezzo_a'+sezioneLaunchRq))
  	  document.getElementById('prezzo_a'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('aeroporto'+sezioneLaunchRq))
  	  document.getElementById('aeroporto'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('tipo'+sezioneLaunchRq))
  	  document.getElementById('tipo'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('durata'+sezioneLaunchRq))
  	  document.getElementById('durata'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('minpax'+sezioneLaunchRq))
  	  document.getElementById('minpax'+sezioneLaunchRq).disabled = true;
  	if(document.getElementById('button'+sezioneLaunchRq))
  	  document.getElementById('button'+sezioneLaunchRq).disabled = true;


	if(document.getElementById('destinazione'+sezioneLaunchRq))
	  document.getElementById('destinazione'+sezioneLaunchRq).value = "";

	if(document.getElementById('localita'+sezioneLaunchRq))
	  document.getElementById('localita'+sezioneLaunchRq).value = "";
	  
	if(document.getElementById('label'+sezioneLaunchRq))
	  document.getElementById('label'+sezioneLaunchRq).value = "";
	  
	if(document.getElementById('tag'+sezioneLaunchRq))
	  document.getElementById('tag'+sezioneLaunchRq).value = "";

  	if(document.getElementById('data_da'+sezioneLaunchRq))
  	  document.getElementById('data_da'+sezioneLaunchRq).value = "";
  	if(document.getElementById('data_a'+sezioneLaunchRq))
  	  document.getElementById('data_a'+sezioneLaunchRq).value = "";

    if(document.getElementById('prezzo_da'+sezioneLaunchRq))
      delSelectID("prezzo_da"+sezioneLaunchRq);
  	if(document.getElementById('prezzo_a'+sezioneLaunchRq))
  	  delSelectID("prezzo_a"+sezioneLaunchRq);
  	if(document.getElementById('aeroporto'+sezioneLaunchRq))
  	  delSelectID("aeroporto"+sezioneLaunchRq);
  	if(document.getElementById('tipo'+sezioneLaunchRq))
  	{
  		if(document.getElementById('tipo'+sezioneLaunchRq).options)
  	  	  delSelectID("tipo"+sezioneLaunchRq);
  	  	else
  	  	{
  	  	  document.getElementById('tipo'+sezioneLaunchRq).value = "TRAS";
  	  	  tipo = "TRAS";
  	  	}
  	}
  	if(document.getElementById('durata'+sezioneLaunchRq))
  	  delSelectID("durata"+sezioneLaunchRq);
  	if(document.getElementById('minpax'+sezioneLaunchRq))	
  	  delSelectID("minpax"+sezioneLaunchRq);
  	  
  	if(document.getElementById('button'+sezioneLaunchRq))	
  	  document.getElementById('button'+sezioneLaunchRq).disabled = true;  
	
  	  
	//document.getElementById('dettaglio_risultati'+sezioneLaunchRq).innerHTML = "";
	document.getElementById('dettaglio_risultati'+sezioneLaunchRq).innerHTML = '<img src="/images/graphics/loading/loader.gif" alt="Caricamento..." />';
	document.getElementById('prova').innerHTML = "";
	
	destinazioneForm = "";
	tagForm = "";
	prezzo_daForm = "";
	prezzo_aForm = "";
	aeroportoForm = "";
	tipoForm = "";
	durataForm = "";
	minpaxForm = "";
	
	document.getElementById('box_disp').style.display = "none";
	document.getElementById('label_dlocalita').style.display = "none";
	document.getElementById('elenco_dlocalita').style.display = "none";
	for(var i=0; i<document.getElementById('dloc').length; i++)
	{
		if(i == 0)
		  document.getElementById('dloc').options[i].selected = true;
		else
		  document.getElementById('dloc').options[i].selected = false;
		
		
	}
	

	
	x_ReloadBoxVacanze("","","","","","",tipoForm,"","",type,"true",compileBoxVacanze);
}

function ApriFinestraVideoSpace(page)
{
	window.open(page,"VideoSpace","fullscreen=yes,scrollbars=yes,resizable=yes");
}	