function setCSS(relativePath) {
	if (document.all)
		document.write("<link rel='stylesheet' href='"+relativePath+"style.css' type='text/css'>");
 	else
  		document.write("<link rel='stylesheet' href='"+relativePath+"stylenn.css' type='text/css'>");
}

function popup(page) {
	window.open(page, "_blank", "width=580,height=530,scrollbars=yes,resizable=yes,menubar=no,directories=no,location=no,status=no");
}

function popuphw(page,h,w) {
	window.open(page, "_blank", "width="+w+",height="+h+",scrollbars=yes,resizable=yes,menubar=no,directories=no,location=no,status=no");
}

function popupDateTime(field) {
	var urljsp = '../include/time/scheduletime.jsp';
	var doTransition = window.showModalDialog( urljsp, "" ,'dialogHeight:185px;dialogWidth:310px;center:yes;help:ninquadrao;status:no;resizable:no;scroll:no');
	if (doTransition != -1) { field.value = doTransition; }
}

function popupDate(field) {
	var urljsp = '../include/time/scheduletime.jsp';
	var doTransition = window.showModalDialog( urljsp, "" ,'dialogHeight:185px;dialogWidth:310px;center:yes;help:no;status:no;resizable:no;scroll:no');
	if (doTransition != -1) { field.value = doTransition.substring(0, 10); }
}

function popupDateReg(field) {
	var urljsp = '../../../include/time/scheduletime.jsp?past=true';
	var doTransition = window.showModalDialog( urljsp, "" ,'dialogHeight:185px;dialogWidth:310px;center:yes;help:no;status:no;resizable:no;scroll:no');
	if (doTransition != -1) { field.value = doTransition.substring(0, 10); }
}

function popupInCostr() {
	window.open("include/incostr.html", "_blank", "width=565,height=285,scrollbars=no,resizable=no,menubar=no,directories=no,location=no,status=no");
}

function popupFotoAeree(POIID) {
	window.open("../poi/"+POIID+".html", "_blank", "width=750,height=530,scrollbars=yes,resizable=yes,menubar=no,directories=no,location=no,status=no");
}

function popupWebCam(POIID) {
	window.open("../poi/"+POIID+".html", "_blank", "width=580,height=530,scrollbars=yes,resizable=yes,menubar=no,directories=no,location=no,status=no");
}

function openRubrica(Rubrica) {
	//window.location="homepage.jsp?Zona=Italia&Rubrica="+Rubrica;
	popup("rubriche/"+Rubrica+".html");
}

