	function ShowAvanzata()
	{
		// we don't allow ShowAvanzata until the page is loaded
		if((country_bck == "") || (country_bck == null))
			return;

		var table = document.getElementById("ricerca_table");
		var prezzo_title = document.getElementById("prezzo_title");
		var price_container = document.getElementById("selling_price_container");
		var durata_title = document.getElementById("durata_title");
		var nights_container = document.getElementById("nights_container");
		var button = document.getElementById("ricerca_button");
		
		onReset();

		if(avanzata == false)
		{
			avanzata = true;
			table.className = "form-ricerca_crociere_avanzato";
			button.className = "bottone-ricerca-semplice-int-crociere";
			prezzo_title.innerHTML = "Prezzo";
			durata_title.innerHTML = "Durata";
			price_container.innerHTML = "<select id=\"selling_price\" class=\"form_selling_price\" onChange=\"onSelectChanged(3)\"><option value=\"\" selected>---- Tutti -----</option><option value=\"0\">Fino a 500</option><option value=\"1\">500 - 1.000</option><option value=\"2\">Fino a 1.500</option><option value=\"3\">Oltre 1.500</option></select>";
			nights_container.innerHTML = "<select id=\"nights\" class=\"form_nights\" onChange=\"onSelectChanged(4)\"><option value=\"\" selected>---- Tutte -----</option><option  value=\"0\">Meno di 7 giorni</option><option value=\"1\">7 giorni</option><option value=\"2\">14 giorni</option><option value=\"3\">Oltre 14 giorni</option></select>";
		}
		else
		{
			avanzata = false;
			table.className = "form-ricerca_crociere";
			button.className = "bottone-ricerca-avanzata-int";
			prezzo_title.innerHTML = "";
			durata_title.innerHTML = "";
			price_container.innerHTML = "";
			nights_container.innerHTML = "";
		}
	}

	function CBGetElementById(id) 
	{
		// elemento da restituire
		var elemento;
	 
		// se esiste il metodo getElementById
		// questo if sarà diverso da false, null o undefined
		// e sarà quindi considerato valido, come un true
		if(document.getElementById)
		{
			elemento = document.getElementById(id);
		}
		else
		{
			 // altrimenti è necessario usare un vecchio sistema
			elemento = document.all[id];
		}

		// restituzione elemento
		return elemento;
	}

	function GoTo(url)
	{
		location.href = url;
	}

    function ShowImage(travel, id, width, height) 
	{
		width=width+20;
		height=height+20;
        window.open("popup.php?travel_id="+travel+"&id="+id, '', 'width='+width+',height='+height+',resizable=no,menubar=no,toolbar=no,scrollbars=no,location=no,status=no');
    }

	// funzione per assegnare l'oggetto XMLHttpRequest
	// compatibile con i browsers più recenti e diffusi
	function GetXMLHttpRequest() 
	{
		// variabile di ritorno, nulla di default
		var XHR = null,
	 
		// informazioni sul nome del browser
		browser = navigator.userAgent.toUpperCase();


		// browser standard con supporto nativo
		// non importa il tipo di browser
		if (typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object") 
		{
			XHR = new XMLHttpRequest();
		}
		else if ((window.ActiveXObject) && (browser.indexOf("MSIE 4") < 0)) 
		{
			// la versione 6 di IE ha un nome differente
			// per il tipo di oggetto ActiveX
			if(browser.indexOf("MSIE 5") < 0)
			{
				XHR = new ActiveXObject("Msxml2.XMLHTTP");
			}
			else
			{
				// le versioni 5 e 5.5 invece sfruttano lo stesso nome
				XHR = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}

		return XHR;
	}

	function PostRequest(queryString, objectToUpdate, objectSelected)
	{
		var ajax = GetXMLHttpRequest();
		if (ajax != null)
		{
			// esempio di richiesta pagina con metodo post
			ajax.open("post", "finder.php", true);

			// imposto il giusto header
			ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");

			// ulteriore header consigliato per richieste get o post
			// da scrivere prima di utilizzare send
			ajax.setRequestHeader("connection", "close");

			// effettuo la richiesta inviando la variabile
			ajax.send(queryString);  

			ajax.onreadystatechange = function() 
			{
				if(ajax.readyState === 4) 
				{
					if(ajax.status == 200)
					{
						// visualizzazione contenuto letto
						// evitando di scrivere la risposta in modo
						// interpretabile dal browser
						CBGetElementById(objectToUpdate + '_container').innerHTML = ajax.responseText;
						var obj = CBGetElementById(objectToUpdate);

						// it could also be zero, but we enable it because otherwise nothing will work anymore
						obj.disabled = false;

						onDownloadCompleted();
					}
				}
			} 
		}
	}

	function DoBackupFields(enable)
	{
		CBGetElementById('country').disabled = false;
		CBGetElementById('tour_operator').disabled = false;
		CBGetElementById('date_departure').disabled = false;

		CBGetElementById('country').selectedIndex = 0;
		CBGetElementById('tour_operator').selectedIndex = 0;
		CBGetElementById('date_departure').selectedIndex = 0;


		country_bck = CBGetElementById('country_container').innerHTML;
		tour_operator_bck = CBGetElementById('tour_operator_container').innerHTML;
		date_departure_bck = CBGetElementById('date_departure_container').innerHTML;


		var adulti = CBGetElementById("adulti");
		var ragazzi = CBGetElementById("ragazzi");
		var cabina = CBGetElementById("cabina");

		if(adulti != null)
			adulti.selectedIndex = 0;
		if(ragazzi != null)
			ragazzi.selectedIndex = 0;
		if(cabina != null)
		{
			cabina.selectedIndex = 0;
			cabina.disabled = true;
		}
	}

	function onDownloadCompleted()
	{
		var country_select = CBGetElementById('country');
		var country = country_select.options[country_select.selectedIndex].value;		
		
		var tour_operator_select = CBGetElementById('tour_operator');
		var tour_operator = tour_operator_select.options[tour_operator_select.selectedIndex].value;		

		var date_departure_select = CBGetElementById('date_departure');
		var date_departure = date_departure_select.options[date_departure_select.selectedIndex].value;

		// We check if everything is downloaded / selected
		if (((country_select.disabled == false) || (country != "")) && ((tour_operator_select.disabled == false) || (tour_operator != "")) && ((date_departure_select.disabled == false) || (date_departure != "")))
		{
			var isFinished = true;

			// We must also check advanced fields, in the case
			if(avanzata == true)
			{
				isFinished = false;

				var price_select = CBGetElementById('selling_price');
				var price = price_select.options[price_select.selectedIndex].value;		

				var nights_select = CBGetElementById('nights');
				var nights = nights_select.options[nights_select.selectedIndex].value;

				if(((price_select.disabled == false) || (price != "")) && ((nights_select.disabled == false) || (nights != "")))
					isFinished = true;
			}

			if(isFinished)
			{
				// Wow everything is completed, we disable the overlay
				CBGetElementById("overlay").style.visibility = "hidden";
				CBGetElementById('submit_btn').disabled = false;
			}
		}
	}

	function onReset()
	{
		CBGetElementById('country_container').innerHTML = country_bck;
		CBGetElementById('tour_operator_container').innerHTML = tour_operator_bck;
		CBGetElementById('date_departure_container').innerHTML = date_departure_bck;
		CBGetElementById('reset').style.visibility = "hidden";
		CBGetElementById('submit_btn').disabled = false;

		if(avanzata == true)
		{
			CBGetElementById('selling_price_container').innerHTML = "<select id=\"selling_price\" class=\"form_selling_price\" onChange=\"onSelectChanged(3)\"><option value=\"\" selected>---- Tutti -----</option><option value=\"0\">Fino a 500</option><option value=\"1\">500 - 1.000</option><option value=\"2\">Fino a 1.500</option><option value=\"3\">Oltre 1.500</option></select>";
			CBGetElementById('nights_container').innerHTML =  "<select id=\"nights\" class=\"form_nights\" onChange=\"onSelectChanged(4)\"><option  value=\"\" selected>---- Tutte -----</option><option  value=\"0\">Meno di 7 giorni</option><option value=\"1\">7 giorni</option><option value=\"2\">14 giorni</option><option value=\"3\">Oltre 14 giorni</option></select>";
		}
	}

	function doSubmit()
	{
		var selectedObjects = new Array(CBGetElementById('country'), CBGetElementById('tour_operator'), CBGetElementById('selling_price'), CBGetElementById('nights'));

		// Checking if the date is selected
		var date = CBGetElementById('date_departure');
		CBGetElementById(date.id + "_field").value = date.options[date.selectedIndex].value;
		if(date.options[date.selectedIndex].value == "")
		{
			alert("E' necessario selezionare un mese");
			return false;		
		}

		var max = 2;

		if(avanzata == true)
			max = 4;
		
		var isSelected = false;

		for (var i = 0; i < max; i++)
		{
			CBGetElementById(selectedObjects[i].id + "_field").value = selectedObjects[i].options[selectedObjects[i].selectedIndex].value;
			if(selectedObjects[i].options[selectedObjects[i].selectedIndex].value != "")
				isSelected = true;
		}

		if(isSelected)
		{
			return true;
		}
		else
		{
			alert("E' necessario selezionare almeno un parametro di ricerca");
			return false;
		}

	}

	// When the select changes we simply download other fields
	function onSelectChanged(selectedId)
	{
		var selectedObjects = new Array(CBGetElementById('country'), CBGetElementById('tour_operator'), CBGetElementById('date_departure'), CBGetElementById('selling_price'), CBGetElementById('nights'));
		var selectedObject = selectedObjects[selectedId];
		var selectedValue = selectedObject.options[selectedObject.selectedIndex].value;

		// No value is selected OR other fields are already disabled : WE MUST DO NOTHING
		if (selectedValue == "")
			return;
		
		var max = 3;
		if(avanzata == true)
			max = 5;

		var isLast = true;

		for (var i = 0; i < max; i++)
		{
			if ((selectedObjects[i].disabled == false) && (i != selectedId))
			{
				isLast = false;
				break;
			}
		}

		if (isLast == true)
			return;

		// We set the overlay
		CBGetElementById("overlay").style.visibility = "visible";

		// Something is changed. We must enable the reset button
		CBGetElementById('reset').style.visibility = "visible";

		var queryString = "&crociere=true";
		for	(var i = 0; i < max; i++)
		{
			queryString = queryString + "&" + selectedObjects[i].id + "=" + selectedObjects[i].options[selectedObjects[i].selectedIndex].value;
		}

		selectedObject.disabled = true;
		
		for (var i = 0; i < max; i++)
		{
			if ((selectedObjects[i].disabled == false) && (i != selectedId))
			{
				selectedObjects[i].disabled = true;
				PostRequest("request="+ selectedObjects[i].id +queryString, selectedObjects[i].id, selectedObjects[selectedId].id);
			}
		}
	}

	function HideLoadPanelCrociere()
	{
		// We set the overlay
		CBGetElementById("overlay_load").style.visibility = "hidden";
		DoBackupFields(false);
	}

	function GetCatalogoDisp(travelId)
	{
		if(CBGetElementById(travelId).innerHTML != "")
		{
			CBGetElementById(travelId + "_seleziona").innerHTML = "Seleziona";
			CBGetElementById(travelId).innerHTML = "";
			return;
		}

		var ajax = GetXMLHttpRequest();
		if (ajax != null)
		{
			// esempio di richiesta pagina con metodo post
			ajax.open("post", "catalogo_finder_disp.php", true);

			// imposto il giusto header
			ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");

			// ulteriore header consigliato per richieste get o post
			// da scrivere prima di utilizzare send
			ajax.setRequestHeader("connection", "close");

			// effettuo la richiesta inviando la variabile
			ajax.send("travel_id=" + travelId);  

			ajax.onreadystatechange = function() 
			{
				if(ajax.readyState === 4) 
				{
					if(ajax.status == 200)
					{
						// visualizzazione contenuto letto
						// evitando di scrivere la risposta in modo
						// interpretabile dal browser
						CBGetElementById(travelId).style.opacity = 100;
						CBGetElementById(travelId + "_seleziona").innerHTML = "<div id='closed'><img src='http://www.ticketcrociere.it/img/close.png' border='0'></div>";
						CBGetElementById(travelId).innerHTML = ajax.responseText;
					}
				}
			} 
		}		
	}

	function GetCatalogo(travelId)
	{
		if(CBGetElementById(travelId).innerHTML != "")
		{
			CBGetElementById(travelId + "_seleziona").innerHTML = "Seleziona";
			CBGetElementById(travelId).innerHTML = "";
			return;
		}

		var ajax = GetXMLHttpRequest();
		if (ajax != null)
		{
			// esempio di richiesta pagina con metodo post
			ajax.open("post", "catalogo_finder.php", true);

			// imposto il giusto header
			ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");

			// ulteriore header consigliato per richieste get o post
			// da scrivere prima di utilizzare send
			ajax.setRequestHeader("connection", "close");

			// effettuo la richiesta inviando la variabile
			ajax.send("travel_id=" + travelId);  

			ajax.onreadystatechange = function() 
			{
				if(ajax.readyState === 4) 
				{
					if(ajax.status == 200)
					{
						// visualizzazione contenuto letto
						// evitando di scrivere la risposta in modo
						// interpretabile dal browser
						CBGetElementById(travelId).style.opacity = 100;
						CBGetElementById(travelId + "_seleziona").innerHTML = "<div id='closed'><img src='http://www.ticketcrociere.it/img/close.png' border='0'></div>";
						CBGetElementById(travelId).innerHTML = ajax.responseText;
					}
				}
			} 
		}		
	}

	baseopacity = 0.0;

	//function instantset(degree)
	//{
		//if (browserdetect=="mozilla")
			//imgobj.style.MozOpacity=degree/100;
		//else if (browserdetect=="ie")
			//imgobj.filters.alpha.opacity=degree;
	//}

	function cleartimer()
	{
		if (window.highlighting) 
			clearInterval(highlighting);
	}

	function gradualfade(cur2)
	{
		if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
			cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
		else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
			cur2.filters.alpha.opacity+=10
		else if (window.highlighting)
			clearInterval(highlighting)
	}

// -------------------------------------------------------------------
// Ajax XML Ticker (txt file source)
// Author: Dynamic Drive (http://www.dynamicdrive.com)
// -------------------------------------------------------------------

////////////No need to edit beyond here//////////////

function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}

// -------------------------------------------------------------------
// Main Ajax Ticker Object function
// ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
// -------------------------------------------------------------------

function ajax_ticker(xmlfile, divId, divClass, delay, fadeornot){
this.xmlfile=xmlfile //Variable pointing to the local ticker xml file (txt)
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=0
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
this.messages=[] //Arrays to hold each message of ticker
this.ajaxobj=createAjaxObj()
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">Initializing ticker...</div></div>')
this.getXMLfile()
}

// -------------------------------------------------------------------
// getXMLfile()- Use Ajax to fetch xml file (txt)
// -------------------------------------------------------------------

ajax_ticker.prototype.getXMLfile=function(){
if (this.ajaxobj){
var instanceOfTicker=this
var url=this.xmlfile+"?bustcache="+new Date().getTime()
this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()}
this.ajaxobj.open('GET', url, true)
this.ajaxobj.send(null)
}
}

