var _VER = navigator.appVersion.match(/\d*\.\d*/);
var _DOM = (document.getElementById) ? true : false;
var _NS4;
_NS4 = (document.layers) ? true : false;
_NS5 = (navigator.appName.indexOf('Netscape') !=-1 && _VER>=5);
_IE = (document.all) ? true : false;
_IE4 = _IE && !_DOM;
_Mac = (navigator.appVersion.indexOf("Mac") != -1);
_IE4M = _IE4 && _Mac;
_Opera = (navigator.userAgent.indexOf("Opera")!=-1);
_Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

_BrowserString = _NS4? "NS4" : (_NS5 ? "NS5" : "MSIE");

file_flag=new Array();

function include_js(file) 
{	
    if (file_flag['file']!==void(0) && file_flag['file']) return;
	file_flag['file'] = true;
	document.write('<script type="text/javascript" SRC="'+file+'"><'+'/script>');	
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function Validate(oForm, LG) 
{
	citta=oForm.fld_city_name.value;
	if (oForm.num_nights.value<0 && (oForm.s_avail.checked || (oForm.s_avail[0]!==undefined && oForm.s_avail[0].checked)))
	{
		alert('La data di arrivo deve essere anteriore alla data di partenza.'); 
		return false; 
	} 
	else 
	{
		if((citta.lenght<1)||(citta.substring(0,4)==""))
		{			
			if(LG == "it")
			{
				document.location = "http://www.itwg.com/regions.asp?code=HQ596&Language=ITA";
				return false;
				alert("Spiacenti: il campo Citta è obbligatorio.");
			}
			else
			{
				document.location = "http://www.itwg.com/regions.asp?code=HQ596&Language=ENG";
				return false;
				alert("Sorry: City's field is required.");
			}
			return false;
		}
		else
		{
			return true; 
		}
	}
}
function ValidateITWG(oForm, LG) 
{
	citta=oForm.citta.value;
	if (oForm.num_nights.value<0)
	{
		alert('La data di arrivo deve essere anteriore alla data di partenza.'); 
		return false; 
	} 
	else 
	{
		if((citta.lenght<1)||(citta.substring(0,4)==""))
		{
			numero_link = Math.round(Math.random() * 100 ) % 2			
			if(LG == "it")
			{
				if(numero_link == 1)
				{
					document.location = "http://www.itwg.com/regions.asp?code=HQ595&Language=ITA";
				}
				else
				{
					document.location = "http://www.venere.com/cgi/ihr/vcom/country.cfm?country=italy&ref=963&lg=it";
				}
				return false;
				alert("Spiacenti: il campo Citta è obbligatorio.");
			}
			else
			{
				if(numero_link == 1)
				{
					document.location = "http://www.itwg.com/regions.asp?code=HQ595&Language=ENG";
				}
				else
				{
					document.location = "http://www.venere.com/cgi/ihr/vcom/country.cfm?country=italy&ref=963&lg=en";
				}
				return false;
				alert("Sorry: City's field is required.");
			}
			return false;
		}
		else
		{
			return true; 
		}
	}
}

function ValidateWCT(oForm, LG) 
{
	citta=oForm.city.value;
	
	if((citta.lenght<1)||(citta.substring(0,4)==""))
	{
		if(LG == "it")
		{
			document.location = "http://www.res99.com/nexres/start-pages/menupage.cgi?src=10007139&lang=ITA&color=blue";
			return false;
			alert("Spiacenti: il campo Citta è obbligatorio.");
		}
		else
		{
			document.location = "http://www.res99.com/nexres/start-pages/menupage.cgi?src=10007139&lang=ENG&color=blue";
			return false;
			alert("Sorry: City's field is required.");
		}
		return false;
	}
	else
	{
		return true; 
	}
}