function inquadraPoi(comunePOI, descrizionePOI, W, N) {
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
	if (i == -1) {
		i = s1.length;
	}
	var bentleyId = new String(s1.substring(i-18, i-14));
	var paginadettaglio = "poi/"+s1.substring(i-20, i)+".html";
	if (bentleyId == "UIMG") {
		paginadettaglio = "save/detuimg.jsp?suid="+s1.substring(i-20, i);
	}
	var comune = new String(comunePOI);
	comune = comune.toLowerCase();
	var descrizione = new String(descrizionePOI);
	var j = descrizione.indexOf(",");
	while (j != -1)
	{
		descrizione = descrizione.substring(0,j)+" "+descrizione.substring(j+1, descrizione.length);
		j = descrizione.indexOf(",");
	}
	if (opener == null)
	{
		window.open("../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&W="+W+"&N="+N+"&Descr="+descrizione, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&W="+W+"&N="+N+"&Descr="+descrizione;
		window.close();
	}
	else
	{
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		opener.document.map.setNameSpace(""+comune.toLowerCase());
//		alert("POI."+bentleyId+","+bentleyId+",250");
		if (bentleyId == 'FLTM')
		{
			opener.document.map.setPOIParameters("POI."+bentleyId+","+bentleyId+",250,0");
		}
		else
		{
			opener.document.map.setPOIParameters("POI."+bentleyId+","+bentleyId+",250,1");
		}
//		alert("UTM32 "+(W)+" "+(N)+",200 200");
		//opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.setViewPort("UTM32 "+W+" "+N+",200 200");
//		alert("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+",poi/"+s1.substring(i-20, i)+".html");
		opener.document.map.showPOI("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+","+paginadettaglio);
		window.close();
	}
}
function inquadraPoiDaScheda(comunePOI, categoriaPOI, descrizionePOI, W, N)
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
	if (i == -1)
	{
		i = s1.length;
	}
	var bentleyId = new String(s1.substring(i-18, i-14));
	var paginadettaglio = "poi/"+s1.substring(i-20, i)+".html";
	if (bentleyId == "UIMG")
	{
		paginadettaglio = "save/detuimg.jsp?suid="+s1.substring(i-20, i);
	}
	var comune = new String(comunePOI);
	comune = comune.toLowerCase();
	var descrizione = new String(descrizionePOI);
	var j = descrizione.indexOf(",");
	while (j != -1)
	{
		descrizione = descrizione.substring(0,j)+" "+descrizione.substring(j+1, descrizione.length);
		j = descrizione.indexOf(",");
	}
	if (opener == null)
	{
		window.open("../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&Descr="+descrizione, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&Descr="+descrizione;
		window.close();
	}
	else
	{
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		opener.document.map.setMap("100_CITTA_"+comune.toUpperCase(),"250_IT");
		//alert("POI."+bentleyId+","+bentleyId+",250");
		opener.document.map.setPOIParameters("POI."+bentleyId+","+categoriaPOI+",250,1");
		//alert("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		//opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.setViewPort("UTM32 "+W+" "+N+",200 200");
		//alert("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+",poi/"+s1.substring(i-20, i)+".html");
		opener.document.map.showPOI("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+","+paginadettaglio);
		window.close();
	}
}

function calcolaPercorso (comune, indirizzo, civico) {
	opener.document.getElementById('routing').cittaD.value = comune;
	opener.document.getElementById('routing').indirizzoD.value = indirizzo;
	opener.document.getElementById('routing').numeroD.value = civico;
	opener.window.focus();
}

function inquadraVeicolo(comune, descrizione, W, N)
{
	var strW = new String(W);
	var strN = new String(N);
	if ( strW.indexOf(".") > 0) {
		strW = strW.substring(0, strW.indexOf(".") );
	}
	if ( strN.indexOf(".") > 0) {
		strN = strN.substring(0, strN.indexOf(".") );
	}
	if (opener != null)
	{
		opener.location="../italia.jsp?Id=PIFLTM000000000000&Comune="+comune+"&BId=FLTM&CatPOI=Fleet%20Management&W="+strW+"&N="+strN+"&Descr="+descrizione;
	}
	else
	{
		window.open("../italia.jsp?Id=PIFLTM000000000000&Comune="+comune+"&BId=FLTM&CatPOI=Fleet%20Management&W="+strW+"&N="+strN+"&Descr="+descrizione, "italia");
	}
	/*var s1 = new String(window.location);
	var i = s1.indexOf(".html");
	var bentleyId = "FLTM";
	if (opener == null)
	{
		window.open("../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&W="+W+"&N="+N+"&Descr="+descrizione, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&W="+W+"&N="+N+"&Descr="+descrizione;
	}
	else
	{
		opener.document.map.setNameSpace(""+comune);
		opener.document.map.setPOIParameters("POI."+bentleyId+","+bentleyId+",250");
		opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.showPoi("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+",poi/"+s1.substring(i-20, i)+".html");
	}*/
}

var homepage = null;

function inquadraFlotta(comune, flotta, vp, sp)
{
	// sp = POI.FLTM, UTM32 X Y, SUID, Nome, URL,POI.FLTM, UTM32 dX1 dY1, Nome, URL, ...
	// alert(opener);
	// alert(opener.window.closed);
	if (opener != null && !opener.window.closed)
	{
		opener.location="../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP0="+sp;
	}
	else if (homepage == null || homepage.closed)
	{
		homepage = window.open("../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP0="+sp, "homepage");
	}
	else
	{
	    homepage.location="../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP0="+sp;
	}
}

function inquadraFlotta(comune, flotta, vp, sp, type)
{
	// sp = POI.FLTM, UTM32 X Y, SUID, Nome, URL,POI.FLTM, UTM32 dX1 dY1, Nome, URL, ...
	// alert(opener);
	// alert(opener.window.closed)
	if (type == null)
	{
	  type=0;  
	}
	if (opener != null && !opener.window.closed)
	{
		opener.location="../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP"+type+"="+sp;
	}
	else if (homepage == null || homepage.closed)
	{
		homepage = window.open("../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP"+type+"="+sp, "homepage");
	}
	else
	{
	    homepage.location="../continuo/index.jsp?Flotta="+flotta+"&Comune="+comune+"&VP="+vp+"&SP"+type+"="+sp;
	}
}

function inquadraFlottaItalia(comune, flotta, vp, sp)
{
	// document.CercaMappe.Localita.value=comune;
	var comunestr = new String(comune);
	var k = comunestr.indexOf(' ');
	if (k>-1)
	{
		comune = comunestr.substring(0, k)+"-"+comunestr.substring(k+1);
	}
	// document.map.setNameSpace(""+comune.toLowerCase());
	//alert("POI.FLTM,"+flotta+",250");
	document.map.setPOIParameters("POI.FLTM,"+flotta+",1000,0");
	//alert(vp);
	document.map.setViewPort(vp);
	//alert(sp);
	var i = -1;
	while ((i=sp.indexOf(";"))>-1)
	{
		//alert(sp.substring(0, i));
		document.map.showPOI(sp.substring(0, i));
		//alert(sp.substring(i+1));
		sp = sp.substring(i+1);
	}
	document.map.showPOI(sp);
	// document.map.showRoute(sr);
}

function inquadraPoiItalia(suid, bentleyId, comune, categoria, descrizione, W, N, DX, DY)
{
	//alert("InquadraPOIItalia");
	var paginadettaglio = "poi/"+suid+".html";
	if (suid.indexOf("DEA") == 0)
	{
		// dea_id
		paginadettaglio = "search/details.jsp?deaid="+suid;
	}
	if (bentleyId == "UIMG")
	{
		paginadettaglio = "save/detuimg.jsp?suid="+suid;
	}
	document.CercaMappe.Localita.value=comune;
	if (categoria == "") categoria = bentleyId;
	var comunestr = new String(comune);
	var k = comunestr.indexOf(' ');
	if (k>-1)
	{
		comune = comunestr.substring(0, k)+"-"+comunestr.substring(k+1);
	}
	document.map.setNameSpace(""+comune.toLowerCase());
	//alert("POI."+bentleyId+","+bentleyId+",250");
	if (bentleyId == 'FLTM')
	{
		document.map.setPOIParameters("POI."+bentleyId+","+categoria+",250,0");
	}
	else
	{
		document.map.setPOIParameters("POI."+bentleyId+","+categoria+",250,1");
	}
	//alert("UTM32 "+(W-100)+" "+(N-100)+",200 200");
	//document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
	document.map.setViewPort("UTM32 "+W+" "+N+","+DX+" "+DY);
	//alert("POI."+bentleyId+",UTM32 "+W+" "+N+","+suid+","+descrizione+",poi/"+suid+".html");
	document.map.showPOI("POI."+bentleyId+",UTM32 "+W+" "+N+","+suid+","+descrizione+","+paginadettaglio);
}
function showRoute(comune, vp, sr)
{
	if (opener == null)
	{
		window.open("../italia.jsp?NS="+comune+"&VP="+vp+"&SR="+sr, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?NS="+comune+"&VP="+vp+"&SR="+sr;
	}
	else
	{
		var comunestr = new String(comune);
		var k = comunestr.indexOf(' ');
		if (k>-1)
		{
			comune = comunestr.substring(0, k)+"-"+comunestr.substring(k+1);
		}
		opener.document.map.setMap('100_CITTA_' + comune.toUpperCase(),'250_IT');
		opener.document.map.setViewPort(vp);
		// sr = ID, UTM32 X Y, dX1 dY1, dX2 dY2, ...
		opener.document.map.showRoute(sr);
	}
}
function showRouteForm()
{
	
	if (document.routing.VP != null && document.routing.VP.value != "")
	{
		if (opener == null)
		{
			document.routing.target="_blank";
			document.routing.submit();
		}
		else if (opener.document.map == null)
		{
			document.routing.target="homepage";
			document.routing.submit();
		}
		else
		{
			var comune = new String(document.routing.NS.value);
			var showpoi = document.routing.SP.value;
			var k = comune.indexOf(' ');
			if (k>-1)
			{
				comune = comune.substring(0, k)+"-"+comune.substring(k+1);
			}
			var showroute = document.routing.SR.value;
			opener.document.map.setMap('100_CITTA_' + comune.toUpperCase(), '250_IT');
			opener.document.map.setViewPort(document.routing.VP.value);

			var j = showroute.indexOf(';');
			while (j > -1)
			{
				if (j > 0)
				{
					opener.document.map.showRoute(showroute.substring(0, j));
				}
				showroute = showroute.substring(j+1);
				j = showroute.indexOf(';');
			}
			opener.document.map.showRoute(showroute);

			opener.document.map.hidePinpoint();
			if (document.routing.PTSP != null)
			{
				
				var showptpoi = document.routing.PTSP.value;
				var i = showptpoi.indexOf(';');
				while (i > -1)
				{
					opener.document.map.showPinpoint(showptpoi.substring(0, i));
					showptpoi = showptpoi.substring(i+1);
					i = showptpoi.indexOf(';');
				}
			}
			//opener.document.map.showPoi(document.routing.SP.value);
			/*var i = showpoi.indexOf(';');
			while (i > -1)
			{
				opener.document.map.showPinpoint(showpoi.substring(0, i));
				showpoi = showpoi.substring(i+1);
				i = showpoi.indexOf(';');
			}*/
		}
		// bShowRoute � inizializzata a false dal foglio stile routing.xsl
		bShowRoute = true;
	}
}

function old_showRouteDetail(dsect, sect, id) {
	// bShowRoute � inizializzata a false dal foglio stile routing.xsl
	// alert(bShowRoute);
	if (bShowRoute == false) {
		showRouteForm();
		bShowRoute = true;
	}
	popup('../routing/routingdetail.jsp?datasect='+dsect+'&sect='+sect+'&id='+id);
}

function showRouteDetail(utm32x, utm32y, istat) {
//alert("showRouteDetail: utm32x=" + utm32x + "\tutm32y=" + utm32y + "\tistat=" + istat);
	// bShowRoute � inizializzata a false dal foglio stile routing.xsl
//	alert(bShowRoute);
	if (bShowRoute == false) {
		showRouteForm();
		bShowRoute = true;
	}
	popup('../routing/routingdetail.jsp?utm32x='+utm32x+'&utm32y='+utm32y+'&istat='+istat);
}

function showPtRouteDetail(vp)
{
	// bShowRoute � inizializzata a false dal foglio stile routing.xsl
	// alert(bShowRoute);
	if (bShowRoute == false)
	{
		showRouteForm();
		bShowRoute = true;
	}
	while (opener.document == null || opener.document.map == null || opener.document.map.namespace == null) ;
	opener.document.map.setViewPort(vp);
}

function showRouteItalia(namespace, viewport, showroute, showpoi, showptpoi)
{
	var comune = new String(namespace);
	var k = comune.indexOf(' ');
	if (k>-1)
	{
		comune = comune.substring(0, k)+"-"+comune.substring(k+1);
	}
	document.map.setNameSpace(comune.toLowerCase());
	document.map.setViewPort(viewport);
	var j = showroute.indexOf(';');
	while (j > -1)
	{
		if (j > 0)
		{
			document.map.showRoute(showroute.substring(0, j));
		}
		showroute = showroute.substring(j+1);
		j = showroute.indexOf(';');
	}
	document.map.showRoute(showroute);
	document.map.hidePinpoint();
	var i = showptpoi.indexOf(';');
	while (i > -1)
	{
		document.map.showPinpoint(showptpoi.substring(0, i));
		showptpoi = showptpoi.substring(i+1);
		i = showptpoi.indexOf(';');
	}
	//document.map.showPoi(showpoi);
	/*var i = showpoi.indexOf(';');
	while (i > -1)
	{
		document.map.showPinpoint(showpoi.substring(0, i));
		showpoi = showpoi.substring(i+1);
		i = showpoi.indexOf(';');
	}*/
	document.CercaMappe.Localita.value=namespace;
}
function sendMail()
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	popup("../mail/sendpoi.jsp?suid="+s1.substring(i-20, i));
}
function sendPoiMail(nome, note)
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	popup("../mail/sendpoi.jsp?suid="+s1.substring(i-20, i)+"&nome="+nome+"&note="+note);
}
function sendPoiMailCategory(nome, note, categoria)
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	popup("../mail/sendpoi.jsp?suid="+s1.substring(i-20, i)+"&nome="+nome+"&note="+note+"&categoria="+categoria);
}
function sendMailRubrica()
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
	if (i == -1)
	{
		i = s1.length;
	}
	s1 = s1.substring(i-20, i);
	i = s1.indexOf("/");
	while (i != -1)
	{
		s1 = s1.substring(i+1, s1.length);
		i = s1.indexOf("/");
	}
	popup("../mail/sendrubrica.jsp?suid="+s1);
}
function vaischeda()
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	window.location="../poi/"+s1.substring(i-20, i)+".html";
}
function vaiSchedaDaRubrica(DeaId)
{
	window.location="../search/details.jsp?deaid="+DeaId;
}
function openBreve(country_id)
{
	if (country_id=="0793")
	{
		country_id="793";
	}
	if (country_id == "3359")
	{
		popup("WebView/"+country_id+"_sib.html");
	}
	else
	{
		popup("iav/"+country_id+"/"+country_id+"_iav.html");
	}
}
function openScheda(country_id)
{
	if (country_id=="0793")
	{
		country_id="793";
	}
	popup("WebView/"+country_id+"_sp.html");
}
function commentoPOI()
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	popup("../save/poicommentonuovo.jsp?suid="+s1.substring(i-20, i));
}
function savePOI()
{
	var s1 = new String(window.location);
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	window.location="../save/poi.jsp?azione=Salva&SUID="+s1.substring(i-20, i);
}