// -------------------------------------------------------------------
// initialize()- Initialize ticker method.
// -Gets contents of xml file and parse it using JavaScript DOM methods 
// -------------------------------------------------------------------

ajax_ticker.prototype.initialize=function(){ 
if (this.ajaxobj.readyState == 4){ //if request of file completed
if (this.ajaxobj.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
var xmldata=this.ajaxobj.responseText
this.contentdiv.style.display="none"
this.contentdiv.innerHTML=xmldata
if (this.contentdiv.getElementsByTagName("div").length==0){ //if no messages were found
this.contentdiv.innerHTML="<b>Error</b> fetching remote ticker file!"
return
}
var instanceOfTicker=this
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){instanceOfTicker.contentdiv=instanceOfTicker.ajaxobj=null})
//Cycle through XML object and store each message inside array
for (var i=0; i<this.contentdiv.getElementsByTagName("div").length; i++){
if (this.contentdiv.getElementsByTagName("div")[i].className=="message")
this.messages[this.messages.length]=this.contentdiv.getElementsByTagName("div")[i].innerHTML
}
this.contentdiv.innerHTML=""
this.contentdiv.style.display="block"
this.rotatemsg()
}
}
}

// -------------------------------------------------------------------
// rotatemsg()- Rotate through ticker messages and displays them
// -------------------------------------------------------------------

ajax_ticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{ //else, construct item, show and rotate it!
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.messages[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.messages.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container periodically
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

ajax_ticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.1
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}










<!-- Mailinglist controllo
function ControllaMail()
   {
   EmailAddr = document.offertamail.mail.value;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return true;
   else
      {
      alert("Controlla l'indirizzo di e-mail inserito");
      document.offertamail.mail.focus();
      return false;
      }
   }
   
function delDefaultValue(elem) {
	elemChange = document.getElementById(elem);
		if (elemChange.value == elemChange.defaultValue) {
				elemChange.value='';
					}
						elemChange.style.color = '#000';
						}
function checkEmptyValue(elem) {
	elemChange = document.getElementById(elem);
		if (elemChange.value == '')
		 {
		 		elemChange.style.color = '#999';
						elemChange.value = elemChange.defaultValue;	
						}
						}
//-->