/*************************************
PARAMETRI DI CONFIGURAZIONE START
*************************************/
Jrel="JMB2.0.1";
//StartScale=100000;//scala mappa inzialale se != -1
//StartX=2450601;//punto di partenza
//StartY=1073562;
StartScale=9999999;//scala mappa inzialale se != -1
StartX=2450000;//punto di partenza
StartY=1070000; 
IniFile="start.txt";

EndX=-1;//punto di arrivo (eventuale percorso se != -1)
EndY=-1;
SetStop=-1;//se 0 imposto come tappa di partenza il centro mappa; 1 come arrivo ; -1 non imposto
MapLayerView=true;//visualizzazione layer RICERCA 
PathLayerView=true;//visualizzazione layer PERCORSI
StopLayerView=false;//visualizzazione layer TAPPE
CoordLayerView=false;//visualizzazione layer MAPPA per COORDINATE
lang="ITA";//lingua di default
StaticMap=false;

// seting map dimension depending to window size

var winW = 630, winH = 460;
/*
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
  if (winW == 0 || winH == 0) {
    // for IE 6.0 or later
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
  }
 }
}
*/
function ResizeMapTemplate() {

  if (is_nav)
  {
     // JavaScript here for Navigator 4 
    winW = window.innerWidth;
    winH = window.innerHeight; 
  }
  else if (is_ie5)
  {
     // JavaScript here for IE 4 and later
    // winW = document.body.offsetWidth;
    winW = window.screen.availWidth;
    // winH = document.body.offsetHeight;
    winH = window.screen.availHeight;
  }
  else 
  { // ie 6
    winW = document.documentElement.offsetWidth;
    winH = document.documentElement.offsetHeight;
  }
  
  // alert('Client area: ('+winW+','+winH+')');
  // minimal video resolution 80x600
  dimx = winW - 475;
  dimy = winH - 170;
  if (winW > 820) {
    // 1024x768 video resolution
    dimx = winW - 525;
    dimy = winH - 320;
  }
  if (winW > 1040) {
    // 1280x1024 video resolution
    dimx = winW - 640;
    dimy = winH - 450;
  }
  if (winW > 1380) {
    // 1400x1050 video resolution
    dimx = winW - 700 /* 580 */;
    dimy = winH - 450;
  }
  if (winW > 1580) {
    // up t0 1600x... video resolution
    dimx = winW - 950 /* 650 */;
    dimy = winH - 450;
  }
  
  if (dimy < parseInt(dimx * 0.55))
    dimy = parseInt(dimx * 0.55);
}
ResizeMapTemplate();

// window.onresize= ResizeMapTemplate;
window.onresize = window.location.reload;

boxwidth=220;
PopupPathDetail=false;//visualizzazione percorso testuale (false pagina principale / true in popup)
PopupPoiDetail=false;//visualizzazione dettaglio poi
PopupPoiOnMap=false;//visualizzazione lista poi
SavePointButton=false;//funzionalitą "salva punto centrale"
PopupAddressList=true;
SplashUrl="images/splash_trenitalia.gif";
SetEncoding="1";
GsiScale=500000;
DefScale=7000;//scala mappe dettaglio

broker_list="TRENITALIA";
CustomPoiUrl="/Product/MRGate/MapGwJ.php";//deve essere sullo stesso Host
CustomXmlPoiDetail="/Product/Customers/StoreLocator/CustomPoiSL.php";//specificare un indirizzo assoluto
CustomHtmlPoiDetail="http://host/MB/Custom/PoiHtmlDetail.php";
LocalPoiBrokerUrl="http://maps.ubiest.com"+CustomPoiUrl;//specificare un indirizzo assoluto
mail_sender="Trenitalia Servizio Clienti <info@trenitalia.com>";//mittente invio mail

/*************************************
PARAMETRI DI CONFIGURAZIONE END
*************************************/
AL_HEADER="<TABLE border=0 cellspacing=0 cellpadding=2 width=100% class=addresslist><TR><TH class=left>"+l_prog+"</TH><TH>"+l_citta+"</TH><TH>"+l_frazione+"</TH><TH>"+l_indirizzo+"</TH></TR>";
AL_BODY="<TR><TD class=left>%N%</TD><TD><A HREF=\"%HREF%self.close();\">UBI_AMD4_UBI</A>&nbsp;</TD><TD><A HREF=\"%HREF%self.close();\">UBI_AMD5_UBI</A>&nbsp;</TD><TD class=right>UBI_ADDR_UBI&nbsp;UBI_NUM_UBI</TD></TR>";
AL_FOOTER="</TABLE>";

