ns=(navigator.appName.indexOf('Netscape')!=-1) ? 1 : 0;
function UpdateComboLocalita()
{
	Select=document.forms['FormLocalita'].elements['LinkLocalita'];
	Value=location.pathname+location.search;
	// Cerca l'opzione che ha il value == all'URL corrente...
	for (i=0; i<Select.options.length; i++)
	{
		if ( Value.lastIndexOf("index.php")>-1 )
		{
			if ( Select.options[i].value==Value )
				break;
		}
		else
		{ 
			if ( Select.options[i].value.substring(0,  Select.options[i].value.lastIndexOf("LeftFile=")+12)==Value.substring(0, Value.lastIndexOf("LeftFile=")+12) )
				break;
		}
	}
	//	...e lo seleziona!
//	if ( i<Select.options.length )
		Select.selectedIndex=i;
}
function RicercaPerLocalita(TipoStruttura)
{
	document.forms['Ricettivita'].elements['TipoLocali[]'].value=TipoStruttura;
	document.forms['Ricettivita'].submit();
}
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
	if ( (Value=selObj.options[selObj.selectedIndex].value)!="" )
		location.href=Value;
	if (restore)
		selObj.selectedIndex=0;
}
function OpenWin(Immagine)
{
	window.open("PopUp.php?ImageFile="+Immagine, "Immagine", "width=200,height=100,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}
function OpenWinCartoline(Immagine, ImgName)
{
	window.open("PopUpCartoline.php", "ImmagineCartolina", "width=200,height=100,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
	document.forms['Cartoline'].elements['Descrizione'].value=document.images[ImgName].alt;
	document.forms['Cartoline'].elements['ImageSrc'].value=document.images[ImgName].src;
	document.forms['Cartoline'].elements['ImageFile'].value=Immagine;
	document.forms['Cartoline'].action="PopUpCartoline.php";
	document.forms['Cartoline'].target="ImmagineCartolina";
	document.forms['Cartoline'].submit();
}
function OpenInfo(File, Width, Height)
{
	if ( isNaN(Width) )
		Width=300;
	if ( isNaN(Height) )
		Height=500;
	window.open(File, "Info", "width="+Width+",height="+Height+",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}
function OpenLogin(File, Width, Height)
{
	if ( isNaN(Width) )
		Width=350;
	if ( isNaN(Height) )
		Height=200;
	window.open(File, "Login", "width="+Width+",height="+Height+",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}
function OpenIPix(File, Width, Height)
{
	if ( isNaN(Width) )
		Width=320;
	if ( isNaN(Height) )
		Height=284;
	window.open(File, "IPix", "width="+Width+",height="+Height+",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}
// apre il popup con l'ipix della struttura..
function IPixPopUp(ID, Definition)
{	
	Width=320;
	Height=284;
	window.open("about:blank", "IPix", "width="+Width+",height="+Height+",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");

	document.forms['Ipix'].elements['ID_Ipix'].value=ID;
	document.forms['Ipix'].elements['Definition'].value=Definition;

	document.forms['Ipix'].action="ita/ipix/IpixPopUp.php";
	document.forms['Ipix'].target="IPix";
	document.forms['Ipix'].submit();
}
function GoTo(FormName)
{
	location.href=FormName.options[FormName.selectedIndex].value;
}
// Controlla che sia una data valida
function CheckDateAlways(Giorno, Mese, Anno)
{
	if ( Giorno.length==0 || Mese.length==0 || Anno.length==0 )
		return false;
	if ( !IsNum(Giorno) || !IsNum(Mese) || !IsNum(Anno) )
		return false;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length>4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 )
		return false;
	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	return true;
}
// Controlla che sia una data valida nel futuro (passata come tre stringhe), non piu' recente del giorno in corso
function CheckDateFuture(Giorno, Mese, Anno)
{
	var Today = new Date;
	if ( Giorno.length==0 || Mese.length==0 || Anno.length==0 )
		return false;
	if ( !IsNum(Giorno) || !IsNum(Mese) || !IsNum(Anno) )
		return false;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length>4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 || Today.getFullYear()>Anno )
		return false;
	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	if ( (Anno==Today.getFullYear() && (Today.getMonth()+1)>Mese) || (Anno==Today.getFullYear() && Mese==(Today.getMonth()+1) && Today.getDate()>Giorno) )
	{
		return false;
	}
	return true;
}
// Controlla che sia una data valida nel passato (passata come tre stringhe), non piu' recente del giorno in corso
function CheckDatePast(Giorno, Mese, Anno)
{
	var Today = new Date;
	if ( Giorno.length==0 || Mese.length==0 || Anno.length==0 )
		return false;
	if ( !IsNum(Giorno) || !IsNum(Mese) || !IsNum(Anno) )
		return false;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length>4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 || Anno<1900 || Anno>Today.getFullYear() )
		return false;
	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	if ( (Anno==Today.getFullYear() && Mese>(Today.getMonth()+1)) || (Anno==Today.getFullYear() && Mese==(Today.getMonth()+1) && Giorno>Today.getDate()) )
	{
		return false;
	}
	return true;
}
//Controlla se l'intervallo (passato come sei stringhe) dato e' valido, (DataInizio<=DataFine)
function CompareDate(Giorno1, Mese1, Anno1, Giorno2, Mese2, Anno2)
{
	if ( Giorno1.substr(0, 1)=="0" )
		Giorno1=Giorno1.substr(1, 1);
	if ( Mese1.substr(0, 1)=="0" )
		Mese1=Mese1.substr(1, 1);
	if ( Giorno2.substr(0, 1)=="0" )
		Giorno2=Giorno2.substr(1, 1);
	if ( Mese2.substr(0, 1)=="0" )
		Mese2=Mese2.substr(1, 1);
	Giorno1=parseInt(Giorno1);
	Mese1=parseInt(Mese1);
	Anno1=parseInt(Anno1);
	Giorno2=parseInt(Giorno2);
	Mese2=parseInt(Mese2);
	Anno2=parseInt(Anno2);
	if ( (Anno1>Anno2) || (Anno1==Anno2 && Mese1>Mese2) || ((Anno1==Anno2 && Mese1==Mese2) && Giorno1>Giorno2) )
	{
		return false;
	}
	return true;
}
// Controlla se la stringa passata e' constituita da cifre
function IsNum(Stringa)
{
	var i;
	for (i=0; i<Stringa.length; i++)
		if ( Stringa.charCodeAt(i)<0x0030 || Stringa.charCodeAt(i)>0x0039 )
			return false;
	return true;
}
// Controlla se la stringa passata e' al massimo Len caratteri
function AreaLength(Stringa, Len)
{
	if ( Stringa.length>Len )
		return false;
	else
		return true;
}

function ShowDiv(id)
{
	document.all['help'+id].style.visibility="visible";
}
function MoveDiv(id)
{
	document.all['help'+id].style.left=event.clientX-50;
	document.all['help'+id].style.top=event.clientY+17;
}
function HideDiv(id)
{
	document.all['help'+id].style.visibility="hidden";
}
function popup(Url,W,H,Img)//apre il popup centrato
{
	var PathImg = '../../images/ita/';
	var PathUrl = '../../../ita/';
	var L = Math.floor((screen.width-W)/2);
	var T = Math.floor((screen.height-H)/2);
	window.open(PathUrl + Url + "?W=" + W + "&H=" + H + "&Img=" + PathImg + Img, 'Bava', 'scrollbars=no, width=' + W + ', height=' + H + ', top=' + T + ', left=' + L);
}
function Stampa(Url)
{
	PathUrl='../stampa/';
	window.open( PathUrl+Url, 'Stampa', 'Top=5000, Left=5000');
}

function ShowImage(Img,Src)
{
if(ns)
	document['img'+Img].src=Src;
else
	document.all['img'+Img].src=Src;
}
function ShowTitolo(Img,Src)
{
	if(ns)
	{
		parent.document['img'+Img].src=Src;
		parent.document['imgacquista'].src="../../../images/ita/shop/acquista_attivo.gif";
		parent.document.getElementById("TopEtichette").style.visibility="visible";
		parent.document.getElementById("Indietro").style.visibility="visible";
		parent.document.getElementById("Conto").style.visibility="visible";
		parent.document['contenuto'].src='tabella_centrale_spesa2.htm';
	}
	else
	{
		parent.document.all['img'+Img].src=Src;
		parent.document.all['imgacquista'].src="../../../images/ita/shop/acquista_attivo.gif";
		parent.document.all['TopEtichette'].style.visibility='visible';
		parent.document.all['Indietro'].style.visibility='visible';
		parent.document.all['Conto'].style.visibility='visible';
		parent.document.all['contenuto'].src='tabella_centrale_spesa2.htm';						
	}
}