function MM_findObj(n, d) { //v3.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); return x;
}
function MM_nbGroup(event, grpName) { //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}
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 inquadraPIN(nome, descrizione, comune, indirizzo, numero, x, y)
{
	if (opener==null)
	{
		window.open("../italia.jsp?ComunePIN="+comune+"&IndirizzoPIN="+indirizzo+"&NumeroPIN="+numero+"&XPIN="+x+"&YPIN="+y+"&NomePIN="+nome+"&DescrizionePIN="+descrizione);
	}
	else if (opener.document.map == null)
	{
		opener.location = "../italia.jsp?ComunePIN="+comune+"&IndirizzoPIN="+indirizzo+"&NumeroPIN="+numero+"&XPIN="+x+"&YPIN="+y+"&NomePIN="+nome+"&DescrizionePIN="+descrizione;
	}
	else
	{
		var comunestr = new String(comune);
		var k = comunestr.indexOf(' ');
		if (k>-1)
		{
			comune = comunestr.substring(0, k)+"-"+comunestr.substring(k+1);
		}
		opener.document.map.setNameSpace(""+comune.toLowerCase());
		opener.document.map.setViewPort("UTM32 "+x+" "+y+",200 200");
		opener.document.map.showPinPoint("UTM32 "+x+" "+y+","+nome+","+descrizione+",pin");
		opener.document.CercaMappe.Localita.value=comune;
		opener.document.CercaMappe.Indirizzo.value=indirizzo;
		opener.document.CercaMappe.numero.value=numero;
	}
}

function inquadraPINItalia(nome, descrizione, comune, indirizzo, numero, x, y)
{
	var comunestr = new String(comune);
	var k = comunestr.indexOf(' ');
	if (k>-1)
	{
		comune = comunestr.substring(0, k)+"-"+comunestr.substring(k+1);
	}
	document.map.setNameSpace(""+comune.toLowerCase());
	document.map.setViewPort("UTM32 "+x+" "+y+",200 200");
	document.map.showPinPoint("UTM32 "+x+" "+y+","+nome+","+descrizione+",pin");
	document.CercaMappe.Localita.value=comune;
	document.CercaMappe.Indirizzo.value=indirizzo;
	document.CercaMappe.numero.value=numero;
}

function inquadraPoiDaPersonalizzazione(id, comunePOI, categoriaPOI, descrizionePOI, W, N)
{
	var s1 = new String(id)+".html";
	var i = s1.indexOf(".html");
		if (i == -1)
	{
		i = s1.length;
	}
	var bentleyId = new String(s1.substring(i-18, i-14));
	var paginadettaglio = "poi/"+s1.substring(i-20, i)+".html";
	if (bentleyId == "UIMG")
	{
		paginadettaglio = "save/detuimg.jsp?suid="+s1.substring(i-20, i);
	}
	var comune = new String(comunePOI);
	comune = comune.toLowerCase();
	var descrizione = new String(descrizionePOI);
	var j = descrizione.indexOf(",");
	while (j != -1)
	{
		descrizione = descrizione.substring(0,j)+" "+descrizione.substring(j+1, descrizione.length);
		j = descrizione.indexOf(",");
	}
	if (opener == null)
	{
		window.open("../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&Descr="+descrizione, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?Id="+s1.substring(i-20, i)+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&Descr="+descrizione;
	}
	else
	{
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		opener.document.map.setNameSpace(""+comune.toLowerCase());
		//alert("POI."+bentleyId+","+bentleyId+",250");
		opener.document.map.setPOIParameters("POI."+bentleyId+","+categoriaPOI+",250,1");
		//alert("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		//opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.setViewPort("UTM32 "+W+" "+N+",200 200");
		//alert("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+",poi/"+s1.substring(i-20, i)+".html");
		opener.document.map.showPOI("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+","+paginadettaglio);
	}
}

function showProfilo(profilo, tipo)
{
	if (tipo == "1")
	{
		if (opener != null)
		{
			opener.location = "../mondo.jsp?Load="+profilo;
		}
	}
	else if(tipo == "0")
	{
		if (opener != null)
		{
			opener.location = "../italia.jsp?Load="+profilo;
		}
	}
}

function inquadraPoiDaRubrica(DeaId, bentleyId, comunePOI, categoriaPOI, descrizionePOI, W, N, DX, DY)
{
	var paginadettaglio = "search/details.jsp?deaid="+DeaId;
	var comune = new String(comunePOI);
	comune = comune.toLowerCase();
	var descrizione = new String(descrizionePOI);
	var j = descrizione.indexOf(",");
	while (j != -1)
	{
		descrizione = descrizione.substring(0,j)+" "+descrizione.substring(j+1, descrizione.length);
		j = descrizione.indexOf(",");
	}
	if (opener == null)
	{
		window.open("../italia.jsp?Id="+DeaId+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&DX="+DX+"&DY="+DY+"&Descr="+descrizione, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?Id="+DeaId+"&Comune="+comune+"&BId="+bentleyId+"&CatPOI="+categoriaPOI+"&W="+W+"&N="+N+"&DX="+DX+"&DY="+DY+"&Descr="+descrizione;
	}
	else
	{
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		opener.document.map.setNameSpace(""+comune.toLowerCase());
		//alert("POI."+bentleyId+","+bentleyId+",250");
		opener.document.map.setPOIParameters("POI."+bentleyId+","+categoriaPOI+",250,1");
		//alert("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		//opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.setViewPort("UTM32 "+W+" "+N+","+DX+" "+DY);
		//alert("POI."+bentleyId+",UTM32 "+W+" "+N+","+s1.substring(i-20, i)+","+descrizione+",poi/"+s1.substring(i-20, i)+".html");
		opener.document.map.showPOI("POI."+bentleyId+",UTM32 "+W+" "+N+","+DeaId+","+descrizione+","+paginadettaglio);
	}
}
function inquadraMappaDaRubrica(comunePOI, W, N, DX, DY)
{
	var comune = new String(comunePOI);
	comune = comune.toLowerCase();
	if (opener == null)
	{
		window.open("../italia.jsp?NS="+comune+"&VP=UTM32+"+W+"+"+N+","+DX+"+"+DY, "_blank");
	}
	else if (opener.document.map == null)
	{
		opener.location= "../italia.jsp?NS="+comune+"&VP=UTM32+"+W+"+"+N+","+DX+"+"+DY;
	}
	else
	{
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		opener.document.map.setNameSpace(""+comune.toLowerCase());
		//opener.document.map.setViewPort("UTM32 "+(W-100)+" "+(N-100)+",200 200");
		opener.document.map.setViewPort("UTM32 "+W+" "+N+","+DX+" "+DY);
	}
}

function sendMailDaRubrica(SUID, nome, note, categoria)
{
	popup("../mail/sendrubrica.jsp?suid="+SUID+"&nome="+nome+"&note="+note+"&categoria="+categoria);
}

function openMeteoDaRubrica(EpsonId)
{
	popup("../meteo/meteo.jsp?epson_id="+EpsonId);
}

function openSearchDaRubrica(X, Y, Raggio, BentleyId)
{
	popup("../search/searchPOICategoryWide.jsp?Type=POI."+BentleyId+"&Area="+X+" "+Y+","+Raggio+" "+Raggio);
}

function banner_hp_dex()
{
	window.open("http://shop.deagostini.it/store/Argomento.asp?Arg=44");
}
function banner_eshop()
{
	window.open("http://shop.deagostini.it/store/Catalogo.asp?Cat=11");
}
function banner_italia_bot()
{
	window.open("http://shop.deagostini.it/store/Argomento.asp?Arg=40");
}
function banner_mondo_dex()
{
	window.open("http://shop.deagostini.it/store/Argomento.asp?Arg=39");
}
function banner_fotoaeree_top()
{
	window.open("http://shop.deagostini.it/store/Argomento.asp?Arg=53");
}
function banner_120()
{
	window.open("http://shop.deagostini.it/store/Argomento.asp?Arg=37");
}

/*function showRouteDetailNew(utm32x, utm32y, istat) {
//alert("showRouteDetail: utm32x=" + utm32x + "\tutm32y=" + utm32y + "\tistat=" + istat);
	// bShowRoute � inizializzata a false dal foglio stile routing.xsl
//	alert(bShowRoute);
	if (bShowRoute == false) {
		showRouteFormNew();
		bShowRoute = true;
	}
	popup('../routing/routingdetaillombardia.jsp?utm32x='+utm32x+'&utm32y='+utm32y+'&istat='+istat);
}*/

function showRouteDetailNew(utm32x, utm32y, istat,indirizzo) {
	if (bShowRoute == false) {
		showRouteFormNew();
		bShowRoute = true;
	}
	//alert("zoommo");
	opener.document.map.hidePinPoint();
	opener.document.map.showPinPoint(utm32x + " " + utm32y + ",step,"+indirizzo+",pin");
	opener.document.map.setViewPort(utm32x + " " + utm32y + ",200 200");
	//alert("zoommato");
}				

function showRouteFormNew()
{

	if (document.routing.VP != null && document.routing.VP.value != "")
	{
		var comune = new String(document.routing.NS.value);
		var showpoi = document.routing.SP.value;
		var k = comune.indexOf(' ');
		if (k>-1)
		{
			comune = comune.substring(0, k)+"-"+comune.substring(k+1);
		}
		
		var showroute = document.routing.SR.value;
		opener.document.map.hideRoute('1');
		opener.document.map.setNameSpace("100_CITTA_" + comune.toUpperCase(), '250_IT');
		opener.document.map.setViewPort(document.routing.VP.value.substring(6));
		
		
		var j = showroute.indexOf(';');
		
		while (j > -1)
		{
			if (j > 0)
			{
				
				opener.document.map.showRoute(transformShowRoute(showroute.substring(0, j)));
			}
			showroute = showroute.substring(j+1);
			j = showroute.indexOf(';');
		}
		try {
			opener.document.map.showRoute(transformShowRoute(showroute));
		} catch (e) {
			//alert(e);
		}
		opener.document.map.hidePinPoint();
		
		if (document.routing.PTSP != null)
		{
			
			var showptpoi = document.routing.PTSP.value;
			var i = showptpoi.indexOf(';');
			while (i > -1)
			{
				opener.document.map.showPinpoint(showptpoi.substring(0, i));
				showptpoi = showptpoi.substring(i+1);
				i = showptpoi.indexOf(';');
			}
		}
	}
  // bShowRoute � inizializzata a false dal foglio stile routing.xsl
	bShowRoute = true;
	
}

function transformShowRoute(sr)
{
  // Cambio di formato: da id, vp, sr 
  //                    a  id, colore(d2d2d2), modo(1), vp, sr
  
  var iFirstComma = sr.indexOf(",");
  var retVal = sr.substring(0, iFirstComma);
  retVal += ",d2d2d2,1" + sr.substring(iFirstComma);
  return retVal;                  
}