/*lista poi: il body č contenuto in un div che scrolla...*/
PL_HEADER="<TABLE cellpadding=0 cellspacing=0 border=0 class=poilist width="+(boxwidth-2)+"><TR><TH class=left align=right width=20>n</TH><TH align=left width=140>"+l_descrizione+"</TH><TH align=center width=20>"+l_icona+"</TH>%PL_HEADER_ADDSTOP%</TR><TR><TD colspan=4 class=nopadding><DIV class=poilist id=poilist style=\"overflow:auto;\"><TABLE class=poilist cellpadding=0 cellspacing=0 border=0 width=100%>";
PL_BODY="<TR %PD%><TD valign=top align=right class=left width=20>%N%</TD><TD valign=top class=poilist width=140><A href=\"#\" title=\"UBI_DESC_UBI\nUBI_AMD4_UBI UBI_ADDR_UBI\" onmouseover=\"%HREFHL%\" onmouseout=\"%HREFHL%\" onclick=\"%HREFDET%\" class=poilist>UBI_DESC_UBI</A></TD><TD valign=top align=center width=20><img src=\"PoiIcons/UBI_ICON_UBI.gif\" width=16 height=16></TD>%PL_BODY_ADDSTOP%</TR>";
PL_FOOTER="</TABLE></DIV></TD></TR></TABLE>";
PL_HEADER_ADDSTOP="<TH align=center width=58 class=right>"+l_tappa+"</TH>";
PL_BODY_ADDSTOP="<td class=right valign=top align=center><a href=\"%STARTSTOP%\" title=\""+t_imposta+" UBI_DESC_UBI "+t_partenza+"\"><img src=\"images/start.gif\" border=0></a><a href=\"%ENDSTOP%\" title=\""+t_imposta+" UBI_DESC_UBI "+t_destinazione+"\"><img src=\"images/end.gif\" border=0></a></td>";

PD_HEADER="<table width="+boxwidth+" cellspacing=1 cellpadding=1 class=poidetail>";
PD_BODY="<tr><td class=label  valign=top>&nbsp;"+l_detdescrizione+"</td><td>UBI_NAME_UBI</td><td align=right><a href=\"javascript:closedetail();\"><img style=closeimg src=\"images/close.gif\" border=0 title=\""+l_chiudi+"\"></a></td></tr>";
PD_BODY+="<tr><td class=label valign=top>&nbsp;"+l_detindirizzo+"</td><td>UBI_AMD4_UBI UBI_ADDR_UBI UBI_NUM_UBI</td></tr>";
PD_BODY+="<tr><td class=label valign=top>&nbsp;"+l_dettelefono+"</td><td>UBI_TEL_UBI</td></tr>";
PD_BODY+="<tr><td class=label valign=top>&nbsp;"+l_detgruppo+"</td><td>UBI_GD1_UBI</td></tr>";
PD_FOOTER="</table>";

TP_HEADER_H="<TR><TD colspan=7><TABLE cellpadding=0 cellspacing=0 width=100% border=0 class=\"pthstoplist\"><TR><TD width=1% class=labeltop>"+l_tipologia+"</TD><TD class=top>%ALGO%</TD></TR><TR><TD width=1% class=label>"+l_partenza+"</TD><TD><A href=\"#\" onclick=\"%HREF%\">%START%</A></TD></TR>";
TP_HEADER_B="<TR><TD class=label>"+l_tappa+"</TD><TD><A href=\"#\" onclick=\"%HREF%\">%STOP%</A></TD></TR>";
TP_HEADER_F="<TR><TD class=label>"+l_arrivo+"</TD><TD><A href=\"#\" onclick=\"%HREF%\">%END%</A></TD></TR></TABLE></TH></TR><TR><TH align=right class=left>"+l_prog+"</TH><TH colspan=2 align=center>"+l_manovra+"</TH><TH colspan=2 align=center>"+l_distanza+"</SCRIPT></TH><TH rowspan=2 align=right width=1% class=bottomright>"+l_tempototale+"</TH></TR><TR><TH colspan=3 class=bottomleft>&nbsp;</TH><TH class=bottom>"+l_passo+"</TH><TH class=bottom>"+l_tempototale+"</TH></TR>";
TP_BODY="<tr %PD%><td class=left align=right>%N%</td><td><img src=\"%MAN%\"></td><td WIDTH=99%><a HREF=\"#map\" onclick=\"%HREF%\">%STRC%</a>%AMD4FROM% %ADDRFROM%</td><td align=right>%STEP%</td><td align=right>%DIST%</td><td align=right>%TIME%</td></tr>";
TP_FOOTER="<TR class=\"footer\"><TD colspan=4 class=left>"+l_tempototale+"</TD><TD align=right>%DIST%</TD><TD align=right>%TIME%</TD></TR>";
/*************************************
PARAMETRI DI CONFIGURAZIONE END
*************************************/




javarel="1";//versione java di default
txtpathwidth="100%";
pthalgo=3;//tipologia percorso iniziale (se presente)
pthdet=3;//dettaglio percorso testuale
ShowMenu=true;//visualizzazione layer menu

