function checkSubmit()
{
	var msg="";
	if (document.getElementById("DEPFROM").value=="" && document.getElementById("DEPCITY").value==""){
	msg="- Scegliere una destinazione."
	}
	if (document.getElementById("depDateFrom").value==""){
	msg+="- Indica una data dalla quale effettuare una ricerca viaggi."
	}
	if (document.getElementById("depDateTo").value==""){
	msg+="\n- Indica una data fino alla quale effettuare una ricerca viaggi."
	}
				if (msg.length > 0){
				alert(msg)
				return false;
				}
				else
				{return true;}
}

function setSearchDestination( destVal ) {
	document.getElementById( "keySearch" ).value = destVal;
    document.getElementById( "CITY" ).value = '';
    document.getElementById( "DEPFROM" ).value = destVal;
    hideDestinations();
}

function setDestinationCity( destVal, cityVal ) {
	document.getElementById( "keySearch" ).value = cityVal;
    document.getElementById( "DEPFROM" ).value = destVal;
	document.getElementById( "CITY" ).value = cityVal;
    hideDestinations();
}

function callback(depSelected)
{
	var html = [];	
	var d = document.tuiForm.DEPFROM;
	var i,m=0; 
	var str='';
	var strSelected='';
/* Best sellers */
	html[html.length]="<ul>";
	for(var i=0; i<topDest.length; i++)
	{
		
		if (i % 20 == 0 && i>0)	html[html.length]="</td><td nowrap>";
		str = topDest[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) 
			{
			if (topDest[i].city == '')
				html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + topDest[i].name + "')\" style='background-color:#000066'>&nbsp; " + topDest[i].value + " &nbsp;</a></li>";   
			else
				html[html.length] = "<li><a href=\"javascript:setDestinationCity('" + topDest[i].name + "','" + topDest[i].city + "')\" style='background-color:#000066'>&nbsp; " + topDest[i].value + " &nbsp;</a></li>";   
			}
		else 
			{
			if (topDest[i].city == '')
				html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + topDest[i].name + "')\">&nbsp; " + topDest[i].value + " &nbsp;</a></li>";
			else
				html[html.length] = "<li><a href=\"javascript:setDestinationCity('" + topDest[i].name + "','" + topDest[i].city + "')\">&nbsp; " + topDest[i].value + " &nbsp;</a></li>";
			}  
   }
	html[html.length]="</ul>";
	document.getElementById("displayTOP").innerHTML = html.join("");
   
	html = [];
/*  Mar Rosso*/

	html[html.length]=""
	html[html.length]="<ul>";
	for(var i=0; i<pnlDest1.length; i++)
	{
		if (i % 20 == 0 && i>0)	html[html.length]="</td><td nowrap>";
		str = pnlDest1[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest1[i].value + "')\" style='background-color:#000066'>&nbsp; " + pnlDest1[i].name + " &nbsp;</a></li>";   
		else html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest1[i].value + "')\">&nbsp; " + pnlDest1[i].name + " &nbsp;</a></li>";   
   }
	html[html.length]="</ul>";
	document.getElementById("displayMarRosso").innerHTML = html.join("");
   
	html = [];

/*  nuove destinazioni  */

	html[html.length]="<ul>";
	for(var i=0; i<pnlDest2.length; i++)
	{
		if (i % 20 == 0 && i>0)	html[html.length]="</td><td nowrap>";
		str = pnlDest2[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest2[i].value + "')\" style='background-color:#000066'>&nbsp; " + pnlDest2[i].name + " &nbsp;</a></li>";   
		else html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest2[i].value + "')\">&nbsp; " + pnlDest2[i].name + " &nbsp;</a></li>";   
   }
	html[html.length]="</ul>";
	document.getElementById("displayNewDest").innerHTML = html.join("");
   
	html = [];
/*  Oceano Indiano  */

	html[html.length]="<ul>";
	for(var i=0; i<pnlDest3.length; i++)
	{
		if (i % 20 == 0 && i>0)	html[html.length]="</td><td nowrap>";
		str = pnlDest3[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest3[i].value + "')\" style='background-color:#000066'>&nbsp; " + pnlDest3[i].name + " &nbsp;</a></li>";   
		else html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + pnlDest3[i].value + "')\">&nbsp; " + pnlDest3[i].name + " &nbsp;</a></li>";   
   }
	html[html.length]="</ul>";
	document.getElementById("displayOceano").innerHTML = html.join("");
   
	html = [];

/*  Other Destination  */
	html[html.length]="<table class=\"vbmenu_option\" align=\"left\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\" border=\"0\">"
	html[html.length]="<tr><td nowrap valign=\"top\"><ul>";
	for(var i=0; i<rlmDest.length; i++)
	{
		if (i % 20 == 0 && i>0) html[html.length]="</td><td nowrap>";
		str = rlmDest[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + rlmDest[i].value + "')\" style='background-color:#F88941'>&nbsp; " + rlmDest[i].name + " &nbsp;</a></li>";   
		else html[html.length] = "<li><a href=\"javascript:setSearchDestination('" + rlmDest[i].value + "')\">&nbsp; " + rlmDest[i].name + " &nbsp;</a></li>";   
	}
	html[html.length]="</ul></td></tr></table>";
	document.getElementById("displayRLM").innerHTML = html.join("");  
}



function setDepartureSelected(depSelected)
{
    var d = document.tuiForm.DEPFROM;
	var i,m=0; 
	var str='';
	var strSelected='';
	
	for(i=0; i<rlmDest.length; i++) 
	{
		str = rlmDest[i].value;
		if (str.toLowerCase() == depSelected.toLowerCase()) strSelected = rlmDest[i].name		
	}
	
	d.value = (strSelected ? strSelected : '');	
}

