// JavaScript Document
<!--
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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
*/
/**  CHECK BROWSER  **/
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false


/** set lang function**/
var lang;
function setLang(){
url=new String(location.href);
if((plang=url.search('lang='))!=-1){
 lang=url.substring(plang+5);
	}
}

/**stampa le labels --- viene ridefinita su XmlPathTemplate.htm e Help.php**/
function printText(var_txt){
  document.write(var_txt);
}


function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
   if ((obj=MM_findObj(args[i]))!=null) 
   { 
    v=args[i+2];
  
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }        
	  
	  if(v=='visible' || v=='show')
	  {	 
	   clayer=MM_findObj('contentlayer');
	   if(tobj=MM_findObj(args[i]+'2')){
	          //width=tobj.offsetWidth;
	          height=tobj.offsetHeight;
	   }
	   if (clayer.style) 
	   	 clayer=clayer.style;
	    //clayer.width=width;
	  clayer.height=height;
	}	
	obj.visibility=v; 
	}
}

/*help popup function*/
var hw = null;
function Help(param,lang) {
  if (hw)
    hw.close();
  hw = null;
  hw = window.open("help/help_"+(new String(lang))+".php?IdCust="+CustId+"#"+param,"","height=400,width=600,scrollbars=yes");
}
/*********************/


/** rollover menu  **/
function setMenuStyle(id){
	if(!document.getElementById)
	return;
	/**restore color**/
	i=1;
	while(robj=document.getElementById("m"+i)){
		robj.className='menu';
		i++;
		}
	/*****************/
	document.getElementById(id).className='menu_selected';
}


/*rollover e highlighting styles function*/
function setScaleZoomBar(id_scale){
	/**restore color**/
	if (ns4) return;
	i=1;
	while(robj=document.getElementById("z"+i)){
		robj.className='zoombar';
		i++;
		}
	/*****************/
	document.getElementById("z"+id_scale).className='zoombar_selected';
}
function setBgColorModeBar(obj){
	/**restore color**/
	if (ns4) return;
	i=1;
	while(robj=document.getElementById("modbar"+i)){
		robj.className='mapmode';
		i++;
		}
	/*****************/
	obj.className='mapmode_selected';
}
/*******************************************/


/*set scale zoombar color*/
function CurrentScale(){
  var CurScale;
  var id_scale;
  CurScale  = document.uemapvw.GetScale();
  if (CurScale <= 2000)
  	setScaleZoomBar(1);
  else if (CurScale <= 10000)
  	setScaleZoomBar(2);
  else if (CurScale <= 25000)
    setScaleZoomBar(3);
  else if (CurScale <= 50000)
    setScaleZoomBar(4);
  else if (CurScale <= 250000)
	setScaleZoomBar(5);
  else if (CurScale <= 500000)
	setScaleZoomBar(6);
  else if (CurScale <= 1000000)
	setScaleZoomBar(7);
  else if (CurScale <= 2000000)
	setScaleZoomBar(8);
  else if (CurScale <= 5000000)
	setScaleZoomBar(9);
  else if (CurScale <= 10000000)
	setScaleZoomBar(10);
 
   
  if (CurScale > ScaleMaxPoi && StatusCheck==true){
	CheckStatus(true);
	StatusCheck=false;
	}
  else if (CurScale <= ScaleMaxPoi && StatusCheck==false){
  	CheckStatus(false);
  	StatusCheck=true;
  	}
}