/** FUNZIONI JS DA PASSARE ALL'APPLET**/
getmap_function="opener.GetMapAddressList";
verifyaddr_function="opener.LatedVerifyAddress";
js_address_addstop_function="opener.AddStop";
js_poi_addstop_function="AddStop";
js_txtpath_addstop_function="AddStop";
getboundarymap_function="GetBoundaryMap";//funzione dettaglio percorso testuale
getpthcenterstop_function="GetCenterMap";//funzione dettaglio percorso testuale
js_poi_infomap_function="CheckPoi";
js_poi_infotemplate_function="getPoiInfo";
js_poi_hl_function="poiHighLighting";
js_getpath_function="";
/**NOMI FUNZIONI JS DA PASSARE ALL'APPLET**/


/*get HTTP params*/
grplist="";
function getHTTPParams(){
        var str=document.location.href;
        var lsRegExp =/#/g;
        str=str.replace(lsRegExp,"");
        str=str.substr(str.search(/\?/)+1);
        params=str.split("&");
        for(i=0;i<params.length;i++){
        	eval(params[i]);
        	}	
}
/*****************/
getHTTPParams();//get HTTP params

/*QUESTA FUNZIONE VIENE RICHIAMATA DA IniMap()*/
var mapmode=0;
function configTemplate(){ 
        if(MapLayerView){ 
                //MM_showHideLayers('maplayer','','show','pathlayer','','hide','stoplayer','','hide','coordlayer','','hide');                                         
                  MM_showHideLayers('maplayer','','show','pathlayer','','hide','stoplayer','','hide','coordlayer','','hide');
                  setMenuStyle('m1');
                //document.getElementById("stoplayer").style.visibility='visible';
                }
        if(PopupPathDetail){
                getboundarymap_function="opener."+getboundarymap_function;
                js_txtpath_addstop_function="opener."+js_txtpath_addstop_function;
                }
        if(PopupPoiDetail){}
        if(PopupPoiOnMap){}

        if(StartX !=-1 && StartY != -1){
               mapmode=0;//map
               if(EndX !=-1 && EndY !=-1)
               mapmode=1;//path 
                }       

                                
        if(!PathLayerView){
                js_poi_addstop_function="";
        }
        
        /*******ADD BROKER (attivazione dei poi broker custom)******/   
        if(!StaticMap) {
         document.MapBroker.AddBroker("TRENITALIA",CustomPoiUrl,CustomXmlPoiDetail);
         //document.MapBroker.AddBroker("UBIEST","","");
        }
        else {
          parent.frames[1].SetParamConfig("CUSTOM_POI_URL",CustomPoiUrl);

        }
        /***************************************/
                
        /*******START GROUPS (gruppi visualizzati all'AVVIO) ************/  
        setCategory("UBIEST","NAV_3_4013");//stazioni
         //setCategory("UBIEST","NAV_1_991");//stazioni             
        setCategory("TRENITALIA","157.1_3_1");//biglietterie
        /*non modificare*/
        setHttpCategory();
        /****************/
        /************************************************/
        /***INTERVALLI SCALE DI VISUALIZZAZIONE GRUPPI POI UBIEST***/
        SetRenderRatio("UBIEST","",0,20000,32,32);
        SetRenderRatio("UBIEST","",20001,200000,16,16);
        /**********************************************************/
           
        /***INTERVALLI SCALE DI VISUALIZZAZIONE GRUPPI POI CUSTOM***/
        SetRenderRatio("TRENITALIA","",0,35000,32,32);
        SetRenderRatio("TRENITALIA","",35001,500000,16,16);                                     
        /*************************************************************************/
        
        SetLocalLayerParam("Ubilocal","spillo",0,50000000,38,38);

}
function SetRenderRatio(p_broker,p_group,p_start,p_end,p_width,p_height) {

 if(!StaticMap)
   document.MapBroker.SetRenderRatio(p_broker,p_group,p_start,p_end,p_width,p_height);
 else
   parent.frames[1].SetRenderRatio(p_broker,p_group,p_start,p_end,p_width,p_height);
	
}	


function SetLocalLayerParam(p_broker,p_id,p_start,p_end,p_width,p_height) {
 
 if(!StaticMap) {
    document.MapBroker.SetCategory(p_broker,p_broker,true,true);
    SetRenderRatio(p_broker,"",p_start,p_end,p_width,p_height);
 }
 else
   SetRenderRatio(p_broker,p_id,p_start,p_end,p_width,p_height);
}

function SetLocalLayer(p_id, p_type, p_x, p_y,p_img, p_url,p_tooltip) {      
 if(!StaticMap)                                                                                   
   document.MapBroker.SetLocalLayer(p_id, p_type, p_x, p_y,p_img, p_url,p_tooltip,"Ubilocal"); 
 else                                                                                             
   parent.frames[1].SetLocalLayer(p_id,"Ubilocal",p_type, p_x, p_y,p_img, p_url,p_tooltip);       

}      

