var isloading=0;var loadingid=0;var host;var theInterval=0;var LOADING_MAP=0;var LOADING_INFO=1;var LOADING_BOTH=2;var LOADING_MAP_R=3;var LOADING_BOTH_R=4;var tpHeight=120;var identifyPanel;var ajaxEnabled;var rsltWin=null;var needReload=false;var mapLocationStack=new Array();var sessSeq;var apiforeSize;function previousMap(){url="action=previousMap";send(url,"Map")}function printMap(){url=packageName+"/view/maptools/print.jsp?sessSeq="+sessSeq;showLoading();printWin=openwin(url,"",653,650*defaultMap.height/defaultMap.width+95)}function gotoCoordinate(a,b){if(a&&b){url="action=gotoCoordinate&x="+a+"&y="+b;send(url,"Map",LOADING_MAP)}}function showOverViewMap(){url="action=showOverviewMap";send(url,"Map",LOADING_MAP)}function fixedZoomIn(){send("action=fixedZoomIn","Map",LOADING_MAP)}function fixedZoomOut(){send("action=fixedZoomOut","Map",LOADING_MAP)}function zoom(c,b,e,a,d){url="action="+c+"&x1="+b+"&y1="+e+"&x2="+a+"&y2="+d;if(needReload){needReload=false;send_reload(url,"Map",LOADING_BOTH)}else{send(url,"Map",LOADING_MAP)}}function zoomToLevel(a){url="action=zoomtolevel&level="+a;if(needReload){needReload=false;send_reload(url,"Map",LOADING_BOTH)}else{send(url,"Map",LOADING_MAP)}}function panDirection(a){send("action=pan"+a,"Map",LOADING_MAP)}function getInitial(){send("action=fullExtent","Map",LOADING_MAP)}function identify(a,b){ajaxEngine.registerRequest("Identify",packageName+"/Identify.do");url="action=identify&x="+a+"&y="+b;send(url,"Identify",LOADING_MAP)}function drawRedline(a,b){ajaxEngine.registerRequest("Redline",packageName+"/Redline.do");checkRedline(a,b)}function latlong(a,b){ajaxEngine.registerRequest("DistanceMeasurement",packageName+"/DistanceMeasurement.do");url="action=latlong&selectedTab=latlong&x="+a+"&y="+b;send(url,"DistanceMeasurement",LOADING_BOTH)}function tree_latlong(a,b){ajaxEngine.registerRequest("TreeReport",packageName+"/TreeReport.do");url="action=latlong&selectedTab=tree_latlong&x="+a+"&y="+b;send(url,"TreeReport",LOADING_BOTH)}function measure(a,b){ajaxEngine.registerRequest("DistanceMeasurement",packageName+"/DistanceMeasurement.do");url="action=show&x="+a+"&y="+b;send(url,"DistanceMeasurement",LOADING_BOTH)}function showMeasure(a){if(typeof setDivToolClick=="function"&&document.getElementById("DistanceMeasurementForm")!=null){if(currInfoTab!="theLeft2"){tab_theLeft2_Click()}if(a=="latlong"){setDivToolClick(document.getElementById("latlong_td"))}else{if(a=="measure"){setDivToolClick(document.getElementById("measure_td"))}else{if(a=="getheight"){setDivToolClick(document.getElementById("getheight_td"))}else{if(a=="area"){setDivToolClick(document.getElementById("area_td"))}}}}}else{ajaxEngine.registerRequest("DistanceMeasurement",packageName+"/DistanceMeasurement.do");send("action=init&measureMode="+a,"DistanceMeasurement",LOADING_BOTH)}}function showSNBReport(f){if(typeof setDivToolClick=="function"&&document.getElementById("SNBForm")!=null){if(currInfoTab!="theLeft2"){tab_theLeft2_Click()}setDivToolClick(document.getElementById("tree_latlong_td"))}else{var c="rslt";var a=f.split("|");f="";var j=new Array();var d,g,b,e;for(i=0;i<a.length;i++){if(a[i]==null||a[i]==""){continue}d=a[i];f+=d+"&";if(d.indexOf("=")>-1){g=d.split("=");j[g[0]]=g[1]}}if(j.action==null){f+="action=form&"}if(j.from_page==null){f+="from_page=form&"}if(j.districtName==null){f+="districtName="+window.default_district+"&"}f+="inbound=true&";ajaxEngine.registerRequest("SNB",packageName+"/SNB.do");send(f,"SNB",LOADING_BOTH)}}function showDCE(){ajaxEngine.registerRequest("DCE",packageName+"/DCE.do");send("action=form","DCE",LOADING_BOTH)}function showCPEVForm(){ajaxEngine.registerRequest("DepartmentFaci",packageName+"/DepartmentFaci.do");var a="action=form&reset=1&depId=-1&catId=-1";a+="&catAbbr=CPEV";a+="&depName=SWD";a+="&depInfo=ENB";a+="&catName=Charging Points for Electric Vehicles";a+="&nameBundle=gihs12";a+="&nameKey=gihs12.cpev";a+="&tabIndex=-1";send(a,"DepartmentFaci",LOADING_BOTH)}function showSWDForm(d){ajaxEngine.registerRequest("DepartmentFaci",packageName+"/DepartmentFaci.do");if(d!=undefined&&d!=""){d=d.replace(" ","");var b=false;var f=["CAAB","CASD","CCC","CH","CISU","CLEICS","CRDC","CRN","DAC","DSCPD","DSWO","EETC","EHS","ELDERLY","HMMH","HSMH","HSPH","HSPH_MH","HWH","HWH_SP","ICCMW","IFS","IRSC","IVRSC","IVTC","LSCH","MHCCC","MSC","MSS","NSCCP","OCCS","PRC","RSCCC","RTC","SCCC","SCCO","SHOS","SRCS","SS","SSAB","SW","TAVAS","TCSC","YOUTH"];var e=["CH","CISU","CLEICS","SCCO","SSAB","TAVAS","TCSC","MSC","RTC","HSPH_MH","IVTC","CRDC","CRN","LSCH","PRC","RSCCC","HSPH","IRSC","CAAB","DSWO","NSCCP","CCC","HWH_SP","DSCPD","SRCS","CASD"];for(var c=0;c<f.length;c++){if(f[c]==d.toUpperCase()){b=true;break}}if(b){var g="action=form&reset=1&depId=-1&catId=-1";g+="&catAbbr="+d.toUpperCase();g+="&depName=SWD";g+="&depInfo=SWD";g+="&catName="+d.toUpperCase();g+="&nameBundle=gihs9";g+="&nameKey=gihs9."+d.toLowerCase();g+="&tabIndex=9";g+="&directLink=true";for(var a=0;a<e.length;a++){if(e[a]==d.toUpperCase()){g+="&rslt=0";break}}send(g,"DepartmentFaci",LOADING_BOTH)}else{selectTab(9)}}else{selectTab(9)}}function showBWQForm(a){ajaxEngine.registerRequest("BeachWQ",packageName+"/BeachWQ.do");send("action=form&identify=true&beach_code="+a,"BeachWQ",LOADING_BOTH)}function showTreeReport(){if(typeof setDivToolClick=="function"&&document.getElementById("TreeReportForm")!=null){if(currInfoTab!="theLeft2"){tab_theLeft2_Click()}setDivToolClick(document.getElementById("tree_latlong_td"))}else{ajaxEngine.registerRequest("TreeReport",packageName+"/TreeReport.do");send("action=init","TreeReport",LOADING_BOTH)}}function pan(b,a){url="action=pan&dx="+b+"&dy="+a;if(needReload){needReload=false;send_reload(url,"Map",LOADING_BOTH)}else{send(url,"Map",LOADING_MAP)}}function selectTab(c,a,b,e){if(c=="USERS"){send("selected=UsersPage","Map",LOADING_INFO);return}if(c=="TOOLS"){send("selected=ToolsPage","Map",LOADING_INFO);return}if(c=="CLUSTER"){if(a!=null){highlightInfoTab(a,true);autoHighlightInfoTab=false}send("selected=ClusterPage","Map",LOADING_INFO);return}url="selected="+c;if(b!=null){url+="&expandCat="+b}if(e!=null){url+="&noUpdateCat="+e}var d=(c==0)?LOADING_BOTH:LOADING_INFO;send(url,"Map",d)}function clearSelected(a,d,c,b){if(rsltWin!=null){rsltWin.close()}setMessage(a,d,[{text:c,handler:function(){jg_itemCount=0;send("action=clearSelected","Map",LOADING_MAP);this.cancel()}},{text:b,handler:setMessage_handleOK}])}function backMapPos(){var b;if(mapLocationStack.length>1){mapLocationStack.pop();b=mapLocationStack.pop();var a=(b.extent[2]+b.extent[0])/2;var c=(b.extent[3]+b.extent[1])/2;send("action=gotoCoordinateWithZoom&back=1&x="+a+"&y="+c+"&zoomLv="+b.zoomLv,"Map",LOADING_MAP_R)}}window.size=function(){var a=0;var b=0;if(!window.innerWidth){if(!(document.documentElement.clientWidth==0)){a=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else{a=document.body.clientWidth;b=document.body.clientHeight}}else{a=window.innerWidth;b=window.innerHeight}return{width:a,height:b}};window.outersize=function(){var a=0;var b=0;if(!window.outerWidth){if(!(document.documentElement.offsetWidth==0)){a=document.documentElement.offsetWidth;b=document.documentElement.offsetHeight}else{a=document.body.offsetWidth;b=document.body.offsetHeight}}else{a=window.outerWidth;b=window.outerHeight}return{width:a,height:b}};function setWindowMinSize(){wh=window.outersize();if(wh[0]<800||wh[1]<600){window.resizeTo(800,600)}}function resize(l,n,c,m,g,o,a,j,d){var p=tpHeight;var b=36;var e=318;var k=0;if(l!=undefined&&l==1){e=0}w=window.size().width-e-k;h=window.size().height-p-b;url="action=resize&sv=true&width="+w+"&height="+h+"&screenWidth="+screen.width+"&prevW="+window.outersize().width+"&prevH="+window.outersize().height;if(n!=undefined&&n!="null"){url+="&gih3ID="+n}if(c!=undefined&&c!="null"){url+="&lang="+c}if(m!=undefined&&m!=""&&m!="null"){var f=unescape(m);f=encodeURIComponent(f);url+="&locationKeyword="+f;if(a!=undefined&&a!=""&&a!="null"){url+="&toolname="+a}if(j!=undefined&&j!=""&&j!="null"){url+="&toolversion="+j}}if(o!=undefined){url+="&initial=true"}if(l!=undefined){url+="&layout="+l}if(d!=undefined){url+="&tab="+d}if(g!=null){g=g.replace("/index.jsp","");g=g.replace("/gih3","")}if(g==undefined||g==null){location.href=packageName+"/Map.do?"+url}else{location.href=g+packageName+"/Map.do?"+url}}function gotoMain(f){if(!f){f="true"}ajaxEngine.registerRequest("Map",packageName+"/Map.do");var j=tpHeight;var g=36;var e=318;if(window.size().width<1024){e=318}var d=0;var a=window.size().width-e-d;var c=window.size().height-j-g;var b="action=resize&sv=true&width="+a+"&height="+c+"&screenWidth="+screen.width+"&prevW="+window.outersize().width+"&prevH="+window.outersize().height+"&lite="+f;location.href=packageName+"/Map.do?"+b}function resizeMap(a,b){var f=tpHeight;var e=36;var d=315;var c=0;if(layout!=undefined&&layout==1){d=0}if(a==undefined){a=window.size().width-d-c}if(b==undefined){b=window.size().height-f-e}action="action=resizeMap&width="+a+"&height="+b+"&screenWidth="+screen.width+"&prevW="+window.outersize().width+"&prevH="+window.outersize().height;send(action,"Map",LOADING_MAP);return[a,b]}function setLayerOnOff(){ajaxEngine.registerRequest("LayerOnOff",packageName+"/LayerOnOff.do");send("action=show","LayerOnOff",LOADING_BOTH)}function setOrthoMap(){ajaxEngine.registerRequest("OrthoMap",packageName+"/OrthoMap.do");send("action=form","OrthoMap",LOADING_INFO)}function showUFlag(){ajaxEngine.registerRequest("UFlag",packageName+"/UFlag.do");send("action=main","UFlag",LOADING_INFO)}function showRedline(){ajaxEngine.registerRequest("Redline",packageName+"/Redline.do");send("action=main","Redline",LOADING_INFO)}function showShare(){ajaxEngine.registerRequest("Share",packageName+"/Share.do");send("action=menu","Share",LOADING_INFO)}function showQuickShare(){ajaxEngine.registerRequest("QuickShare",packageName+"/QuickShare.do");send("action=main&saveAsURLOnly=true","QuickShare",LOADING_INFO)}function showDrawing(a){ajaxEngine.registerRequest("Drawing",packageName+"/Drawing.do");send("action=main&draw=false&drawingMode="+a,"Drawing",LOADING_INFO)}function showPSIDownload(){ajaxEngine.registerRequest("PSI",packageName+"/PSI.do");send("action=main","PSI",LOADING_INFO)}function send_nav(d,b,c,a){captureMapLocation(d,c);if(c==LOADING_MAP_R){c=LOADING_MAP}send(d,b,c,a)}function send_reload(f,c,e,b,d){f=f+"&reload=1";if(b==undefined){b=hideLoading}if(!isloading){captureMapLocation(f,e);if(e==LOADING_MAP_R){e=LOADING_MAP}showLoading(e);isloading=1;if(c==null){c="Map"}if(ajaxEnabled==undefined){ajaxEnabled="true"}if(maps.map_default!=undefined){maps.map_default.hideHighlightBox()}if(ajaxEnabled=="true"||ajaxEnabled){f+="&sessSeq="+sessSeq;ajaxEngine.sendRequestAndUpdate(c,this,{parameters:f,evalScripts:true,onComplete:b,onFailure:reportFailure,onException:reportException})}else{var a=ajaxEngine.requestURLS[c];if(a==null){a=packageName+"/"+c+".do"}linkClicked=1;location.href=a+"?"+f}}else{setMessage(actionFail)}}function send(f,c,e,b,d){if(f==undefined){return}if(b==undefined){b=hideLoading}if(f==undefined){return}if(!isloading){captureMapLocation(f,e);if(e==LOADING_MAP_R){e=LOADING_MAP}showLoading(e);isloading=1;if(c==null){c="Map"}if(ajaxEnabled==undefined){ajaxEnabled="true"}if(maps.map_default!=undefined){maps.map_default.hideHighlightBox();maps.map_default.hideSelectBox()}if(ajaxEnabled=="true"||ajaxEnabled){f+="&sessSeq="+sessSeq;ajaxEngine.sendRequestAndUpdate(c,this,{parameters:f,evalScripts:true,onComplete:b,onFailure:reportFailure,onException:reportException})}else{var a=ajaxEngine.requestURLS[c];if(a==null){a=packageName+"/"+c+".do"}linkClicked=1;location.href=a+"?"+f}}else{}}function reportFailure(a){hideLoading();setMessage(generalError)}function reportException(b,a){hideLoading();setMessage(exceptionError)}function hideLoading(){if(document.getElementById("loadingDiv")!=null){document.getElementById("loadingDiv").style.visibility="hidden"}if(document.getElementById("loadingDiv2")!=null){document.getElementById("loadingDiv2").style.visibility="hidden"}if(document.getElementById("loadingBackground")!=null){setTimeout('document.getElementById("loadingBackground").style.visibility="hidden"',500)}isloading=0;window.clearTimeout(loadingid);loadingid=0;faciOptions=document.forms.KeywordSearchForm.formCategory;if(faciOptions){faciOptions.disabled=false}}function hideLoadingWithWarning(){setMessage(unknownError);hideLoading()}function showLoading(g){try{if(railwayPanel!=null){railwayPanel.hide()}}catch(d){}g=LOADING_BOTH;var j=document.getElementById("naviDIV");var a=document.getElementById("mapDIV");var c=document.getElementById("toolDIV");var b=70;var f=78;if(document.getElementById("loadingDiv")!=null&&layout!=null){document.getElementById("loadingDiv").style.left=defaultMap.width/2-b/2;document.getElementById("loadingDiv").style.top=defaultMap.height/2-f}if(g==undefined||g==LOADING_MAP){if(document.getElementById("loadingDiv")!=null){document.getElementById("loadingDiv").style.visibility="visible"}if(document.getElementById("loadingBackground")!=null){document.getElementById("loadingBackground").style.visibility="visible"}hideAllMaptips()}else{if(g==LOADING_INFO){if(document.getElementById("loadingDiv2")!=undefined){document.getElementById("loadingDiv2").style.visibility="visible"}}else{if(g==LOADING_BOTH){if(document.getElementById("loadingDiv")!=null){document.getElementById("loadingDiv").style.visibility="visible"}if(document.getElementById("loadingBackground")!=null){document.getElementById("loadingBackground").style.visibility="visible"}hideAllMaptips()}}}faciOptions=document.forms.KeywordSearchForm.formCategory;if(faciOptions){faciOptions.disabled=true}if(loadingid==0){loadingid=window.setTimeout("hideLoadingWithWarning()",120000)}}function timeOut(){setMessage(connectTimeout);if(opener!=undefined){opener.focus();opener.location.href=packageName+"/view/index.jsp";window.close()}else{location.href=packageName+"/view/index.jsp"}}function captureMapLocation(b,a){}function addIE7Plugin(){this.ver=navigator.appVersion;if((this.ver.indexOf("MSIE 7")>-1||this.ver.indexOf("MSIE 8")>-1||this.ver.indexOf("MSIE 9")>-1)&&this.dom&&window.external&&("AddSearchProvider" in window.external)){window.external.AddSearchProvider(host+packageName+"/view/maptools/ie7-geoinfoMap.xml")}else{setMessage(ie7pluginError)}}function addIE8Plugin(a){this.ver=navigator.appVersion;this.dom=document.getElementById?1:0;if((this.ver.indexOf("MSIE 8")>-1||this.ver.indexOf("MSIE 9")>-1)&&this.dom){window.external.addService(host+packageName+"/view/maptools/ie8-geoinfoMap.xml")}else{setMessage(ie8AcceleratorError)}}function addFirefoxPlugin(){if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)&&window.external&&("AddSearchProvider" in window.external)){window.external.AddSearchProvider(host+packageName+"/view/maptools/firefox-geoinfoMap.xml")}else{setMessage(ffpluginError)}}function addFirefoxAddon(){if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){window.open("https://addons.mozilla.org/firefox/addon/geoinfo-map/")}else{setMessage(ffpluginError)}}function mbrowser_reload(){var b=(packageLang=="tw")?"tc":((packageLang=="zh")?"sc":packageLang);var a=window.location.href;a=a.replace(/\?.*/,"");a+="?lg="+b;window.location.href=a}function showMeasureToolsMax(){document.getElementById("measureToolSwitchMax").parentNode.parentNode.style.display="none";document.getElementById("measureToolSwitchMin").parentNode.parentNode.style.display="";document.getElementById("measureDistanceToolBtn").parentNode.parentNode.style.display="";document.getElementById("measureAreaToolBtn").parentNode.parentNode.style.display="";measuretoolsIsMax=true}function showMeasureToolsMin(){document.getElementById("measureToolSwitchMin").parentNode.parentNode.style.display="none";document.getElementById("measureToolSwitchMax").parentNode.parentNode.style.display="";document.getElementById("measureDistanceToolBtn").parentNode.parentNode.style.display="none";document.getElementById("measureAreaToolBtn").parentNode.parentNode.style.display="none";measuretoolsIsMax=false}function showDrawToolsMax(){document.getElementById("drawToolSwitchMax").parentNode.parentNode.style.display="none";document.getElementById("drawToolSwitchMin").parentNode.parentNode.style.display="";document.getElementById("drawPolyToolBtn").parentNode.parentNode.style.display="";document.getElementById("drawOvalToolBtn").parentNode.parentNode.style.display="";document.getElementById("drawSymbolToolBtn").parentNode.parentNode.style.display="";document.getElementById("drawTextToolBtn").parentNode.parentNode.style.display="";drawingtoolsIsMax=true}function showDrawToolsMin(){document.getElementById("drawToolSwitchMin").parentNode.parentNode.style.display="none";document.getElementById("drawToolSwitchMax").parentNode.parentNode.style.display="";document.getElementById("drawPolyToolBtn").parentNode.parentNode.style.display="none";document.getElementById("drawOvalToolBtn").parentNode.parentNode.style.display="none";document.getElementById("drawSymbolToolBtn").parentNode.parentNode.style.display="none";document.getElementById("drawTextToolBtn").parentNode.parentNode.style.display="none";drawingtoolsIsMax=false}function showWeatherToolsSize(a){if(a==1){showWeatherToolsMin()}else{if(a==2){showWeatherToolsNormal()}else{if(a==3){showWeatherToolsMax()}}}}function showWeatherToolsNextSize(){var b=weathertoolsSize;if(b==2){showWeatherToolsMax()}else{if(b==3){showWeatherToolsNormal()}}var a=document.getElementById("weatherDIV");a.clicked=true}function hideWeatherTblTip(){var b=document.getElementById("weatherInfoNormalTbl");var a=document.getElementById("weatherInfoMaxTbl");b.title="";a.title=""}function showWeatherToolsPrevSize(){var a=weathertoolsSize;if(a==2){showWeatherToolsMax()}else{if(a==3){showWeatherToolsNormal()}}}function showWeatherToolsMin(){winfo_n_css.style.display="none";winfo_x_css.style.display="none";winfo_s_css.style.display="";document.getElementById("weatherInfoBgPanel").style.display="none";document.getElementById("weatherInfoHkoIcon").style.display="none";weathertoolsSize=1}function showWeatherToolsMax(){winfo_n_css.style.display="none";winfo_s_css.style.display="none";winfo_x_css.style.display="";document.getElementById("weatherInfoBgPanel").style.display="";document.getElementById("weatherInfoHkoIcon").style.display="";weathertoolsSize=3;var a=document.getElementById("weatherInfoPanel");if(a.offsetHeight>0){winfo_bg_img_css.style.height=((a.offsetHeight>10)?(a.offsetHeight-10):0)+"px"}if(a.offsetWidth>0){winfo_bg_img_css.style.width=((a.offsetWidth>40)?(a.offsetWidth-40):0)+"px"}}function showWeatherToolsNormal(){winfo_x_css.style.display="none";winfo_s_css.style.display="none";winfo_n_css.style.display="";document.getElementById("weatherInfoBgPanel").style.display="none";document.getElementById("weatherInfoHkoIcon").style.display="none";weathertoolsSize=2}function showAPIForeToolsMax(){apifore_x_css.style.display="";apifore_n_css.style.display="none";apiforeSize=1}function hideAPIForeToolsMax(){apifore_x_css.style.display="none";apifore_n_css.style.display="";apiforeSize=0}function controlAPIForeTools(){var a=apiforeSize;if(a==0){apifore_x_css.style.display="none";apifore_n_css.style.display=""}else{if(a==1){apifore_x_css.style.display="";apifore_n_css.style.display="none"}else{apifore_x_css.style.display="none";apifore_n_css.style.display=""}}}function weatherIconClick(g,f){if(f==1){var d=YAHOO.util.Event.getXY(g);var b=YAHOO.util.Dom.getXY("weatherInfoPanel");var c=Math.abs(d[0]-b[0]);var a=Math.abs(d[1]-b[1]);if(c<50&&a<72){YAHOO.util.Event.stopEvent(g);window.open(hko7daysUrl)}}}function weatherIconTips(k,j){if(j==1){var g=YAHOO.util.Event.getXY(k);var c=YAHOO.util.Dom.getXY("weatherInfoPanel");var d=Math.abs(g[0]-c[0]);var b=Math.abs(g[1]-c[1]);var f=document.getElementById("weatherInfoNormalTbl");var a=document.getElementById("weatherInfoMaxTbl");if(d<50&&b<72){if(f.title!=hko7daysTip){f.title=hko7daysTip;a.title=hko7daysTip}}else{f.title=hkoExpandTip;a.title=hkoMinimizeTip}}}function reactivateMapTool(a){if(isIE){if(a=="pan"){document.getElementById("pan").click()}else{if(a=="zoomout"){(document.getElementById("zoomoutTool")).click()}else{if(a=="zoomin"){(document.getElementById("zoominTool")).click()}else{if(a=="identify"){(document.getElementById("identify2")).click()}}}}}else{if(a=="pan"){document.getElementById("pan").onclick()}else{if(a=="zoomout"){(document.getElementById("zoomoutTool")).onclick()}else{if(a=="zoomin"){(document.getElementById("zoominTool")).onclick()}else{if(a=="identify"){(document.getElementById("identify2")).onclick()}}}}}};