function inimap(){
	//mostro il layer mappe
 if(Menu!=0 || IdLayout==1) {
  MM_showHideLayers('maplayer','','hide','pathlayer','','hide','stoplistlayer','','hide','poilayer','','show','kmlayer','','hide','poifilter','',poifilter);
  
  if(PathLayerView==1)
  {
   MM_showHideLayers('pathlayer','','show','stoplistlayer','','hide','maplayer','','hide','kmlayer','','hide','poifilter','',poifilter,'poilayer','','hide');
   setMenuStyle('m2');   
  }
  if(PathLayerView==2)
  {
   MM_showHideLayers('pathlayer','','hide','stoplistlayer','','show','maplayer','','hide','kmlayer','','hide','poifilter','',poifilter,'poilayer','','hide');
   setMenuStyle('m2');   
  }
  if(PathLayerView==3)
  {
   MM_showHideLayers('pathlayer','','show','stoplistlayer','','hide','maplayer','','show','kmlayer','','hide','poifilter','',poifilter,'poilayer','','hide');
   setMenuStyle('m1');   
  }
  if(MapLayerView)
  {
    MM_showHideLayers('maplayer','','show','pathlayer','','hide','stoplistlayer','','hide','poilayer','','hide','kmlayer','','hide','poifilter','',poifilter);
    setMenuStyle('m1');
  }
 }
 	
 setBgColorModeBar(document.getElementById('modbar1'));

 //setLang();		
}


function setRemaxPoiCategory(category,obj){
        switch(category){
                case 0:
                        document.uemapvw.SetPoiText('CUSTOM','',extra0);
                break;
                case 1:
                        document.uemapvw.SetPoiText('CUSTOM','',extra1);
                break;
        }
        if(!obj.checked){
                document.uemapvw.QueryPoiCategoryStatus();                
                }
        }
var wleg;
function ShowLegend(){		
	if(wleg!=null){wleg.close(); wleg=null;}	
	wleg=window.open('help/legenda_'+lang+'.php?IdCust='+CustId+'&NavCat='+NavCat,'','menu=mo,width=300,height=250,scrollbars=1');
}

function StreetListFilter() {
  
  list = document.ricercakm.StreetList;
  listTmp = document.ricercakm.StreetListTmp;

//  backup of the original dropdown list
  listBak = new Array();
  for (n=0;n<list.length;n++){
    listBak[listBak.length] = new Array(list[n].value, list[n].text);
  }
  
  list.length=0;
  for (n=0;n<listTmp.length;n++){
    list.options[list.length] = new Option(listTmp[n].text);
    list[n].value = listTmp[n].value;
  }

  listTmp.length=0;
  for (n=0;n<listBak.length;n++){
    listTmp.options[listTmp.length] = new Option(listBak[n][1]);
    listTmp[n].value = listBak[n][0];
  }
  list.bak = 0;
  list.selectedIndex=0;
}

function SelectCatFilter(pattern, list,len){                                                                                                                        
   
   if(pattern.value.length>0 && pattern.value.length<len) return;

//  La prima volta viene eseguito un backup della lista
  if (!list.bak){
//  backup of the original dropdown list
    list.bak = new Array();
    for (n=0;n<list.length;n++){
      list.bak[list.bak.length] = new Array(list[n].value, list[n].text);
    }
  }

//  Ciclo su dropdown list backuppata
//  Se match con valore input, viene aggiunto all'array dei match
//  altrimenti all'array dei no match

  tomatch = new Array();
  match = new Array();
  nomatch = new Array();
  
  tomatch = list.bak;
  
  if(pattern.value!=null && pattern.value!='')
  {
   for (n=0;n<tomatch.length;n++){
    if(tomatch[n][1].toLowerCase().indexOf(pattern.value.toLowerCase())!=-1)
      match[match.length] = new Array(tomatch[n][0], tomatch[n][1]);
    else
      nomatch[nomatch.length] = new Array(tomatch[n][0], tomatch[n][1]);
   }
  }
  else
   match = tomatch;
  
  list.length=0;
  for (n=0;n<match.length;n++){
    list.options[list.length] = new Option(match[n][1]);
    list[n].value = match[n][0];
  }
  if(!pattern)
  {
    for (n=0;n<nomatch.length;n++){
      list.options[list.length] = new Option(nomatch[n][1]);
      list[n+match.length].value = nomatch[n][0];
    }
  }
  
  list.selectedIndex=0;
}

//-->

