﻿var map;var MarkersArr=[];var MarkersC=[];var loadminX=0;var loadminY=0;var loadmaxX=0;var loadmaxY=0;j(document).ready(function(){Q();function Q(){j("#showArea").click(O);for(i=1;i<14;i++){j("#showArea"+i).click(R);}j("#btngo").click(G);var X=j("#lat_s").val();var W=j("#lng_s").val();var V=j("#lay_s").val();F(X,W,13);if(j("#showArea").attr("checked")){I();}}function F(X,W,V){map=new GMap2(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.addControl(new GOverviewMapControl());map.setCenter(new GLatLng(X,W),V);map.enableDoubleClickZoom();map.enableContinuousZoom();B(map.getCenter());C();GEvent.addListener(map,"moveend",function(){var Y=map.getCenter();J(Y.lat(),Y.lng());if(j("#showArea").attr("checked")){M();}C();});}function J(W,V){j("#lat").val(W);j("#lng").val(V);}function B(V){j("#lat").val(V.lat());j("#lng").val(V.lng());}function G(){map.panTo(new GLatLng(j("#cselect").val().split("|")[1],j("#cselect").val().split("|")[0]));j("#btngo").attr("style","display:none");}function U(){var V=new GIcon();V.image="../img/marker/marker.png";V.shadow="../img/marker/shadow50.png";V.iconSize=new GSize(20,34);V.shadowSize=new GSize(37,34);V.iconAnchor=new GPoint(9,34);V.infoWindowAnchor=new GPoint(9,2);V.infoShadowAnchor=new GPoint(18,25);return V;}function E(X){var W=new GIcon(U);var V=new GMarker(X,{icon:W,draggable:true});GEvent.addListener(V,"click",function(){V.openInfoWindowHtml("");});return V;}function C(){j.waitInfoShow();Guide.ChangeCity(j("#lng").val(),j("#lat").val(),function(V){T(document.getElementById("pselect"),V[0],V[0]);K(document.getElementById("cselect"));for(var W=0;W<(V.length-2)/3;W++){L(document.getElementById("cselect"),V[W*3+2],V[W*3+3]+"|"+V[W*3+4]+"|"+V[W*3+2]);}T(document.getElementById("cselect"),V[1],V[1]);j("#a_city").text(V[1]);j("#a_city").attr("href","/city/"+V[1]);j.waitInfoHide();});}function T(X,Y,V){for(var W=0;W<X.options.length;W++){if(X.options[W].text==V){X.options[W].selected=true;break;}}}function K(V){V.options.length=0;}function L(X,Y,V){var W=new Option(Y,V);X.options.add(W);}function M(){var a=map.getBounds();var d=a.getSouthWest().lng();var X=a.getSouthWest().lat();var Z=a.getNorthEast().lng();var c=a.getNorthEast().lat();var V=map.getZoom();var Y=map.getBounds();var b=map.getCurrentMapType();var W;W=0;if(loadminX>d||loadminY>X||loadmaxX<Z||loadmaxY<c){j.waitInfoShow();Guide.GetPoints(d,Z,X,c,V,W,function(e){if(e.Count>0){j("#items").empty();j("#navi").empty();j("#flyto").empty();j.each(e.Rows,function(g,h){var f=j('<a href="p'+h.buildingID+'"><p>'+h.buildingName+"><br/><br/><br/><br/><br/><br/></p></a>");f.mouseover(function(){N(h.Y/1000000,h.X/1000000,13);S(h.buildingID);});j("#items").append(f);});j("div.playlist").scrollable({size:5,speed:500,prev:".prev",next:".next",begin:".begin",end:".end"});j.each(e.Rows,function(h,k){var f="";var g=5;H(k.X/1000000,k.Y/1000000,k.Type,k.buildingID,k.buildingName,f,h,g,k.rownum);});}});j.waitInfoHide();}loadminX=d-(Z-d)/5;loadminY=X-(c-X)/5;loadmaxX=Z+(Z-d)/5;loadmaxY=c+(c-X)/5;}function I(){var a=map.getBounds();var d=a.getSouthWest().lng();var X=a.getSouthWest().lat();var Z=a.getNorthEast().lng();var c=a.getNorthEast().lat();var V=map.getZoom();var Y=map.getBounds();var b=map.getCurrentMapType();var W;W=0;j.waitInfoShow();Guide.GetPoints(d,Z,X,c,V,W,function(e){if(e.Count>0){j("#items").empty();j("#navi").empty();j("#flyto").empty();j.each(e.Rows,function(g,h){var f=j('<a href="p'+h.buildingID+'"><p>'+h.buildingName+"><br/><br/><br/><br/><br/><br/></p></a>");f.mouseover(function(){N(h.Y/1000000,h.X/1000000,13);S(h.buildingID);});j("#items").append(f);});j("div.playlist").scrollable({size:5,speed:500,prev:".prev",next:".next",begin:".begin",end:".end"});j.each(e.Rows,function(h,k){var f="";var g=5;H(k.X/1000000,k.Y/1000000,k.Type,k.buildingID,k.buildingName,f,h,g,k.rownum);});}j.waitInfoHide();});loadminX=d-(Z-d)/5;loadminY=X-(c-X)/5;loadmaxX=Z+(Z-d)/5;loadmaxY=c+(c-X)/5;}function H(Y,Z,W,V,b,g,a,d,e){if(MarkersArr[V]==null){var f;var c=new Object();c.icon=A(W);point=new GLatLng(Z,Y);f=new GMarker(point,c);f.type=W;f.id=V;MarkersC[V]=f;MarkersArr[V]=new D(V,Z,Y,b,g,W,d,f);var X;X=GEvent.addListener(f,"click",function(){window.location.href="/place/"+V;});GEvent.addListener(f,"mouseover",function(){j("#flyto span[item="+e+"]").click();showCursorMessage(b);});GEvent.addListener(f,"mouseout",function(){hideCursorMessage();});if(document.getElementById("showArea").checked==true){map.addOverlay(f);}}}function D(V,Y,X,Z,c,W,b,a){this.id=V;this.x=X;this.y=Y;this.title=Z;this.htmlContent=c;this.color=W;this.lay=b;this.marker=a;}function O(){if(j("#showArea").attr("checked")){M();}if(document.getElementById("showArea").checked==false){for(var V in MarkersArr){map.removeOverlay(MarkersC[V]);}for(V=1;V<13;V++){j("#showArea"+V).attr("checked","");}}else{for(var V in MarkersArr){map.addOverlay(MarkersC[V]);}for(V=1;V<13;V++){j("#showArea"+V).attr("checked","checked");}}}function R(){if(j(this).attr("checked")!=true){for(var V in MarkersArr){if(MarkersArr[V].color==j(this).val()){map.removeOverlay(MarkersC[V]);}}}else{for(var V in MarkersArr){if(MarkersArr[V].color==j(this).val()){map.addOverlay(MarkersC[V]);}}}}function S(X){for(var V in MarkersArr){if(V==X){var W='<b><a href="/place/'+MarkersArr[V].id+'">'+MarkersArr[V].title+"</a></b>"+MarkersArr[V].htmlContent;MarkersArr[V].marker.openInfoWindowHtml(W);return;}}}function A(W){var V=new GIcon();V.image="/img/marker/"+W+".png";V.shadow="/img/marker/mm_20_shadow.png";V.iconSize=new GSize(12,20);V.shadowSize=new GSize(22,20);V.iconAnchor=new GPoint(6,20);V.infoWindowAnchor=new GPoint(5,1);return V;}function P(){var V=map.getZoom();if(V>=17){return 6;}if(V>=14){return 5;}if(V>=11){return 4;}if(V>=5){return 3;}if(V>=3){return 2;}return 1;}function N(X,W,V){map.panTo(new GLatLng(X,W));}});