	var country_bck;
	var tour_operator_bck;
	var date_departure_bck;
	var reset_bck;
	var avanzata = false;

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 tornaindietro()
	{
		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 ShowImage(travel, id, width, height) 
	{
		width=width+20;
		height=height+20;
        window.open("http://www.ticketcrociere.it/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 GetCatalogoDisp(travelId)
	{
		if(CBGetElementById(travelId).innerHTML != "")
		{
			CBGetElementById(travelId + "_seleziona").innerHTML = "<div id='closed'><img src='http://www.ticketcrociere.it/img/entra_catalogo.png' border='0' align='right'></div>";
			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/chiudi_catalogo.png' border='0' align='right'></div>";
						CBGetElementById(travelId).innerHTML = ajax.responseText;
					}
				}
			} 
		}		
	}

	function GetCatalogo(travelId)
	{
		if(CBGetElementById(travelId).innerHTML != "")
		{
			CBGetElementById(travelId + "_seleziona").innerHTML = "<div id='closed'><img src='http://www.ticketcrociere.it/img/entra_catalogo.png' border='0' align='right'></div>";
			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/chiudi_catalogo.png' border='0' align='right'></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)
	}

<!-- 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;	
						}
						}

function closepromotion() {
document.getElementById("promotion").style.display = 'none';
}
function openpromotion() {
document.getElementById("promotion").style.display = 'block';
}
