/* (C) 2007 ALPS MAPPING K.K. */
function AlpsUtil(){};AlpsUtil.getXMLHttp=function(){var xmlhttp;if(typeof ActiveXObject != 'undefined'){try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}}if(typeof XMLHttpRequest != 'undefined'){xmlhttp = new XMLHttpRequest();}return xmlhttp;};AlpsUtil.getXMLDOM=function(url){var xmlhttp=AlpsUtil.getXMLHttp();if (!xmlhttp) return;xmlhttp.open("GET", url, false);xmlhttp.send(null);if(xmlhttp.status==200||xmlhttp.status==304){return xmlhttp.responseXML;}};AlpsUtil.createXMLDOM=function(){var doc;if(typeof ActiveXObject != 'undefined'){doc=new ActiveXObject("Microsoft.XMLDOM");}else{doc=document.implementation.createDocument("", "", null);}if(doc.documentElement){doc.removeChild(doc.documentElement);}return doc;};AlpsUtil.getXMLDOMFromStr=function(str){try{if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){var doc=new ActiveXObject("Microsoft.XMLDOM");doc.loadXML(str);return doc;}else if(typeof DOMParser!="undefined"){return (new DOMParser()).parseFromString(str,"text/xml");}else{return null;}}catch(error){return null;}};AlpsUtil.getElementContent=function(e, tagName){var n=e.getElementsByTagName(tagName)[0];if(n) return AlpsUtil.getNodeContent(n);};AlpsUtil.getNodeContent=function(n){var nl=n.childNodes;if(nl.length==1) return nl[0].nodeValue;if(nl.length>1) return nl[1].nodeValue;};AlpsUtil.getElementAttribute=function(e, tagName, attrName){var n=e.getElementsByTagName(tagName)[0];if(n) return n.getAttribute(attrName);};AlpsUtil.getProperties=function(e){var a=new Object;var p=e.getElementsByTagName("property");for(var i=0;i<p.length;i++){var name=p[i].getAttribute("name");var value=p[i].getAttribute("value");if(!value) value=AlpsUtil.getNodeContent(p[i]);if(name&&value){a[name]=value;}}return a;};Array.prototype._indexOf=function(s){for(var i=0;i<this.length;i++){if(this[i]==s) return i;}return -1;};Array.prototype._clear=function(){while(this.pop());};Array.prototype._release=function(){if(_bi.type!=1)return;for(var i=0;i<this.length;++i){if(typeof(this[i])=="object"){_objrelease(this[i]);}delete this[i];}};function _setTimeout(obj,timeoutHandler,elapseTime){var arg=[];for(var i=3;i<arguments.length;++i){arg.push(arguments[i]);}var timerId=window.setTimeout(function(){timeoutHandler.apply(obj,arg);},elapseTime);return timerId;};function _setInterval(obj,timeoutHandler,elapseTime){var arg=[];for(var i=3;i<arguments.length;++i){arg.push(arguments[i]);}var timerId=window.setInterval(function(){timeoutHandler.apply(obj,arg);},elapseTime);return timerId;};function _objrelease(obj,hash){if(_bi.type!=1) return;if(!obj) return;if(typeof(obj)!="object") return;if(!hash&&typeof(obj.release)!="function") return;if(typeof(obj.releasing)=="function") return;obj.releasing=function(){};for(var i in obj){if(!obj[i]) continue;if(typeof(obj[i])=="object"){if(typeof(obj[i]._release)=="function"){obj[i]._release();}else if(typeof(obj[i].release)=="function"){obj[i].release();}delete obj[i];}else if(typeof(obj[i])!="function"){delete obj[i];}}};function BrowserInfo(){this.type=0;this.version=0;this.os=null;var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("opera")!=-1){this.type=4;this.version=9;if(ua.indexOf("opera/7")!=-1||ua.indexOf("opera 7")!=-1){this.version=7;}else if(ua.indexOf("opera/8")!=-1||ua.indexOf("opera 8")!=-1){this.version=8;}}else if(ua.indexOf("msie")!=-1&&document.all){this.type=1;this.version=6; if(ua.indexOf("msie 5")!=-1){this.version=5;}}else if(ua.indexOf("safari")!=-1){this.type=3;}else if(ua.indexOf("mozilla")!=-1){this.type=2;if(ua.indexOf("firefox")!=-1){this.subType=1;this.version=1.5;if(ua.indexOf("firefox/1.0")!=-1){this.version=1.0;}}else if(ua.indexOf("netscape")!=-1){this.subType=2;}else if(ua.indexOf("seamonkey")!=-1){this.subType=4;}else{this.subType=3;this.version=1.8;if(ua.indexOf("rv:1.7")!=-1){this.version=1.7;}}}if(ua.indexOf("x11;")!=-1){this.os=1;}else if(ua.indexOf("macintosh")!=-1){this.os=2;}};var _bi=new BrowserInfo();function AlpsEvent(){};function EventObj(source,eventName,ListnerFn){this.instance=source;this.propertyName=eventName;this.listenerFn=ListnerFn};AlpsEvent.addEvent=function(source,eventName,ListnerFn){var propName=AlpsEvent.getPropertyName(eventName);if(source[propName]==null){source[propName]=new Array;}source[propName].push(ListnerFn);return new EventObj(source,eventName,ListnerFn);};AlpsEvent.removeEvent=function(eventObj){var propName=AlpsEvent.getPropertyName(eventObj.propertyName);var eventAry=eventObj.instance[propName];for(var idx=0;idx<eventAry.length;idx++){if(eventAry[idx]==eventObj.listenerFn){eventAry.splice(idx,1);return;}}};AlpsEvent.clearEvents=function(source,eventName){var propName=AlpsEvent.getPropertyName(eventName);source[propName]=null;};AlpsEvent.triggerEvent=function(source,eventName){var eventFireFlag=AlpsEvent.getEventFireFlag(eventName);if(source[eventFireFlag]){return;} source[eventFireFlag]=1;var propName=AlpsEvent.getPropertyName(eventName);var listnerFn=source[propName];if(listnerFn&&listnerFn.length>0){var arg=[];for(var i=2;i<arguments.length;++i){arg.push(arguments[i])}for(var i=0;i<listnerFn.length;++i){var fn=listnerFn[i];if(fn){try{fn.apply(source,arg);}catch(e){}}}}delete source[eventFireFlag];};AlpsEvent.isEventRunning=function(source,eventName){var eventFireFlag=AlpsEvent.getEventFireFlag(eventName);if(source[eventFireFlag]){return true;}else{return false;}};AlpsEvent.bindEvent=function(source,eventName,object,method){return AlpsEvent.addEvent(source,eventName,function(){method.apply(object,arguments)})};AlpsEvent.bindBuiltInEvent=function(obj,event,object,method){var handler=AlpsEvent.makeBinder(object,method);return AlpsEvent.addBuiltInEvent(obj,event,handler);};AlpsEvent.makeBinder=function(object,method){return function(e){if(!e){e=window.event;}if(e&&!e.target){e.target=e.srcElement;}method.call(object,e);}};AlpsEvent.getPropertyName=function(eventName){return "_aevt_"+eventName;};AlpsEvent.getEventFireFlag=function(eventName){return "_fire_"+eventName;};AlpsEvent.addBuiltInEvent=function(obj,event,handler){if(_bi.type==3&&event=="dblclick"){obj["on"+event]=handler;return;}if(obj.addEventListener){obj.addEventListener(event,handler,false);}else if(obj.attachEvent){obj.attachEvent("on"+event,handler);}else{obj["on"+event]=handler;}};AlpsEvent.removeBuiltInEvent=function(obj,event,handler){if(obj.removeEventListener){obj.removeEventListener(event,handler,false);}else if(obj.detachEvent){obj.detachEvent("on"+event,handler);}else{obj["on"+event]=null;}};function AlpsCallback(){this.callbacks=new Object();this.timer=new Object();this.timeout=1500;};AlpsCallback.prototype.send=function(url,func){var id='ID'+(new Date().getTime().toString(16))+Math.floor(Math.random()*10000);var src=""+url;if(src.indexOf('?')<0){src+="?";}else{src+="&";}src+="_cbid="+id;this.callbacks[id]=func;var scr=document.createElement("script");scr.id=id;scr.src=src;scr.type="text/javascript";document.body.appendChild(scr);this.timer[id]=window.setTimeout(function(){_cb.invoke(id)},this.timeout);return id;};AlpsCallback.prototype.invoke=function(id){if(this.timer[id]){window.clearTimeout(this.timer[id]);delete this.timer[id];}var func=this.callbacks[id];if(!func) return;var args=new Array();for(var i=1;i<arguments.length;i++){args.push(arguments[i]);}delete this.callbacks[id];document.body.removeChild(document.getElementById(id));func.apply(this,args);};var _cb=new AlpsCallback();
function Point(xPos,yPos){this.x=xPos;this.y=yPos;};Point.prototype.set=function(xPos,yPos){this.x=xPos;this.y=yPos;};Point.prototype.rotate=function(origin,angle){var rdAngle=angle*Math.PI/180;var reltvX=this.x-origin.x;var reltvY=this.y-origin.y;var roteX=reltvX*Math.cos(rdAngle)-reltvY*Math.sin(rdAngle);var roteY=reltvX*Math.sin(rdAngle)+reltvY*Math.cos(rdAngle);this.x=origin.x+roteX;this.y=origin.y+roteY;};Point.distance=function(pos1,pos2){var reltvX=pos1.x-pos2.x;var reltvY=pos1.y-pos2.y;return Math.sqrt(reltvX*reltvX+reltvY*reltvY);};Point.sqdist=function(pos1,pos2){var reltvX=pos1.x-pos2.x;var reltvY=pos1.y-pos2.y;return reltvX*reltvX+reltvY*reltvY;};Point.angle=function(pos1,pos2){var reltvX=pos1.x-pos2.x;var reltvY=pos1.y-pos2.y;return Math.atan2(reltvY,reltvX)*180/Math.PI;};Point.prototype.toString=function(){return"("+this.x+", "+this.y+")";};Point.prototype.equals=function(X){if(!X)return false;return this.x==X.x&&this.y==X.y};Point.prototype.approxEquals=function(X){if(!X)return false;return approxCompare(this.x,X.x)&&approxCompare(this.y,X.y)};function Size(w,h){this.width=w;this.height=h};Size.prototype.set=function(w,h){this.width=w;this.height=h;};Size.prototype.toString=function(){return"("+this.width+", "+this.height+")";};Size.prototype.equals=function(s){if(!s)return false;return this.width==s.width&&this.height==s.height;};Size.prototype.approxEquals=function(s){if(!s)return false;return approxCompare(this.width,s.width)&&approxCompare(this.height,s.height);};function approxCompare(rh,Ai){return Math.round(rh*1000000)==Math.round(Ai*1000000)};
function Dms(degree){if(typeof(degree)=="string"){this.setByDmsStr(degree);}else if(typeof(degree)=="number"){this.setByDegree(degree);}};Dms.prototype.set=function(d,m,s){this.d=d;this.m=m;this.s=s;};Dms.prototype.setByDegree=function(degree){this.d=Math.floor(degree);var temp=(degree-this.d)*60;this.m=Math.floor(temp);this.s=(temp-this.m)*60;};Dms.prototype.setByDmsStr=function(str){var spStr=str.split("/");if(spStr.length==1){this.setByDegree(parseFloat(spStr[0]));}else if(spStr.length==2){var temp=parseFloat(spStr[1]);var m=Math.floor(temp);var s=(temp - m) * 60;this.set(Math.floor(parseFloat(spStr[0])),m,s);}else if(spStr.length==3){this.set(Math.floor(parseFloat(spStr[0])),Math.floor(parseFloat(spStr[1])),parseFloat(spStr[2]));}};Dms.prototype.getDegree=function(){var degree=0;if(this.d>=0){degree=this.d+this.m/60+this.s/60/60;}else{degree=this.d-this.m/60-this.s/60/60;}return degree;};Dms.prototype.toString=function(){var d=this.d;var m=this.m;var s=Math.round(this.s*1000)/1000;if(s==60){m+=1;s=0;if(m==60){d+=1;m=0;}}return d+"/"+m+"/"+s;};function LLPoint(latitude,longitude){this.lat=0;this.lon=0;if(arguments.length==1&&typeof(arguments[0])=="string"){var sp=arguments[0].split(",");this.lat=(new Dms(sp[0])).getDegree();this.lon=(new Dms(sp[1])).getDegree();}else{if(typeof(latitude)=="object"){this.lat=latitude.getDegree();}else if(typeof(latitude)=="string"){this.lat=(new Dms(latitude)).getDegree();}else{this.lat=latitude;}if(typeof(longitude)=="object"){this.lon=longitude.getDegree();}else if(typeof(longitude)=="string"){this.lon=(new Dms(longitude)).getDegree();}else{this.lon=longitude;}}};LLPoint.prototype.set=function(latitude,longitude){this.lat=latitude;this.lon=longitude;};LLPoint.prototype.toString=function(){return (new Dms(this.lat)).toString()+","+(new Dms(this.lon)).toString();};LLPoint.prototype.distance=function(pos){var radius=6370300.0;var x1=Math.cos(this.lon*Math.PI/180.0)*Math.cos(this.lat*Math.PI/180.0);var y1=Math.sin(this.lon*Math.PI/180.0)*Math.cos(this.lat*Math.PI/180.0);var z1=Math.sin(this.lat*Math.PI/180.0);var x2=Math.cos(pos.lon*Math.PI/180.0)*Math.cos(pos.lat*Math.PI/180.0);var y2=Math.sin(pos.lon*Math.PI/180.0)*Math.cos(pos.lat*Math.PI/180.0);var z2=Math.sin(pos.lat*Math.PI/180.0);var d = x1*x2+y1*y2+z1*z2;if(d<-1) d=-1;if(d>1) d=1;return radius*Math.acos(d);};function ConvertRADtoDEGREE(radAngle){return radAngle*180.0/Math.PI;};function ConvertDEGREEtoRAD(degAngle){return degAngle*Math.PI/180.0;};function BesslWgs(mode,lpPoint) {var eps=1.0e-15;var pi=Math.PI;var ar=new Array(2);ar[0]=6377397.155;ar[1]=6378137.000;var f=new Array(2);f[0]=1.0/299.152813;f[1]=1.0/298.257223563;var e2=new Array(2);e2[0]=f[0]*(2.0-f[0]);e2[1]=f[1]*(2.0-f[1]);var dx=new Array(2);var dy=new Array(2);var dz=new Array(2);dx[0]=-146.43;dy[0]=507.89;dz[0]=681.46;dx[1]=146.43;dy[1]=-507.89;dz[1]=-681.46;var _in=mode;var _out=1-mode;var b_in=ConvertDEGREEtoRAD(lpPoint.lat);  var l_in=ConvertDEGREEtoRAD(lpPoint.lon);  var h_in=0.0; var r_in=ar[_in]/Math.sqrt(1.0-e2[_in]*Math.sin(b_in)*Math.sin(b_in));var x_in=(r_in+h_in)*Math.cos(b_in)*Math.cos(l_in);var y_in=(r_in+h_in)*Math.cos(b_in)*Math.sin(l_in);var z_in=(r_in*(1.0-e2[_in])+h_in)*Math.sin(b_in);var x=x_in+dx[_in];var y=y_in+dy[_in];var z=z_in+dz[_in];var p=Math.sqrt(x*x+y*y);var mu0=z/p;var aa=Math.sqrt((1.0-e2[_out])*mu0*mu0+1.0);var aa3=aa*aa*aa;var ff=mu0-z/p-ar[_out]*e2[_out]*mu0/p/aa;var df=1.0-ar[_out]*e2[_out]/p/aa3;var mu1=mu0-ff/df;var aas;for(i=0;(ff>eps||-eps>ff)&&i<10;i++){mu0=mu1;aa=Math.sqrt((1.0-e2[_out])*mu0*mu0+1.0);aa3=aa*aa*aa;aas=ar[_out]*e2[_out]/p;ff=mu0-z/p-aas*mu0/aa;df=1.0-aas/aa3;mu1=mu0-ff/df;}var b_out=Math.atan2(mu1,1.0);var l_out=Math.atan2(y,x);var r_out=ar[_out]/Math.sqrt(1.0-e2[_out]*Math.sin(b_out)*Math.sin(b_out));return new LLPoint(ConvertRADtoDEGREE(b_out),ConvertRADtoDEGREE(l_out));};
function SProjection(projCode, origin, factor) {this.m_projCode = projCode; this.origin = new LLPoint(origin.lat, origin.lon); this.factor = factor; };SProjection.prototype.release=function(){_objrelease(this);};function EllipsoID(form) {this.form = form; if (form == 0) { this.a = 6370300.0;this.b = 6370300.0;this.e2 = 0.0;} else { this.a = 6377397.155;this.b = 6356078.96325;this.e2 = (this.a*this.a - this.b*this.b) / (this.a*this.a);}};function MercatorConversion(origin, form) {this.proj = new SProjection(1, origin, 1.0); this.ellipsoid = new EllipsoID(form); };MercatorConversion.prototype.QPI = Math.atan(1); MercatorConversion.prototype.EPS = 2.2204460492503131e-016; MercatorConversion.prototype.MAX = Number.MAX_VALUE; MercatorConversion.prototype.set = function(origin, form) {this.proj = new SProjection(1, origin, 1.0); this.ellipsoid = new EllipsoID(form); };MercatorConversion.prototype.getLLPoint = function(meterPoint) {var x = meterPoint.x;var y = meterPoint.y;var raOriginPhi = this.proj.origin.lat * Math.PI / 180;var raOriginLamda = this.proj.origin.lon * Math.PI / 180;var raLamda = 0;var raPhi = 0;var e, esin0, Radius0, Xm, XM, Y, delta;var a = this.ellipsoid.a;var b = this.ellipsoid.b;var e2 = this.ellipsoid.e2;e = Math.sqrt(e2); esin0 = e * Math.sin(raOriginPhi);Radius0 = a * Math.cos(raOriginPhi) / Math.sqrt(1 - e2*Math.sin(raOriginPhi)*Math.sin(raOriginPhi));Xm = -Radius0*(4*this.QPI + raOriginLamda);XM =  Radius0*(4*this.QPI - raOriginLamda);Y = this.MAX;if (-Y < y && y < Y) {raLamda = x/Radius0 + raOriginLamda;if (this.ellipsoid.form == 0) raPhi = 2*(Math.atan(Math.exp(y/Radius0)*Math.tan(this.QPI+raOriginPhi/2.0))-this.QPI);else { var i = 0;raPhi = 2*(Math.atan(Math.exp(y/Radius0)*Math.tan(this.QPI+raOriginPhi/2))-this.QPI); delta = Math.log(Math.tan(this.QPI+raPhi/2)/Math.tan(this.QPI+raOriginPhi/2))+e/2*(Math.log((1-e*Math.sin(raPhi))*(1+esin0)/(1-esin0)/(1+e*Math.sin(raPhi)))) - y/Radius0;while (delta <= -this.EPS || this.EPS <= delta) {raPhi -= delta/(1-e2)*(Math.cos(raPhi)*(1-e2*Math.sin(raPhi)));delta = Math.log(Math.tan(this.QPI+raPhi/2)/Math.tan(this.QPI+raOriginPhi/2))+e/2*(Math.log((1-e*Math.sin(raPhi))*(1+esin0)/(1-esin0)/(1+e*Math.sin(raPhi)))) - y/Radius0;i++;if ( 100 < i ) {break;}}}}if (raLamda > Math.PI) raLamda -= (2 * Math.PI);else if (raLamda < -Math.PI) raLamda += (2 * Math.PI);return new LLPoint(raPhi * 180 / Math.PI, raLamda * 180 / Math.PI);};MercatorConversion.prototype.getMeterPoint = function(lpPoint) {var raPhi = lpPoint.lat * Math.PI / 180;var raLamda = lpPoint.lon * Math.PI / 180;var raOriginPhi = this.proj.origin.lat * Math.PI / 180;var raOriginLamda = this.proj.origin.lon * Math.PI / 180;var a = this.ellipsoid.a;var b = this.ellipsoid.b;var e2 = this.ellipsoid.e2;var Radius0, esin0;var xx = 0, yy = 0;if( (-2*this.QPI + this.EPS < raPhi) && (raPhi < 2*this.QPI - this.EPS) ) {var e = Math.sqrt(e2); esin0 = e*Math.sin(raOriginPhi);Radius0 = a*Math.cos(raOriginPhi)/Math.sqrt(1-e2*Math.sin(raOriginPhi)*Math.sin(raOriginPhi));xx = Radius0*(raLamda-raOriginLamda);yy = Radius0*(Math.log(Math.tan(this.QPI+raPhi/2)/Math.tan(this.QPI+raOriginPhi/2)) +e/2*(Math.log((1-e*Math.sin(raPhi))/(1-esin0)) - Math.log((1+e*Math.sin(raPhi))/(1+esin0))));}return new Point(xx , yy);};MercatorConversion.prototype.release=function(){_objrelease(this);};function UTMConversion(origin, factor) {this.proj = new SProjection(0, origin, factor); };UTMConversion.prototype.A = 6377397.155; UTMConversion.prototype.E = 0.006674372231315; UTMConversion.prototype.meridian = function(raPhi1, raPhi2) {var Ba, Bb, Bc, Bd, Be;Ba = 1.005037306049 * (raPhi2 - raPhi1);Bb = 5.0478492403e-3 * (Math.sin(2*raPhi2) - Math.sin(2*raPhi1)) / 2;Bc = 1.05637868e-5 * (Math.sin(4*raPhi2) - Math.sin(4*raPhi1)) / 4;Bd = 2.063332e-8 * (Math.sin(6*raPhi2) - Math.sin(6*raPhi1)) / 6;Be = 3.8853e-11 * (Math.sin(8*raPhi2) - Math.sin(8*raPhi1)) / 8;return this.A * (1 - this.E) * (Ba - Bb + Bc - Bd + Be);};UTMConversion.prototype.getLLPoint = function(meterPoint) {var x = meterPoint.y;var y = meterPoint.x;var raOriginPhi = this.proj.origin.lat * Math.PI / 180;var raOriginLamda = this.proj.origin.lon * Math.PI / 180;var dbFactor = this.proj.factor;var ra0 = 0;var ab = 1;var ph0 = Math.PI * 0.2;var m = x / dbFactor + this.meridian(ra0, raOriginPhi);y = y / dbFactor;var mot = 1 / (this.A * (1 - this.E));var si;var n = 0;while (ab > 1.0e-14) {var s = this.meridian(ra0, ph0);si= Math.sin(ph0);var ph1 = ph0 + (m - s) * Math.pow(1 - this.E * si * si, 1.5) * mot;ab = ph1 - ph0;ph0 = ph1;if(ab < 0)ab = -ab;if (++n > 100) {break;}}var co = Math.cos(ph0);var cr = Math.sqrt(1 - this.E * si * si);var ni = cr / this.A;var ri = cr * cr * cr * mot;var eta2 = (co * co) * this.E / (1 - this.E);var t = Math.tan(ph0);var t2 = t * t;var t4 = t2 * t2;var y1 = y * ni;var y2 = y1 * y1;var y4 = y2 * y2;var f1 = -0.08333333333333333 * y2 * (5 + 3*t2 + eta2 - 9*t2*eta2);var f2 = 0.002777777777777777 * y4 * (61 + 90*t2 + 45*t4);var raPhi = ph0 - 0.5 * y * y1 * ri * t * (1 + f1 + f2);f1 = -0.1666666666666666 * y2 * (1 + 2*t2 + eta2);f2 = 0.008333333333333333 * y4 * (5 + 28*t2 + 24*t4);var raLamda = raOriginLamda + y1 / co * (1 + f1 + f2);if (raLamda > Math.PI) raLamda -= (2.0 * Math.PI);else if(raLamda < -Math.PI) raLamda += (2.0 * Math.PI);return new LLPoint(raPhi * 180 / Math.PI, raLamda * 180 / Math.PI);};UTMConversion.prototype.getMeterPoint = function (lpPoint) {var raPhi = lpPoint.lat * Math.PI / 180;var raLamda = lpPoint.lon * Math.PI / 180;var raOriginPhi = this.proj.origin.lat * Math.PI / 180;var raOriginLamda = this.proj.origin.lon * Math.PI / 180;var dbFactor = this.proj.factor;raLamda -= raOriginLamda;var s = Math.sin(raPhi);var c = Math.cos(raPhi);var c2 = c * c;var c4 = c2 * c2;var t = Math.tan(raPhi);var t2 = t * t;var t4 = t2 * t2;var h2 = this.E * c2 / (1 - this.E);var h4 = h2 * h2;var N = this.A / Math.sqrt(1 - this.E * s * s);          var lam2 = raLamda * raLamda;var lamc2 = lam2 * c2;var lamc4 = lamc2 * lamc2;var B = this.meridian(raOriginPhi, raPhi);var x1 = lamc2 * (5 - t2 + 9*h2 + 4*h4) / 24;var x2 = lamc4 * (61 - 58*t2 + t4 + 270*h2 - 330*h2*t2) / 720;var y1 = lamc2 * (1 - t2 + h2) / 6;var y2 = lamc4 * (5 - 18*t2 + t4 + 14*h2 - 58*h2*t2) / 120;var xx = dbFactor * (B + N * s * c * lam2 * (0.5 + x1 + x2));var yy = dbFactor * N * c * raLamda * (1 + y1 + y2);return new Point(yy, xx);};UTMConversion.prototype.release=function(){_objrelease(this);};function MeterMMConversion(scale, angle) {this.scale = scale; this.angle = angle; };MeterMMConversion.prototype.getMMPoint = function(meterPoint) {var dbCos = Math.cos(-this.angle);var dbSin = Math.sin(-this.angle);var x = (meterPoint.x * dbCos - meterPoint.y * dbSin) * 1000 / this.scale;var y = (meterPoint.x * dbSin + meterPoint.y * dbCos) * 1000 / this.scale;return new Point(x, y);};MeterMMConversion.prototype.getMeterPoint = function(mmPoint) {var dbCos = Math.cos(this.angle);var dbSin = Math.sin(this.angle);var x = (mmPoint.x * dbCos - mmPoint.y * dbSin) * this.scale / 1000;var y = (mmPoint.x * dbSin + mmPoint.y * dbCos) * this.scale / 1000;return new Point(x, y);};var MAXLEVEL=18;var RAD_PER_DEG=Math.PI/180.0;var M_PER_DEGREE=111111;var EARTH_CIRCUM_M=M_PER_DEGREE * 360;function sinh(x){ret=Math.exp(x);ret=(ret-1/ret)/2;return ret;};function YUSMercConversion(p_level){this.magnify=1;this.init(p_level);this.circum_px=1<<(26-this.level_);this.defscale=399999600000/this.circum_px;this.meters_per_pixel_=EARTH_CIRCUM_M/this.circum_px;this.x_per_lon_=this.circum_px/360.0;};YUSMercConversion.prototype.init=function(p_level){if(p_level<1)this.level_=1;else if(p_level>MAXLEVEL)this.level_=MAXLEVEL;else this.level_=p_level;};YUSMercConversion.prototype.pixel_height=function(){return this.circum_px;};YUSMercConversion.prototype.ll_to_pxy=function(lpPoint){var alat=Math.abs(lpPoint.lat);var alon=lpPoint.lon;if(alon>180.0){alon-=360.0;}alon+=180.0;var v_pxy=new Point(0,0);if(alat>= 90.0)return v_pxy;if(alon>360.0)alon-=360.0;if(alon<0.0)alon+=360.0;alat*=RAD_PER_DEG;v_pxy.x=parseInt(alon*this.x_per_lon_);var ytemp=Math.log(Math.tan(alat)+1.0/Math.cos(alat))/Math.PI;v_pxy.y=parseInt(ytemp*this.pixel_height())/2;if(lpPoint.lat<0)v_pxy.y=-v_pxy.y;v_pxy.x*=this.magnify;v_pxy.y*=this.magnify;return v_pxy;};YUSMercConversion.prototype.pxy_to_ll=function(logPoint){var v_ll=new LLPoint(0,0);var logP=new Point(logPoint.x/this.magnify,logPoint.y/this.magnify);var alon=logP.x/this.x_per_lon_;var alat=(logP.y/(this.pixel_height()/2.0))*Math.PI;alat=Math.atan(sinh(alat))/RAD_PER_DEG;if(alon<0.0)alon+=360.0;if(alon>360.0)alon-=360.0;v_ll.lon=alon-180.0;if(alat<=-90.0||alat>=90.0)return v_ll;v_ll.lat=alat;return v_ll;};function CoordinatesConversion() {this.m_projCode = 0;this.m_UTMConv = new UTMConversion(new LLPoint(0, 0), 0);this.m_MercatorConv = new MercatorConversion(new LLPoint(0, 0), 0);this.m_MeterMMConv = new MeterMMConversion(25000, 0);this.m_YUSMercConv = new YUSMercConversion(1);this.m_center = new LLPoint(0, 0);this.m_windowWidth = 0;this.m_windowHeight = 0;};CoordinatesConversion.prototype.getProjOrigin = function() {if(this.m_projCode==0) { return this.m_UTMConv.proj.origin;}else if(this.m_projCode==1){ return this.m_MercatorConv.proj.origin;}else if(this.m_projCode==2){ return new LLPoint(0,-180);}};CoordinatesConversion.prototype.setProjConv=function(projCode,origin,info){this.m_projCode=projCode;if(projCode==0){ this.m_UTMConv=new UTMConversion(new LLPoint(origin.lat,origin.lon),info);}else if(projCode==1){ this.m_MercatorConv=new MercatorConversion(new LLPoint(origin.lat,origin.lon),info);}else if(projCode==2){this.m_YUSMercConv=new YUSMercConversion(info);}};CoordinatesConversion.prototype.setScale = function(scale) {if(this.m_projCode==2){this.m_YUSMercConv.magnify=this.m_YUSMercConv.defscale/scale;}else{this.m_MeterMMConv.scale = scale;}};CoordinatesConversion.prototype.setAngle = function(angle) {this.m_MeterMMConv.angle = angle*Math.PI/180;};CoordinatesConversion.prototype.getScale = function() {return this.m_MeterMMConv.scale;};CoordinatesConversion.prototype.getAngle = function() {return this.m_MeterMMConv.angle*180/Math.PI;};CoordinatesConversion.prototype.setCenter = function(center) {while(center.lon<-30){center.lon+=360;}while(center.lon>330){center.lon-=360;}this.m_center = new LLPoint(center.lat, center.lon);};CoordinatesConversion.prototype.setWindowSize = function(width, height) {this.m_windowWidth = width;this.m_windowHeight = height;};CoordinatesConversion.prototype.LL2Meter = function(lpPoint) {if (this.m_projCode == 0) { return this.m_UTMConv.getMeterPoint(lpPoint);} else { return this.m_MercatorConv.getMeterPoint(lpPoint);}};CoordinatesConversion.prototype.Meter2LL = function(meterPoint) {if (this.m_projCode == 0) { return this.m_UTMConv.getLLPoint(meterPoint);} else { return this.m_MercatorConv.getLLPoint(meterPoint);}};CoordinatesConversion.prototype.MM2Log = function(mmPoint) {var mmCenter = this.m_MeterMMConv.getMMPoint(this.LL2Meter(this.m_center));var logX =  this.m_windowWidth/2  - mmCenter.x*10 + mmPoint.x*10;var logY = -this.m_windowHeight/2 - mmCenter.y*10 + mmPoint.y*10;return new Point(logX, -logY);};CoordinatesConversion.prototype.Log2MM = function(logPoint) {var mmCenter = this.m_MeterMMConv.getMMPoint(this.LL2Meter(this.m_center));var mmX = mmCenter.x - this.m_windowWidth/2/10  + logPoint.x/10;var mmY = mmCenter.y + this.m_windowHeight/2/10 - logPoint.y/10;return new Point(mmX, mmY);};CoordinatesConversion.prototype.LL2MM = function(lpPoint) {return this.m_MeterMMConv.getMMPoint(this.LL2Meter(lpPoint));};CoordinatesConversion.prototype.MM2LL = function(mmPoint) {return this.Meter2LL(this.m_MeterMMConv.getMeterPoint(mmPoint));};CoordinatesConversion.prototype.LL2Log = function(lpPoint) {if(this.m_projCode!=2){return this.MM2Log(this.m_MeterMMConv.getMMPoint(this.LL2Meter(lpPoint)));}else{var logPoint=this.m_YUSMercConv.ll_to_pxy(lpPoint);var logCenter=this.m_YUSMercConv.ll_to_pxy(this.m_center);var logP=new Point(0,0);logP.x=this.m_windowWidth/2-logCenter.x+logPoint.x;logP.y=this.m_windowHeight/2+logCenter.y-logPoint.y;return logP;}};CoordinatesConversion.prototype.Meter2Log = function(meterPoint) {return this.MM2Log(this.m_MeterMMConv.getMMPoint(meterPoint));};CoordinatesConversion.prototype.Log2LL = function(logPoint) {if(this.m_projCode!=2){return this.Meter2LL(this.m_MeterMMConv.getMeterPoint(this.Log2MM(logPoint)));}else{var logP=new Point(0,0);var logCenter=this.m_YUSMercConv.ll_to_pxy(this.m_center);logP.x=logCenter.x-this.m_windowWidth/2+logPoint.x;logP.y=logCenter.y+this.m_windowHeight/2-logPoint.y;return this.m_YUSMercConv.pxy_to_ll(logP);}};CoordinatesConversion.prototype.Log2Meter = function(logPoint) {return this.m_MeterMMConv.getMeterPoint(this.Log2MM(logPoint));};CoordinatesConversion.prototype.release=function(){_objrelease(this);};
var _delaytime=300;function getObjPos(g,obj){var pos=new Point(0,0);while(g&&g!=obj){pos.x+=g.offsetLeft;pos.y+=g.offsetTop;g=g.offsetParent;}return pos;};function getObjPos2(obj){var pos=new Point(0,0);while(obj){pos.x+=obj.offsetLeft;pos.y+=obj.offsetTop;obj=obj.offsetParent;}return pos;};function getRelativePos(e,obj,pos){if(!pos){pos=new Point(0,0);}if(typeof e.pageX!="undefined"){var Kd=getObjPos2(obj);pos.x=e.pageX-Kd.x;pos.y=e.pageY-Kd.y;}else if(typeof e.offsetX!="undefined"){var targetObj=e.target||e.srcElement;var xg=getObjPos(targetObj,obj);pos.x=e.offsetX+xg.x;pos.y=e.offsetY+xg.y;}return pos;};function KeyCodesArray(keyCodes){if(keyCodes){for(var i=keyCodes.length-1;i>=0;--i){this.add(keyCodes[i]);}}};KeyCodesArray.prototype.add=function(keyCode){if(!this.contains(keyCode)){this["key"+keyCode]=1;}};KeyCodesArray.prototype.remove=function(keyCode){if(this.exist(keyCode)){delete this["key"+keyCode];}};KeyCodesArray.prototype.contains=function(keyCode){return this["key"+keyCode]==1;};KeyCodesArray.prototype.exist=function(keyCode){return this["key"+keyCode]==1||this["key"+keyCode]==2;};KeyCodesArray.prototype.sleep=function(){for(prop in this){if(typeof this[prop]!="function"){this[prop]=2;}}};KeyCodesArray.prototype.wakeup=function(){for(prop in this){if(typeof this[prop]!="function"){this[prop]=1;}}};function Nothing(){return false;};function CancelBubble(e){if(_bi.type==1){window.event.cancelBubble=true;window.event.returnValue=false;}else{e.cancelBubble=true;if(e.preventDefault){e.preventDefault();}if(e.stopPropagation){e.stopPropagation();}}};function setMouseCursor(obj,shape){try{obj.style.cursor=shape;}catch(p){if(shape=="pointer"){setMouseCursor(obj,"hand");}}};function loadLatLonFromDOMNode(n){var unit=n.getAttribute("unit");var latlon=AlpsUtil.getNodeContent(n);var spLatlon=latlon.split(",");var lat=spLatlon[0];var lon=spLatlon[1];if(unit=="dms"){return new LLPoint(lat,lon);}else if(unit=="degree"){return new LLPoint(parseFloat(lat),parseFloat(lon));}else if(unit=="msec"){return new LLPoint(parseInt(lat)/3600000,parseInt(lon)/3600000);}};function ImageMaker(){};ImageMaker.createImg=function(path,visibility,zIndex,width,height){var img=document.createElement("IMG");if(path&&path.length>0){img.src=path;}if(width){img.width=width;}if(height){img.height=height;}img.style.position="absolute";img.style.top="0px";img.style.left="0px";if(zIndex){img.style.zIndex=zIndex;}if(_bi.type==1){img.unselectable="on";img.onselectstart=Nothing;img.galleryImg="no";}else{img.style.MozUserSelect="none";}img.oncontextmenu=Nothing;img.style.border="0px";img.style.padding="0px";img.style.margin="0px";if(visibility){img.style.visibility=visibility;}return img;};function SpecType(){this.id="";this.name="";};SpecType.prototype.toString=function(){var str="SpecType:";str+="id: "+this.id+"\t"+"name: "+this.name;return str;};function SpecItem(){this.id="";this.name="";};SpecItem.prototype.toString=function(){var str="SpecItem:";str+="id: "+this.id+"\t"+"name: "+this.name;return str;};function ProjInfo(n2){if(n2.nodeName=="projection"){this.loadXML(n2);}else{this.name=arguments[0]; this.code=arguments[1]; this.origin=new LLPoint(arguments[2],arguments[3]); this.subInfo=arguments[4]; this.org1stMeshCode=0; this.id=0;}};ProjInfo.prototype.loadXML=function(n2){this.name=n2.getAttribute("name");var code=n2.getAttribute("type");this.code=0;if(code=="UTM"){this.code=0;}else if(code=="Mercator"){this.code=1;}else if(code=="YMercator"){this.code=2;}var nl3=n2.childNodes;for(var i=0;i<nl3.length;++i){var n3=nl3[i];if(n3.nodeType==1&&n3.nodeName=="origin"){this.origin=loadLatLonFromDOMNode(n3);this.org1stMeshCode=Math.floor(this.origin.lat*1.5)*100+Math.floor(this.origin.lon-100);}else if(n3.nodeType==1&&n3.nodeName=="projfactor"){this.subInfo=parseFloat(AlpsUtil.getNodeContent(n3));}else if(n3.nodeType==1&&n3.nodeName=="ellipse"){var ellipse=AlpsUtil.getNodeContent(n3);if(ellipse=="bessele"){this.subInfo=1;}else if(ellipse=="sphere"){this.subInfo=0;}}}};ProjInfo.prototype.release=function(){_objrelease(this);};function MapLayer(n1){this.projInfo=new Array; this.scrollrange=new Object; this.scrollrange.enable=false;this.specType=new Array; this.specItem=new Array; if(n1.nodeName=="layer"){this.loadXML(n1);}else{this.scale=n1; this.operation=true; }};MapLayer.prototype.toString=function(){var str="MapLayer:\n";str+="scale: "+this.scale+"\n";return str;};MapLayer.prototype.loadXML=function(n1){this.operation=true;if(n1.getAttribute("operation")=="no"){this.operation=false;}var nl2=n1.childNodes;for(var i=0;i<nl2.length;++i){var n2=nl2[i];if(n2.nodeType==1&&n2.nodeName=="projection"){var proj=new ProjInfo(n2);this.addProjInfo(proj);proj.id=this.projInfo.length-1;}else if(n2.nodeType==1&&n2.nodeName=="scale"){this.scale=parseInt(AlpsUtil.getNodeContent(n2));}else if(n2.nodeType==1&&n2.nodeName=="level"){this.level=parseInt(AlpsUtil.getNodeContent(n2));}else if(n2.nodeType==1&&n2.nodeName=="scrollrange"){this.scrollrange.enable=true;var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="bottomleft"){this.scrollrange.bottomleftLatLon=loadLatLonFromDOMNode(n3);}if(n3.nodeType==1&&n3.nodeName=="topright"){this.scrollrange.toprightLatLon=loadLatLonFromDOMNode(n3);}}}else if(n2.nodeType==1&&n2.nodeName=="speclist"){this.loadSpecTypeList(n2);}else if(n2.nodeType==1&&n2.nodeName=="specgroup"){this.loadSpecItemList(n2);}}if(this.scale==undefined&&this.level!=undefined&&this.getProjInfoById(0).code==2){this.scale=399999600000/(1<<(26-this.level));}};MapLayer.prototype.addProjInfo=function(projInfo){this.projInfo.push(projInfo);};MapLayer.prototype.getNearestProjInfo=function(target){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){var mindist=Number.MAX_VALUE;for(var i=0;i<this.projInfo.length;++i){var org=this.projInfo[i].origin;var dist=(target.lat-org.lat)*(target.lat-org.lat)+(target.lon-org.lon)*(target.lon-org.lon);if(dist<mindist){mindist=dist;projInfo=this.projInfo[i];}}}return projInfo;};MapLayer.prototype.getProjInfoById=function(projId){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){for(var i=0;i<this.projInfo.length;++i){if(this.projInfo[i].id==projId){projInfo=this.projInfo[i];break;}}}return projInfo;};MapLayer.prototype.getProjInfoByCode=function(code){var projInfo=this.projInfo[0];if(this.projInfo.length>=2){for(var i=0;i<this.projInfo.length;++i){if(this.projInfo[i].org1stMeshCode==code){projInfo=this.projInfo[i];break;}}}return projInfo;};MapLayer.prototype.getEnableProjInfo=function(layerCodeList,currentProjId){var changeProjInfo;for(var i=0;i<layerCodeList.length;++i){var layerCode=layerCodeList[i];if(layerCode.scale==this.scale){var projInfo=this.getProjInfoByCode(layerCode.code);changeProjInfo=projInfo;if(projInfo.id==currentProjId){break;}}}return changeProjInfo;};MapLayer.prototype.loadSpecTypeList=function(n2){var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="svespec"){var spectype=new SpecType();spectype.id=n3.getAttribute("id");spectype.name=n3.getAttribute("name");this.specType.push(spectype);}}};MapLayer.prototype.loadSpecItemList=function(n2){var nl3=n2.childNodes;for(var j=0;j<nl3.length;++j){var n3=nl3[j];if(n3.nodeType==1&&n3.nodeName=="svegroup"){var specgroup=new SpecItem();specgroup.id=n3.getAttribute("id");specgroup.name=n3.getAttribute("name");this.specItem.push(specgroup);}}};MapLayer.prototype.release=function(){_objrelease(this);};function MapPackage(n0){this.layerCollect=new Array; this.mapserverCollect=new Array; this.currentMapserverIdx=0; if(n0.nodeName=="mappackage"){this.loadXML(n0);}else{this.id="map";var mapserver=new Object();mapserver.url=n0.baseURL; mapserver.type=n0.type; mapserver.sourceType=1; mapserver.format="png"; this.mapserverCollect.push(mapserver);this.layerServerName=""; this.setLayerInfo(n0);}};MapPackage.prototype.getNextMapserver=function(){if(this.currentMapserverIdx>=this.mapserverCollect.length){this.currentMapserverIdx=0;}return this.mapserverCollect[this.currentMapserverIdx++];};MapPackage.prototype.toString=function(){var str="MapPackage: "+this.id+"\n";for(var i=0;i<this.layerCollect.length;++i){str+=this.layerCollect[i].toString();}return str;};MapPackage.prototype.loadXML=function(n0){this.id=n0.getAttribute("id");var nl1=n0.childNodes;for(var i=0;i<nl1.length;++i){var n1=nl1[i];if(n1.nodeType==1&&n1.nodeName=="layer"){var layer=new MapLayer(n1);this.layerCollect.push(layer);}else if(n1.nodeType==1&&n1.nodeName=="mapservername"){var mapserver=new Object();var mapServerType=n1.getAttribute("type");if(mapServerType=="pes"){mapserver.type=1}else if(mapServerType=="presplit"){mapserver.type=2;}else if(mapServerType=="yahoo"){mapserver.type=3;}else if(mapServerType=="yahoosplit"){mapserver.type=4;}var format=n1.getAttribute("format");if(format){mapserver.format=format;}else{mapserver.format="png";}var sourceType=n1.getAttribute("sourcetype");if(sourceType&&sourceType=="vector"){mapserver.sourceType=2; }else{mapserver.sourceType=1; }mapserver.url=AlpsUtil.getNodeContent(n1);this.mapserverCollect.push(mapserver);}else if(n1.nodeType==1&&n1.nodeName=="layerservername"){this.layerServerName=AlpsUtil.getNodeContent(n1);this.layerServerType=n1.getAttribute("type");}}this.layerCollect.sort(function(a,b){return a.scale-b.scale;});};MapPackage.prototype.setLayerInfo=function(layerInfo){for(var i=0;i<layerInfo.count;++i){var projInfo=new ProjInfo("",layerInfo.projCode[i],layerInfo.projOrgLt[i]/3600000,layerInfo.projOrgLn[i]/3600000,layerInfo.projInfo[i]);var layer=new MapLayer(layerInfo.scale[i]);layer.addProjInfo(projInfo);this.layerCollect.push(layer);}};MapPackage.prototype.getLayerScale=function(layerId){var count=this.layerCollect.length;if(layerId<0){layerId=0;}else if(layerId>=count){layerId=count-1;}return this.layerCollect[layerId].scale;};MapPackage.prototype.getLayerId=function(scale,mode){var count=this.layerCollect.length;if(scale<=0){return 0;}if(scale>=this.getLayerScale(count-1)){return count-1;}var layerId=0;var diff=this.getLayerScale(count-1);for(var i=0;i<count;++i){var tempDiff=this.getLayerScale(i)-scale;if(mode&&mode==1&&tempDiff<0){continue;}if(mode&&mode==2&&tempDiff>0){continue;}tempDiff=Math.abs(tempDiff);if(tempDiff==0){diff=tempDiff;layerId=i;break;}if(tempDiff<diff){diff=tempDiff;layerId=i;}}return layerId;};MapPackage.prototype.release=function(){_objrelease(this);};function Tile(tileCollect){this.tileCollect=tileCollect; this.id=null; this.centerLatLon=null; this.enable=false; this.img=ImageMaker.createImg("","inherit",0,this.tileCollect.gazoSize.width,this.tileCollect.gazoSize.height);this.initialized=false;this.isImgLoaded=false;};Tile.prototype.onImgLoad=function(){this.isImgLoaded=true;if(!this.bUpper){return;}for(var i=0;i<this.tileCollect.tileCount;++i){if(this.tileCollect.tileArray[i].isImgLoaded==false){return;}}AlpsEvent.triggerEvent(this.tileCollect.mapView.mapCtrl,"mapImgLoad");};Tile.prototype.setTileURL=function(){var strMapURI;var mapPackage=this.tileCollect.getCurrentPackage();var gazoSize=this.tileCollect.gazoSize;var layerId=this.tileCollect.layerId;var projId=this.tileCollect.projId;var angle=this.tileCollect.angle;var mapserver=mapPackage.getNextMapserver();if(mapserver.type==0){}else if(mapserver.type==3){var lpTileCenter = this.centerLatLon;var strOmajinai = "no part=0&la=0";var strScale = "scale=" + mapPackage.getLayerScale(layerId);var strWidth = "width=" + gazoSize.width;var strHeight = "height=" + gazoSize.height;var strLat = "nl=" + lpTileCenter.lat;var strLon = "el=" + lpTileCenter.lon;strMapURI = mapserver.url + "?" +  strOmajinai + "&" +  strScale + "&" +  strWidth + "&" +  strHeight + "&" +  strLat + "&" +  strLon;}else if(mapserver.type==1){var lpTileCenter= this.centerLatLon;var strScale= "scale="+mapPackage.getLayerScale(layerId);var strSize= "width="+gazoSize.width+"&height="+gazoSize.height;var strPos= "c="+lpTileCenter.lat+","+lpTileCenter.lon;var strOmajinai= "copyright=no&scalebar=no";strMapURI= mapserver.url+"/"+mapserver.format+"?"+strScale+"&"+strSize+"&"+strPos+"&"+strOmajinai;}else if(mapserver.type==2){var org1stMeshCode= 0;if(mapPackage.layerCollect[layerId].projInfo.length>=2){org1stMeshCode= mapPackage.layerCollect[layerId].projInfo[projId].org1stMeshCode;}strMapURI= mapserver.url+"/"+mapPackage.getLayerScale(layerId)+"/"+org1stMeshCode+"/"+Math.floor(this.id.x/100)+"_"+Math.floor(this.id.y/100)+"/"+this.id.x+"_"+this.id.y+"."+mapserver.format;if(mapserver.sourceType==2){strMapURI+="?";var vectorOpe=this.tileCollect.mapView.mapCtrl.vectorOpe;if(!vectorOpe.visibleVecHeimen){strMapURI+="heimen=no&"}if(!vectorOpe.visibleVecTyuki){strMapURI+="tyuki=no&"}if(!vectorOpe.visibleVecRaster){strMapURI+="raster=no&";}if(vectorOpe.specHide.length){strMapURI+="spechide=";strMapURI+=vectorOpe.specHide.join(",");strMapURI+="&";}strMapURI+="spectype=";if(vectorOpe.vecSpecType!="normal"){strMapURI+=vectorOpe.vecSpecType;}else{strMapURI+="normal";}if(angle!=0){strMapURI+="&angle=";strMapURI+=angle;}}}else if(mapserver.type==4){var strOmajinai="v=1.3&t=a";strMapURI= mapserver.url+"?"+strOmajinai +"&x=" + this.id.x +"&y=" + this.id.y +"&z=" + (layerId+1);}if(this.img.src!=strMapURI){this.isImgLoaded=false; if(this.initialized){if(this.tileCollect.mapView.mapCtrl.vacantTilePath){this.img.src=this.tileCollect.mapView.mapCtrl.vacantTilePath;}else{this.img.src="vacantTile.gif";}}else{this.initialized=true;}this.img.src=strMapURI;}};function ProAtlasSheet(mapView,parentContainer,bUpper){this.mapView=mapView;this.bUpper=bUpper; this.packageId="map"; this.layerId=null; this.projId=null; this.scale=0; this.magnify=1; this.angle=0; this.gazoSize=new Size(256,256); this.tileSize=new Size(this.gazoSize.width,this.gazoSize.height); this.div=document.createElement("div");this.div.style.position="absolute";this.div.style.top="0px";this.div.style.left="0px";parentContainer.appendChild(this.div);this.tileArray=new Array();this.tileXCount=0;this.tileYCount=0;this.tileCount=0;};ProAtlasSheet.prototype.getCurrentPackage=function(){return this.mapView.getMapPackage(this.packageId);};ProAtlasSheet.prototype.getTileById=function(id){for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];if((tile.id!=null)&&(tile.id.x==id.x)&&(tile.id.y==id.y)){return tile;}}return null;};ProAtlasSheet.prototype.getTileByIndex=function(index){return this.tileArray[index];};ProAtlasSheet.prototype.getFirstEditableTile=function(){for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];if(!tile.enable){return tile;}}return null;};ProAtlasSheet.prototype.resetAllTiles=function(){var vacantTilePath;if(this.mapView.mapCtrl.vacantTilePath){vacantTilePath=this.mapView.mapCtrl.vacantTilePath;}else{vacantTilePath="vacantTile.gif";}this.magnify=1;var tileWidth,tileHeight;if(this.mapView.conv.m_projCode==2){tileWidth=Math.round(258*this.magnify);tileHeight=Math.round(258*this.magnify);}else{tileWidth=Math.round(this.gazoSize.width*this.magnify);tileHeight=Math.round(this.gazoSize.height*this.magnify);}for(var i=0;i<this.tileCount;++i){var tile=this.tileArray[i];tile.id=null;tile.centerLatLon=null;tile.enable=false;if(tile.initialized){tile.img.src=vacantTilePath;}tile.img.width=tileWidth;tile.img.height=tileHeight;tile.img.style.left=0+"px";tile.img.style.top=0+"px";}this.magnify=0;};ProAtlasSheet.prototype.getVisible=function(){return (this.div.style.visibility=="visible")?true:false;};ProAtlasSheet.prototype.setVisible=function(visible){this.div.style.visibility=(visible?"visible":"hidden");};ProAtlasSheet.prototype.setOpacity=function(val){if(_bi.type==1){for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.style.filter="alpha(opacity=0)";this.tileArray[i].img.filters.alpha.Opacity=(val*100);}}else if(_bi.type==2){this.div.style.MozOpacity=val;}else if(_bi.type==3||(_bi.type==4&&_bi.version>=9)){this.div.style.opacity=val;}else{if(val<0.5){this.setVisible(false);}else{this.setVisible(true);}}};ProAtlasSheet.prototype.ResetOpacity=function(){if(_bi.type==1){for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.style.filter="";}}else if(_bi.type==2){}else if(_bi.type==3){}else{}};ProAtlasSheet.prototype.setZIndex=function(val){this.div.style.zIndex=val;};ProAtlasSheet.prototype.isImageAllLoaded=function(){if(_bi.type==3){return true;}else{var ret=true;for(var i=0;i<this.tileCount;++i){if(!this.tileArray[i].img.complete){ret=false;}}return ret;}};ProAtlasSheet.prototype.setTileCount=function(width,height,bGetNewImage){if(width==0||height==0){return;}var gazoSize=this.gazoSize;var tileSize=this.tileSize;tileSize.width=gazoSize.width*this.magnify;tileSize.height=gazoSize.height*this.magnify;if(bGetNewImage){var tileXCount=Math.floor(width/tileSize.width)+2;var tileYCount=Math.floor(height/tileSize.height)+2;var tileTotalCount=tileXCount*tileYCount;var diff=tileTotalCount-this.tileCount;if(diff>0){for(var i=0;i<diff;++i){var tile=new Tile(this);this.div.appendChild(tile.img);this.tileArray.push(tile);}}else if(diff<0){for(var i=0;i<-diff;++i){var tile=this.tileArray.pop();this.div.removeChild(tile.img);}}this.tileXCount=tileXCount;this.tileYCount=tileYCount;this.tileCount=tileTotalCount;}var tileWidth,tileHeight;if(this.mapView.conv.m_projCode==2){tileWidth=Math.round(258*this.magnify);tileHeight=Math.round(258*this.magnify);}else{tileWidth=Math.round(tileSize.width);tileHeight=Math.round(tileSize.height);}for(var i=0;i<this.tileCount;++i){this.tileArray[i].img.width=tileWidth;this.tileArray[i].img.height=tileHeight;}};ProAtlasSheet.prototype.setCenterAndScale=function(center,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange){var packageChanged=false; if(this.packageId!=packageId&&this.mapView.ExistMapPackage(packageId)){packageChanged=true;var scale=0;if(this.layerId!=null&&layerId==null){scale=this.mapView.getMapPackage(this.packageId).getLayerScale(this.layerId);}this.packageId=packageId; if(scale!=0){layerId=this.getCurrentPackage().getLayerId(scale);}}if(layerId==null){layerId=0;}var mapPackage=this.getCurrentPackage();if(layerId<0||layerId>=mapPackage.layerCollect.length){layerId=this.layerId;}var layer=mapPackage.layerCollect[layerId];var projInfo;if(bProjectionChange){if(this.mapView.mapCtrl.layerCodeList){projInfo=layer.getEnableProjInfo(this.mapView.mapCtrl.layerCodeList[mapPackage.id],this.projId);}if(!projInfo){projInfo=layer.getNearestProjInfo(center);}this.projId=projInfo.id;}else{projInfo=layer.getProjInfoById(this.projId);}if(this.getCurrentPackage().mapServerSourceType!=2){angle=0;}var scale=layer.scale/magnify;this.mapView.setCenterAndScale(projInfo,center,scale,angle,layer.level);if(packageChanged||this.layerId!=layerId||this.angle!=angle){ this.resetAllTiles(); }if(this.layerId!=layerId){this.layerId=layerId; }if(this.magnify!=magnify){ this.magnify=magnify; this.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);}if(this.angle!=angle){this.angle=angle; }this.configureAllTiles(bGetNewImage);if(_bi.type==1){var dummy1=this.mapView.mapContainer.offsetWidth;var dummy2=this.mapView.mapContainer.offsetHeight;}};ProAtlasSheet.prototype.setAllTilesFlag=function(bValue){for(var i=0;i<this.tileCount;++i){this.tileArray[i].isImgLoaded=bValue;}};ProAtlasSheet.prototype.configureAllTiles=function(bGetNewImage){if(this.mapView.conv.m_projCode==2){this.configureAllTilesYUS(bGetNewImage);}else{this.configureAllTilesNormal(bGetNewImage);}};ProAtlasSheet.prototype.configureAllTilesNormal=function(bGetNewImage){if(this.layerId==null){return;}var topleft=this.mapView.conv.LL2Log(this.mapView.conv.getProjOrigin());var gamenLeft=topleft.x*-1;var gamenTop=topleft.y*-1;var gamenRight=gamenLeft+this.mapView.conv.m_windowWidth;var gamenBottom=gamenTop+this.mapView.conv.m_windowHeight;var gamenCenterX=(gamenLeft+gamenRight)/2;var gamenCenterY=(gamenTop+gamenBottom)/2;var centerTileId=new Point(Math.floor(gamenCenterX/this.tileSize.width),Math.floor(gamenCenterY/this.tileSize.height));var centerTileTopLeft=new Point(Math.round(this.mapView.conv.m_windowWidth/2+(centerTileId.x*this.tileSize.width-gamenCenterX)),Math.round(this.mapView.conv.m_windowHeight/2+(centerTileId.y*this.tileSize.height-gamenCenterY)));var tileLeft,tileTop,tileRight,tileBottom;if(this.tileXCount%2!=0){ var temp=Math.floor(this.tileXCount/2);tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+temp;}else{ var temp=Math.floor(this.tileXCount/2);if(gamenCenterX/this.tileSize.width-centerTileId.x>0.5){tileLeft=centerTileId.x-(temp-1);tileRight=centerTileId.x+temp;}else{tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+(temp-1);}}if(this.tileYCount%2!=0){ var temp=Math.floor(this.tileYCount/2);tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+temp;}else{ var temp=Math.floor(this.tileYCount/2);if(gamenCenterY/this.tileSize.height-centerTileId.y>0.5){tileTop=centerTileId.y-(temp-1);tileBottom=centerTileId.y+temp;}else{tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+(temp-1);}}for(var i=0;i<this.tileCount;++i){this.getTileByIndex(i).enable=false;}var requestTiles=new Array();var gamenCenter=new Point((gamenLeft+gamenRight)/2,(gamenTop+gamenBottom)/2);for(var j=tileTop;j<=tileBottom;++j){for(var i=tileLeft;i<=tileRight;++i){var id=new Point(i,j);var tile=this.getTileById(id);if(tile!=null){ tile.enable=true;var bSetImage=false;this.configureTile(tile,bSetImage,centerTileId,centerTileTopLeft);}else if(bGetNewImage){ var tileCenter=new Point((i+0.5)*this.tileSize.width,(j+0.5)*this.tileSize.height);var sqdist=Point.sqdist(gamenCenter,tileCenter);var centerLatLon=null;var mapServerType=this.getCurrentPackage().mapServerType;if(mapServerType==1||mapServerType==3){ centerLatLon=this.mapView.conv.Log2LL(new Point(tileCenter.x-gamenLeft,tileCenter.y-gamenTop));}var rqTile=new TileRequest(id,sqdist,centerLatLon);requestTiles.push(rqTile);}}}requestTiles.sort(tileSort);for(var i=0;i<requestTiles.length;++i){var request=requestTiles[i];var tile=this.getFirstEditableTile();if(tile!=null){tile.enable=true;tile.id=request.id; tile.centerLatLon=request.centerLatLon; var bSetImage=true;this.configureTile(tile,bSetImage,centerTileId,centerTileTopLeft);}}};ProAtlasSheet.prototype.configureAllTilesYUS=function(bGetNewImage){if(this.layerId==null){return;}var bottomleft=this.mapView.conv.LL2Log(this.mapView.conv.getProjOrigin());var gamenLeft=bottomleft.x*-1;var gamenBottom=bottomleft.y*-1;gamenBottom*=-1; var gamenRight=gamenLeft+this.mapView.conv.m_windowWidth;var gamenTop=gamenBottom-this.mapView.conv.m_windowHeight;var gamenCenterX=(gamenLeft+gamenRight)/2;var gamenCenterY=(gamenTop+gamenBottom)/2;var centerTileId=new Point(Math.floor(gamenCenterX/this.tileSize.width),Math.floor(gamenCenterY/this.tileSize.height));var centerTileTopLeft=new Point(Math.round(this.mapView.conv.m_windowWidth/2+(centerTileId.x*this.tileSize.width-gamenCenterX)),Math.round(-this.mapView.conv.m_windowHeight/2+(centerTileId.y*this.tileSize.height-gamenCenterY)));var tileLeft,tileTop,tileRight,tileBottom;if(this.tileXCount%2!=0){ var temp=Math.floor(this.tileXCount/2);tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+temp;}else{ var temp=Math.floor(this.tileXCount/2);if(gamenCenterX/this.tileSize.width-centerTileId.x>0.5){tileLeft=centerTileId.x-(temp-1);tileRight=centerTileId.x+temp;}else{tileLeft=centerTileId.x-temp;tileRight=centerTileId.x+(temp-1);}}if(this.tileYCount%2!=0){ var temp=Math.floor(this.tileYCount/2);tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+temp;}else{ var temp=Math.floor(this.tileYCount/2);if(gamenCenterY/this.tileSize.height-centerTileId.y>0.5){tileTop=centerTileId.y-(temp-1);tileBottom=centerTileId.y+temp;}else{tileTop=centerTileId.y-temp;tileBottom=centerTileId.y+(temp-1);}}for(var i=0;i<this.tileCount;++i){this.getTileByIndex(i).enable=false;}var requestTiles=new Array();var gamenCenter=new Point((gamenLeft+gamenRight)/2,(gamenTop+gamenBottom)/2);for(var j=tileTop;j<=tileBottom;++j){for(var i=tileLeft;i<=tileRight;++i){var id=new Point(i,j);var tile=this.getTileById(id);if(tile!=null){ tile.enable=true;var bSetImage=false;this.configureTileYUS(tile,bSetImage,centerTileId,centerTileTopLeft);}else if(bGetNewImage){ var tileCenter=new Point((i+0.5)*this.tileSize.width,(j+0.5)*this.tileSize.height);var sqdist=Point.sqdist(gamenCenter,tileCenter);var centerLatLon=null;var mapServerType=this.getCurrentPackage().mapServerType;if(mapServerType==1||mapServerType==3){ centerLatLon=this.mapView.conv.Log2LL(new Point(tileCenter.x-gamenLeft,tileCenter.y-gamenTop));}var rqTile=new TileRequest(id,sqdist,centerLatLon);requestTiles.push(rqTile);}}}requestTiles.sort(tileSort);for(var i=0;i<requestTiles.length;++i){var request=requestTiles[i];var tile=this.getFirstEditableTile();if(tile!=null){tile.enable=true;tile.id=request.id; tile.centerLatLon=request.centerLatLon; var bSetImage=true;this.configureTileYUS(tile,bSetImage,centerTileId,centerTileTopLeft);}}};function tileSort(a,b){return a.sqdist-b.sqdist;};ProAtlasSheet.prototype.configureTile=function(tile,bSetImage,centerTileId,centerTileTopLeft){var diffX=(tile.id.x-centerTileId.x)*Math.round(this.tileSize.width);var diffY=(tile.id.y-centerTileId.y)*Math.round(this.tileSize.height);var tileLeft=centerTileTopLeft.x+diffX;var tileTop=centerTileTopLeft.y+diffY;tile.img.style.left=tileLeft+"px";tile.img.style.top=tileTop+"px";if(bSetImage==true){tile.setTileURL();}};ProAtlasSheet.prototype.configureTileYUS=function(tile,bSetImage,centerTileId,centerTileTopLeft){var diffX=(tile.id.x-centerTileId.x)*Math.round(this.tileSize.width);var diffY=(tile.id.y-centerTileId.y)*Math.round(this.tileSize.height);var tileLeft=centerTileTopLeft.x+diffX;var tileTop=centerTileTopLeft.y+diffY+this.tileSize.height;tile.img.style.left=tileLeft+"px";tile.img.style.top=-tileTop+"px";if(bSetImage==true){tile.setTileURL();}};ProAtlasSheet.prototype.release=function(){_objrelease(this);};function TileRequest(id,sqdist,centerLatLon){this.id=id;this.sqdist=sqdist;this.centerLatLon=centerLatLon;};function ProAtlasMapView(mapContainer,mapCtrl){this.mapContainer=mapContainer; this.mapCtrl=mapCtrl; this.packageCollect=new Array; this.conv=new CoordinatesConversion(); this.fadeinTimerId=0;this.mapContainer.style.overflow="hidden";if(this.mapContainer.style.position!="absolute"){this.mapContainer.style.position="relative"}this.viewContainer=document.createElement("div");this.viewContainer.style.position="absolute";this.viewContainer.style.top="0px";this.viewContainer.style.left="0px";this.mapContainer.appendChild(this.viewContainer);this.backSheet=new ProAtlasSheet(this,this.viewContainer,false); this.frontSheet=new ProAtlasSheet(this,this.viewContainer,true); this.frontSheet.setVisible(true);this.backSheet.setVisible(false);this.setVisibleCopyright(true);};ProAtlasMapView.prototype.toString=function(){var str="ProAtlasMapView\n";for(var i=0;i<this.packageCollect.length;++i){var packageId=this.packageCollect[i];var aaa=this.getMapPackage(packageId);str+=aaa.toString();}return str;};var _mAlpsCopy="(C)"+(new Date()).getFullYear().toString()+" ALPS MAPPING K.K.";ProAtlasMapView.prototype.setVisibleCopyright=function(visible){if(!this.copyright){this.copyright=this.createCopyright(_mAlpsCopy);this.copyright.style.right="3px";this.copyright.style.bottom="3px";this.mapContainer.appendChild(this.copyright);}this.copyright.style.visibility=visible?"visible":"hidden";};ProAtlasMapView.prototype.createCopyright=function(strCopyright){var obj=document.createElement("div");obj.style.position="absolute";obj.style.fontSize="12px";obj.style.fontFamily="Arial, Helvetica, sans-serif";obj.style.fontWeight="bold";if(_bi.type==1){obj.unselectable="on";obj.onselectstart=Nothing;}else{obj.style.MozUserSelect="none";}obj.oncontextmenu=Nothing;setMouseCursor(obj,"default"); obj.innerHTML=strCopyright;return obj;};ProAtlasMapView.prototype.getVisibleCopyright=function(){if(!this.copyright){return false;}return this.copyright.style.visibility=="visible";};ProAtlasMapView.prototype.createCenterMark=function(path,size){this.centerImg=ImageMaker.createImg(path,"visible",0,size,size);this.mapContainer.appendChild(this.centerImg);this.centerImg.style.left=(this.mapContainer.offsetWidth-this.centerImg.width)/2 + "px";this.centerImg.style.top=(this.mapContainer.offsetHeight-this.centerImg.height)/2 + "px";};ProAtlasMapView.prototype.getVisibleCenterMark=function(){if(!this.centerImg){return false;}return this.centerImg.style.visibility=="visible";};ProAtlasMapView.prototype.setVisibleCenterMark=function(visible){if(!this.centerImg){return;}this.centerImg.style.visibility=visible?"visible":"hidden";};ProAtlasMapView.prototype.addMapPackage=function(mapPackage){this.packageCollect.push(mapPackage.id);this.packageCollect[mapPackage.id]=mapPackage;};ProAtlasMapView.prototype.getMapPackage=function(packageId){return this.packageCollect[packageId];};ProAtlasMapView.prototype.ExistMapPackage=function(packageId){for(var i=0;i<this.packageCollect.length;++i){if(this.packageCollect[i]==packageId){return true;}}return false;};ProAtlasMapView.prototype.resizeMapView=function(){this.conv.setWindowSize(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight);var bGetNewImage=this.mapCtrl.zoomTimerId?false:true;this.frontSheet.setTileCount(this.mapContainer.offsetWidth,this.mapContainer.offsetHeight,bGetNewImage);var bGetNewImage=true;this.frontSheet.configureAllTiles(bGetNewImage);if(this.centerImg){this.centerImg.style.left=(this.mapContainer.offsetWidth-this.centerImg.width)/2 + "px";this.centerImg.style.top=(this.mapContainer.offsetHeight-this.centerImg.height)/2 + "px";}};ProAtlasMapView.prototype.flipSheet=function(){var frontSheet=this.frontSheet;this.frontSheet=this.backSheet;this.backSheet=frontSheet;if(!this.frontSheet.bUpper){this.viewContainer.removeChild(this.frontSheet.div);this.viewContainer.appendChild(this.frontSheet.div);this.frontSheet.bUpper=true;this.backSheet.bUpper=false;}this.frontSheet.setVisible(true);if(_bi.type==4){ this.backSheet.setVisible(false);this.backSheet.resetAllTiles();}};ProAtlasMapView.prototype.fadeinFlipSheet=function(type){var frontSheet=this.frontSheet;this.frontSheet=this.backSheet;this.backSheet=frontSheet;if(!this.frontSheet.bUpper){this.viewContainer.removeChild(this.frontSheet.div);this.viewContainer.appendChild(this.frontSheet.div);this.frontSheet.bUpper=true;this.backSheet.bUpper=false;}this.frontSheet.setOpacity(0);this.frontSheet.setVisible(true);var func="this.timerFadein(1,'"+type+"')";this.fadeinTimerId=_setTimeout(this,this.timerFadein,10,1,type);};ProAtlasMapView.prototype.timerFadein=function(val,type){if(val>10){this.frontSheet.setOpacity(1);this.frontSheet.ResetOpacity();this.backSheet.ResetOpacity();if(_bi.type==4){ this.backSheet.setVisible(false);this.backSheet.resetAllTiles();}this.fadeinTimerId=0;if(type=="package"){AlpsEvent.triggerEvent(this.mapCtrl,"packageChanged");if(this.frontSheet.angle!=this.backSheet.angle){AlpsEvent.triggerEvent(this.mapCtrl,"angleChanged");}}else if(type=="angle"){AlpsEvent.triggerEvent(this.mapCtrl,"angleChanged");}else if(type=="layer"){AlpsEvent.triggerEvent(this.mapCtrl,"layerChanged");}else if(type=="mapmove"){AlpsEvent.triggerEvent(this.mapCtrl,"mapMoved");}}else{this.frontSheet.setOpacity(val/10);var newval=val+1.25;if(type=="layer"){var newval=val+2.5;}var func="this.timerFadein("+newval+",'"+type+"')";this.fadeinTimerId=_setTimeout(this,this.timerFadein,150,newval,type);}};ProAtlasMapView.prototype.isFadeinFlipping=function(){return this.fadeinTimerId!=0;};ProAtlasMapView.prototype.stopFadeinFlipping=function(){if(this.fadeinTimerId){clearTimeout(this.fadeinTimerId);this.fadeinTimerId=0;this.frontSheet.setOpacity(1);this.frontSheet.ResetOpacity();this.backSheet.ResetOpacity();if(_bi.type==4){ this.backSheet.setVisible(false);this.backSheet.resetAllTiles();}}};ProAtlasMapView.prototype.setCenterAndScale=function(projInfo,center,scale,angle,level){var org;var info;if(projInfo.code!=2){org=new LLPoint(projInfo.origin.lat,projInfo.origin.lon);info=projInfo.subInfo;}else{info=level}this.conv.setProjConv(projInfo.code,org,info);this.conv.setScale(scale);this.conv.setAngle(angle);this.conv.setCenter(center);};ProAtlasMapView.prototype.getNextPackageId=function(id){for(var i=0;i<this.packageCollect.length;++i){var tempId=this.packageCollect[i];if(tempId==id){i+=1;if(i==this.packageCollect.length){i=0;}break;}}return this.packageCollect[i];};ProAtlasMapView.prototype.release=function(){_objrelease(this.packageCollect,true);_objrelease(this);};var _maxMagnify=5;var _minMagnify=0.5;var _buttonLeft=0;var _buttonRight=1;var _buttonMiddle=2;function ProAtlasMapCtrl(mapContainer,layerInfo,strType,defpos){this.mouseX=0;this.mouseY=0;this.mouseDownX=0;this.mouseDownY=0;this.scrollType=0; this.autoScrollTimerId=0;this.enableDragScroll=true;this.enableDbClickCentering=true;this.enableSingleClickCentering=false;this.isMouseMoved=false; this.isMouseDragged=false; this.isMouseDown=false; this.mouseDownTime=null; this.zoomTimerId=0;this.zoomElapseTime=33;this.targetMagnify=0;this.stepMagnify=0;this.isSmoothZoomEnd=false;this.enableWheelOperation=true;this.enableZoomendFadeinEfct=false;this.cntrngTimerId=0;this.cntrngElapseTime=10; this.cntrngTotalTime=300; this.cntrngCrrntStep=0; this.targetSize=new Size(0,0); this.currentPos=new Point(0,0); this.flightScrollTimerId=0;this.flightScrollElapseTime=30; this.coefficientOfAirResistance=10; this.objectMass=2; this.accelerationOfJetEngine=5000; this.velocityX=0; this.velocityY=0; this.arrowKeys=new KeyCodesArray();this.enableKeyboardOperation=true;this.enableMagnifyOperation=true;this.enableLayerOperation=true;this.enableSmoothLayerOperation=true;this.enableAngleOperation=false;this.enableSmoothScroll=true;this.enablePackageOperation=false;this.mouseIsOnTheMap=false;this.vectorOpe=new Object;this.vectorOpe.visibleVecHeimen=true; this.vectorOpe.visibleVecTyuki=true; this.vectorOpe.visibleVecRaster=true; this.vectorOpe.vecSpecType="normal"; this.vectorOpe.specHide=new Array; this.enableAutoLayerChange=false;this.datum="tokyo97";this.yahooMapLayer=null;this.yahooMapLayerServerType="";var mapContainerStyle=mapContainer.style.display;mapContainer.style.display="block";this.mapView=new ProAtlasMapView(mapContainer,this);AlpsEvent.bindBuiltInEvent(window,"resize",this,this.onResize);this.eventSrc=mapContainer.setCapture?mapContainer:window; AlpsEvent.bindBuiltInEvent(mapContainer,"mousedown",this,this.onMouseDown);AlpsEvent.bindBuiltInEvent(this.eventSrc,"mousemove",this,this.onMouseMove);AlpsEvent.bindBuiltInEvent(this.eventSrc,"mouseup",this,this.onMouseUp);if(_bi.type==2){AlpsEvent.bindBuiltInEvent(window,"mouseout",this,this.onWindowMouseOut);}AlpsEvent.bindBuiltInEvent(mapContainer,"mouseover",this,this.onMouseOver);AlpsEvent.bindBuiltInEvent(mapContainer,"mouseout",this,this.onMouseOut);AlpsEvent.bindEvent(this,"mapMoved",this,this.mapMoved);AlpsEvent.bindEvent(this,"mapMoving",this,this.mapMoving);this.mapMovedTimerId=0;AlpsEvent.bindEvent(this,"layerListChanged",this,this.layerListChanged);if(_bi.type==3){ AlpsEvent.bindBuiltInEvent(window.document,"keypress",this,this.onKeyDown);}else{ AlpsEvent.bindBuiltInEvent(window.document,"keydown",this,this.onKeyDown);}AlpsEvent.bindBuiltInEvent(window.document,"keyup",this,this.onKeyUp);this.mouseWheelHandler=AlpsEvent.makeBinder(this,this.onMouseWheel);this.addWheelEvent();AlpsEvent.bindBuiltInEvent(mapContainer,"click",this,this.onClick);AlpsEvent.bindBuiltInEvent(mapContainer,"dblclick",this,this.onDblClick);AlpsEvent.bindBuiltInEvent(mapContainer,"contextmenu",this,this.onContextMenu);this.loadMap(layerInfo,strType);if(defpos){if(defpos.datum){this.datum=defpos.datum;}this.packageTo(defpos.packageId);var layerId;if(defpos.layerId>=0){layerId=defpos.layerId;}else if(defpos.scale){layerId=this.getLayerId(defpos.scale);}var pos=this.toInside(defpos.pos,true);this.moveAndLayerTo(pos,layerId,true);}else{this.defaultTo();}this.onResizeEnd();this.layerScaleList=new Object;this.layerCodeList=new Object;for(var i=0;i<this.mapView.packageCollect.length;++i){var packageId=this.mapView.packageCollect[i];this.layerScaleList[packageId]=new Array;var layerCollect=this.mapView.getMapPackage(packageId).layerCollect;for(var j=0;j<layerCollect.length;++j){this.layerScaleList[packageId].push(layerCollect[j].scale);}this.layerCodeList[packageId]=new Array;}mapContainer.style.display=mapContainerStyle;};ProAtlasMapCtrl.prototype.addWheelEvent=function(){if(_bi.type==2){ AlpsEvent.addBuiltInEvent(window.document,"DOMMouseScroll",this.mouseWheelHandler);}else if(_bi.type==4){ AlpsEvent.addBuiltInEvent(this.mapView.mapContainer,"mousewheel",this.mouseWheelHandler);}else{ AlpsEvent.addBuiltInEvent(window.document,"mousewheel",this.mouseWheelHandler);}};ProAtlasMapCtrl.prototype.removeWheelEvent=function(){if(_bi.type==2){ AlpsEvent.removeBuiltInEvent(window.document,"DOMMouseScroll",this.mouseWheelHandler);}else if(_bi.type==4){ AlpsEvent.removeBuiltInEvent(this.mapView.mapContainer,"mousewheel",this.mouseWheelHandler);}else{ AlpsEvent.removeBuiltInEvent(window.document,"mousewheel",this.mouseWheelHandler);}};ProAtlasMapCtrl.prototype.toString=function(){var str="ProAtlasMapCtrl\n";str+=this.mapView.toString();return str;};ProAtlasMapCtrl.prototype.loadMap=function(layerInfo,strType){if(typeof(layerInfo)=="object"){var mapPackage=new MapPackage(layerInfo);this.mapView.addMapPackage(mapPackage);}else if(typeof(layerInfo)=="string"){this.loadXML(layerInfo,strType);}};ProAtlasMapCtrl.prototype.loadXML=function(param,strType){var doc=null;if(strType!=null&&strType=="string"){doc=AlpsUtil.getXMLDOMFromStr(param);}else{doc=AlpsUtil.getXMLDOM(param);}if(!doc)return;var n=doc.getElementsByTagName("proatlasmap")[0];if(!n)return;var nl0=n.childNodes;for(var i=0;i<nl0.length;++i){var n0=nl0[i];if(n0.nodeType==1&&n0.nodeName=="mappackage"){var mapPackage=new MapPackage(n0);this.mapView.addMapPackage(mapPackage);}else if(n0.nodeType==1&&n0.nodeName=="defaultposition"){this.loadDefaultPosition(n0);}else if(n0.nodeType==1&&n0.nodeName=="centermark"){this.loadCenterMark(n0);}else if(n0.nodeType==1&&n0.nodeName=="autoscrollanchor"){this.loadAnchor(n0);}else if(n0.nodeType==1&&n0.nodeName=="vacanttile"){this.loadVacantTile(n0);}else if(n0.nodeType==1&&n0.nodeName=="yahoolayerservername"){this.yahooMapLayer=AlpsUtil.getNodeContent(n0);this.yahooMapLayerType=n0.getAttribute("type");}}};ProAtlasMapCtrl.prototype.loadCenterMark=function(n0){var path=n0.getAttribute("src");var size=n0.getAttribute("size");this.mapView.createCenterMark(path,size);};ProAtlasMapCtrl.prototype.loadAnchor=function(n0){var path=n0.getAttribute("src");var size=n0.getAttribute("size");this.anchorImg=ImageMaker.createImg(path,"hidden",0,size,size);this.mapView.mapContainer.appendChild(this.anchorImg);};ProAtlasMapCtrl.prototype.loadVacantTile=function(n0){this.vacantTilePath=n0.getAttribute("src");var vacantImg=ImageMaker.createImg(this.vacantTilePath,"hidden",0);this.mapView.mapContainer.appendChild(vacantImg);};ProAtlasMapCtrl.prototype.loadDefaultPosition=function(n0){var nl1=n0.childNodes;for(var i=0;i<nl1.length;++i){var n1=nl1[i];if(n1.nodeType==1&&n1.nodeName=="mappackage"){this.defPackageId=AlpsUtil.getNodeContent(n1);}else if(n1.nodeType==1&&n1.nodeName=="position"){this.defPos=loadLatLonFromDOMNode(n1);}else if(n1.nodeType==1&&n1.nodeName=="scale"){this.defScale=parseInt(AlpsUtil.getNodeContent(n1));}}};ProAtlasMapCtrl.prototype.onResize=function(){if(_bi.type==1||_bi.type==4||_bi.type==3){this.resizeEnd=(this.resizeEnd==null)?(new Object()):this.resizeEnd;clearTimeout(this.resizeEnd);this.resizeEnd=_setTimeout(this,this.onResizeEnd,100);}else{this.onResizeEnd();}};ProAtlasMapCtrl.prototype.onResizeEnd=function(){this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.getWindowSize=function(){var sz=new Size(0,0);if(window.self&&self.innerWidth){sz.width=self.innerWidth;sz.height=self.innerHeight;return sz;}if(document.documentElement&&document.documentElement.clientHeight){sz.width=document.documentElement.clientWidth;sz.height=document.documentElement.clientHeight;return sz;}sz.width=document.body.clientWidth;sz.height=document.body.clientHeight;return sz;};ProAtlasMapCtrl.prototype.onMouseDown=function(e){if(e.button!=0&&e.button!=1){CancelBubble(e);return false;}var lpPoint=this.log2LatLon(getRelativePos(e,this.mapView.mapContainer));AlpsEvent.triggerEvent(this,"mouseDown",lpPoint);this.isMouseDown=true;this.isMouseMoved=false;this.isMouseDragged=false;this.mouseX=e.screenX;this.mouseY=e.screenY;this.mouseDownX=e.screenX;this.mouseDownY=e.screenY;if(this.mapView.mapContainer.setCapture){this.mapView.mapContainer.setCapture()}CancelBubble(e);if(this.arrowKeys.contains(16)){if(this.anchorImg){var pos=getRelativePos(e,this.mapView.mapContainer);this.anchorImg.style.left=pos.x-this.anchorImg.width/2 + "px";this.anchorImg.style.top=pos.y-this.anchorImg.height/2 + "px";this.anchorImg.style.visibility="visible";}this.scrollType=1;this.autoScrollCount=0;this.autoScroll(); }else{this.scrollType=0;}this.mouseDownTime=(new Date()).getTime();return false;};ProAtlasMapCtrl.prototype.onMouseMove=function(e){var mapContainer=this.mapView.mapContainer;var log=getRelativePos(e,mapContainer);if(log.x>0&&log.y>0&&log.x<mapContainer.offsetWidth&&log.y<mapContainer.offsetHeight){var lpPoint=this.log2LatLon(log);AlpsEvent.triggerEvent(this,"mouseMove",lpPoint);}this.isMouseMoved=true;if(!this.isMouseDown){return false;}var scrollX=e.screenX-this.mouseX;var scrollY=e.screenY-this.mouseY;if(Math.abs(scrollX)>0||Math.abs(scrollY)>0){this.isMouseDragged=true;if(this.scrollType==0&&this.enableDragScroll){this.dragScroll(scrollX,scrollY);}this.mouseX=e.screenX;this.mouseY=e.screenY;}return false;};ProAtlasMapCtrl.prototype.onMouseUp=function(e){if(this.mapView.mapContainer.releaseCapture){this.mapView.mapContainer.releaseCapture();}var mapContainer=this.mapView.mapContainer;var log=getRelativePos(e,mapContainer);if(log.x>0&&log.y>0&&log.x<mapContainer.offsetWidth&&log.y<mapContainer.offsetHeight){var lpPoint=this.log2LatLon(log);AlpsEvent.triggerEvent(this,"mouseUp",lpPoint);}if(_bi.type==4&&e.button==2){ var lpPoint=this.log2LatLon(log);AlpsEvent.triggerEvent(this,"click",this.toOutside(lpPoint,true),_buttonRight);}if(this.scrollType==1){if(this.anchorImg){this.anchorImg.style.visibility="hidden";}clearTimeout(this.autoScrollTimerId);this.autoScrollTimerId=0;AlpsEvent.triggerEvent(this,"mapMoved",true);this.isMouseDown=false;return false;}var currTime=(new Date()).getTime();if(currTime-this.mouseDownTime<=500&&!this.isMouseMoved){}else if(this.isMouseDown&&this.isMouseMoved&&this.enableDragScroll){AlpsEvent.triggerEvent(this,"mapMoved",true);}this.isMouseDown=false;return false;};ProAtlasMapCtrl.prototype.autoScroll=function(){var targetX=this.mouseX-this.mouseDownX;var targetY=this.mouseY-this.mouseDownY;var target = new Point(this.mapView.conv.m_windowWidth/2+targetX/10,this.mapView.conv.m_windowHeight/2+targetY/10);var lpTarget=this.mapView.conv.Log2LL(target);this.moveTo(lpTarget,null,true/*fromUI*/,false/*fromSmoothCentering*/,true/*fromInside*/);if(this.autoScrollCount>=30){this.autoScrollCount=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}else{this.autoScrollCount+=1;}this.autoScrollTimerId=_setTimeout(this,this.autoScroll,10);};ProAtlasMapCtrl.prototype.dragScroll=function(scrollX,scrollY){var target = new Point(this.mapView.conv.m_windowWidth/2-scrollX,this.mapView.conv.m_windowHeight/2-scrollY);var lpTarget=this.mapView.conv.Log2LL(target);this.moveTo(lpTarget,null,true/*fromUI*/,false/*fromSmoothCentering*/,true/*fromInside*/);};ProAtlasMapCtrl.prototype.onWindowMouseOut=function(e){if(!e.relatedTarget&&this.isMouseDown){this.onMouseUp(e);}};ProAtlasMapCtrl.prototype.onMouseOver=function(e){var mapContainer=this.mapView.mapContainer;var log=getRelativePos(e,mapContainer);if(log.x>=0&&log.y>=0&&log.x<=mapContainer.offsetWidth&&log.y<=mapContainer.offsetHeight){if(!this.mouseIsOnTheMap){this.mouseIsOnTheMap=true;var lpPoint=this.log2LatLon(log);AlpsEvent.triggerEvent(this,"mouseOver",lpPoint);}}};ProAtlasMapCtrl.prototype.onMouseOut=function(e){var mapContainer=this.mapView.mapContainer;var log=getRelativePos(e,mapContainer);if(log.x<=0||log.y<=0||log.x>=mapContainer.offsetWidth||log.y>=mapContainer.offsetHeight){if(this.mouseIsOnTheMap){this.mouseIsOnTheMap=false;var lpPoint=this.log2LatLon(log);AlpsEvent.triggerEvent(this,"mouseOut",lpPoint);}}};ProAtlasMapCtrl.prototype.onKeyDown=function(e){if(!this.enableKeyboardOperation){return true;}e=(e?e:window.event);switch(e.keyCode){case 33: if(this.enableLayerOperation){var layerId=this.mapView.frontSheet.layerId+1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.layerTo(layerId,null,true);}CancelBubble(e);return false;}else{return true;}case 34: if(this.enableLayerOperation){var layerId=this.mapView.frontSheet.layerId-1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.layerTo(layerId,null,true);}CancelBubble(e);return false;}else{return true;}case 36: if(this.enableMagnifyOperation){var magnify=1;if(this.arrowKeys.contains(16)){if(this.mapView.frontSheet.magnify>1){magnify=1;}else{magnify=_minMagnify;}}else{magnify=this.mapView.frontSheet.magnify/1.2;}this.magnifyTo(magnify,true);CancelBubble(e);return false; }else{return true;}case 35: if(this.enableMagnifyOperation){var magnify=1;if(this.arrowKeys.contains(16)){if(this.mapView.frontSheet.magnify<1){magnify=1;}else{magnify=_maxMagnify;}}else{magnify=this.mapView.frontSheet.magnify*1.2;}this.magnifyTo(magnify,true);CancelBubble(e);return false;}else{return true;}case 45: if(this.enableSmoothLayerOperation){var layerId=this.mapView.frontSheet.layerId+1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return false;}else{return true;}case 46: if(this.enableSmoothLayerOperation){var layerId=this.mapView.frontSheet.layerId-1;if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return false;}else{return true;}case 82: if(this.enableAngleOperation){var angle=this.getCurrentAngle()+5;if(this.arrowKeys.contains(16)){this.smoothAngleTo(angle);}else{this.angleTo(angle,true);}CancelBubble(e);return false;}else{return true;}case 76: if(this.enableAngleOperation){var angle=this.getCurrentAngle()-5;if(this.arrowKeys.contains(16)){this.smoothAngleTo(angle);}else{this.angleTo(angle,true);}CancelBubble(e);return false;}else{return true;}case 32:if(this.enablePackageOperation){var nextPackageId=this.mapView.getNextPackageId(this.getCurrentPackageId());this.smoothPackageTo(nextPackageId);CancelBubble(e);return false;}else{return true;}case 37: case 38: case 39: case 40: this.arrowKeys.add(e.keyCode);this.startFlightScroll();CancelBubble(e);return false;case 16: this.arrowKeys.add(e.keyCode);CancelBubble(e);return false;case 18: if(_bi.type==2&&_bi.subType==1){CancelBubble(e);return false;}return true;}return true;};ProAtlasMapCtrl.prototype.onKeyUp=function(e){switch(e.keyCode){case 37: case 38: case 39: case 40: case 16: this.arrowKeys.remove(e.keyCode);CancelBubble(e);return false;}return true;};ProAtlasMapCtrl.prototype.smoothZoom=function(){if(!this.isSmoothZoomEnd){var currentMagnify=this.mapView.frontSheet.magnify;var targetMagnify=currentMagnify*this.stepMagnify;if(targetMagnify>100||targetMagnify<0.01){this.isSmoothZoomEnd=true;}else{if((this.stepMagnify>1&&targetMagnify>this.targetMagnify)||   (this.stepMagnify<1&&targetMagnify<this.targetMagnify)){targetMagnify=this.targetMagnify;this.isSmoothZoomEnd=true;}var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var angle=this.mapView.frontSheet.angle;var bGetNewImage=false;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,targetMagnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"layerChanging");}var zoomElapseTime;if(!this.enableZoomendFadeinEfct||(_bi.type==2&&_bi.subType==1&&_bi.version<1.5)||(_bi.type==2&&_bi.subType==3&&_bi.version<1.8)||(_bi.type==2&&_bi.subType==2)||(_bi.type==4&&_bi.version<9)){zoomElapseTime=50;}else{zoomElapseTime=33;}this.zoomTimerId=_setTimeout(this,this.smoothZoom,zoomElapseTime);}else{var packageId=this.mapView.backSheet.packageId;var layerId=this.mapView.backSheet.layerId;this.mapView.backSheet.magnify=1;var bGetNewImage=true;this.mapView.backSheet.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);var lpTarget=this.mapView.conv.m_center;var angle=this.mapView.backSheet.angle;var bProjectionChange=false;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,this.mapView.backSheet.magnify,angle,bGetNewImage,bProjectionChange);this.zoomTimerId=0;if(!this.enableZoomendFadeinEfct||(_bi.type==2&&_bi.subType==1&&_bi.version<1.5)||(_bi.type==2&&_bi.subType==3&&_bi.version<1.8)||(_bi.type==2&&_bi.subType==2)||(_bi.type==4&&_bi.version<9)){this.mapView.flipSheet();AlpsEvent.triggerEvent(this,"layerChanged");}else{this.mapView.fadeinFlipSheet("layer");}}};ProAtlasMapCtrl.prototype.onMouseWheel=function(e){if(!this.enableWheelOperation){return;}e=(e?e:window.event);var target=e.srcElement||e.target;var delta=e.wheelDelta?e.wheelDelta:e.detail*-1;if(_bi.type==4)delta*=-1;while(target!=this.mapView.mapContainer){if(target.parentNode==null)return;target=target.parentNode;}var layerId;if(delta<0){ layerId=this.mapView.frontSheet.layerId-1;}else{ layerId=this.mapView.frontSheet.layerId+1;}if(this.IsEnableLayer(this.mapView.frontSheet.packageId,layerId)){this.smoothLayerTo(layerId,true);}CancelBubble(e);return;};ProAtlasMapCtrl.prototype.onClick=function(e){if(!this.isMouseMoved){var pos=getRelativePos(e,this.mapView.mapContainer);var lpPoint=this.mapView.conv.Log2LL(pos);if(this.enableSingleClickCentering){if(this.enableSmoothScroll){this.startSmoothCentering(pos,true);}else{this.moveTo(lpPoint,null,true/*fromUI*/,false/*fromSmoothCentering*/,true/*fromInside*/);}}AlpsEvent.triggerEvent(this,"click",this.toOutside(lpPoint,true),_buttonLeft);}};ProAtlasMapCtrl.prototype.onDblClick=function(e){var pos=getRelativePos(e,this.mapView.mapContainer);var lpPoint=this.mapView.conv.Log2LL(pos);if(this.enableDbClickCentering){if(this.enableSmoothScroll){this.startSmoothCentering(pos,true);}else{this.moveTo(lpPoint,null,true/*fromUI*/,false/*fromSmoothCentering*/,true/*fromInside*/);}}AlpsEvent.triggerEvent(this,"dbClick",this.toOutside(lpPoint,true));};ProAtlasMapCtrl.prototype.onContextMenu=function(e){if(_bi.type==1||_bi.type==2||_bi.type==3){ var pos=getRelativePos(e,this.mapView.mapContainer);var lpPoint=this.mapView.conv.Log2LL(pos);AlpsEvent.triggerEvent(this,"click",this.toOutside(lpPoint,true),_buttonRight);}};ProAtlasMapCtrl.prototype.startSmoothCentering=function(pos,fromUI){this.stopFlightScroll(fromUI);AlpsEvent.triggerEvent(this,"mapSmoothMoving");var centerX=this.mapView.conv.m_windowWidth/2;var centerY=this.mapView.conv.m_windowHeight/2;var targetX=pos.x-centerX;var targetY=pos.y-centerY;var dist=Math.sqrt((targetX*targetX+targetY*targetY)/(centerX*centerX+centerY*centerY));this.cntrngCrrntStep=0; this.cntrngElapseTime=10; this.cntrngTotalTime=dist>0.2?200:50; this.targetSize.width=targetX; this.targetSize.height=targetY; this.currentPos.x=0; this.currentPos.y=0; if(fromUI==null){fromUI=false;}this.cntrngTimerId=_setTimeout(this,this.smoothCentering,1,fromUI);};ProAtlasMapCtrl.prototype.smoothCentering=function(fromUI){this.cntrngCrrntStep+=1;var t=this.cntrngCrrntStep*this.cntrngElapseTime/this.cntrngTotalTime;var targetX=this.targetSize.width*(2*t-t*t);var targetY=this.targetSize.height*(2*t-t*t);var targetPos=new Point(this.mapView.conv.m_windowWidth/2+targetX-this.currentPos.x,this.mapView.conv.m_windowHeight/2+targetY-this.currentPos.y);var lpTarget=this.mapView.conv.Log2LL(targetPos);this.moveTo(lpTarget,null,fromUI,true/*fromSmoothCentering*/,true/*fromInside*/);this.currentPos.x=targetX;this.currentPos.y=targetY;if(t<1){this.cntrngTimerId=_setTimeout(this,this.smoothCentering,this.cntrngElapseTime,fromUI);}else{this.cntrngTimerId=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);}};ProAtlasMapCtrl.prototype.stopSmoothCentering=function(fromUI){if(this.cntrngTimerId!=0){clearTimeout(this.cntrngTimerId);this.cntrngTimerId=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);return true;}else{return false;}};ProAtlasMapCtrl.prototype.startFlightScroll=function(){if(this.flightScrollTimerId==0){this.flightScrollCount=0;this.flightScrollTimerId=_setTimeout(this,this.flightScroll,5);}};ProAtlasMapCtrl.prototype.stopFlightScroll=function(fromUI){if(this.flightScrollTimerId!=0){clearTimeout(this.flightScrollTimerId);this.flightScrollTimerId=0;this.velocityX=0;this.velocityY=0;if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);return true;}else{return false;}};ProAtlasMapCtrl.prototype.flightScroll=function(){var accelerationX=0;var accelerationY=0;var acceleration=this.accelerationOfJetEngine;if(this.arrowKeys.contains(16)){acceleration*=3;} if(this.arrowKeys.contains(37)){accelerationX-=acceleration;}if(this.arrowKeys.contains(39)){accelerationX+=acceleration;}if(this.arrowKeys.contains(38)){accelerationY-=acceleration;}if(this.arrowKeys.contains(40)){accelerationY+=acceleration;}this.flightScrollCore(accelerationX,accelerationY,this.flightScrollElapseTime/1000);if(this.velocityX!=0||this.velocityY!=0){if(this.flightScrollCount>=50){this.flightScrollCount=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}else{this.flightScrollCount+=1;}this.flightScrollTimerId=_setTimeout(this,this.flightScroll,this.flightScrollElapseTime);}else{this.flightScrollTimerId=0;AlpsEvent.triggerEvent(this,"mapMoved",true);}};ProAtlasMapCtrl.prototype.flightScrollCore=function(accelerationX,accelerationY,duration){var airResistanceX=-this.coefficientOfAirResistance*this.velocityX;var airResistanceY=-this.coefficientOfAirResistance*this.velocityY;var resultantX=this.objectMass*accelerationX+airResistanceX;var resultantY=this.objectMass*accelerationY+airResistanceY;var aX=resultantX/this.objectMass;var aY=resultantY/this.objectMass;var targetX=this.velocityX*duration+0.5*aX*duration*duration;var targetY=this.velocityY*duration+0.5*aY*duration*duration;if(Math.abs(targetX)<2&&Math.abs(targetY)<2){this.velocityX=0;this.velocityY=0;}else{this.velocityX=targetX/duration;this.velocityY=targetY/duration;if(targetX!=0||targetY!=0){var targetPos=new Point(this.mapView.conv.m_windowWidth/2+targetX,this.mapView.conv.m_windowHeight/2+targetY);var lpTarget=this.mapView.conv.Log2LL(targetPos);this.moveTo(lpTarget,true,true/*fromUI*/,false/*fromSmoothCentering*/,true/*fromInside*/);}}};ProAtlasMapCtrl.prototype.mapMoving=function(){if(this.mapView.backSheet.getVisible()){this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();}if(this.mapMovedTimerId){window.clearTimeout(this.mapMovedTimerId);this.mapMovedTimerId=0;}};ProAtlasMapCtrl.prototype.mapMoved=function(){if(this.mapMovedTimerId){window.clearTimeout(this.mapMovedTimerId);this.mapMovedTimerId=0;}this.mapMovedTimerId=_setTimeout(this,this.timer_updateLayerScaleList,_delaytime);};ProAtlasMapCtrl.prototype.timer_updateLayerScaleList=function(){if(this.yahooMapLayer){this.updateLayerScaleList();}else{for(var i=0;i<this.mapView.packageCollect.length;++i){this.updateLayerScaleList(this.mapView.packageCollect[i]);}}};ProAtlasMapCtrl.prototype.layerListChanged=function(packageId){if(packageId!=this.getCurrentPackageId()){return;}if(packageId==this.mapView.frontSheet.packageId){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var currentProjId=this.mapView.frontSheet.projId;var projInfo=layer.getEnableProjInfo(this.layerCodeList[packageId],currentProjId);if(projInfo&&currentProjId!=projInfo.id){this.mapView.frontSheet.projId=projInfo.id;var tempPackageId=this.mapView.frontSheet.packageId;var lpTarget=this.mapView.conv.m_center;var tempLayerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.frontSheet.setCenterAndScale(lpTarget,tempPackageId,tempLayerId,magnify,angle,bGetNewImage,bProjectionChange);}}if(this.enableAutoLayerChange){var layerId=this.getCurrentLayerId();if(this.IsEnableLayer(packageId,layerId)){return;}while(true){layerId+=1;if(layerId>=this.getLayerCount()){break;}if(this.IsEnableLayer(packageId,layerId)){this.smoothLayerTo(layerId,true);break;}}}};ProAtlasMapCtrl.prototype.updateLayerScaleList=function(packageId){if(packageId){if(this.mapView.getMapPackage(packageId).layerServerType=="callback"){this.updateLayerScaleListByJson(packageId);}else{this.updateLayerScaleListByXMLHttp(packageId);}}else{if(this.yahooMapLayerType=="callback"){this.updateYahooLayerScaleListByJason();}else{this.updateYahooLayerScaleListByXMLHttp();}}};ProAtlasMapCtrl.prototype.updateLayerScaleListByXMLHttp=function(packageId){var xmlhttp=AlpsUtil.getXMLHttp();if(!xmlhttp)return;var p=this.mapView.conv.m_center;var layerServerName=this.mapView.getMapPackage(packageId).layerServerName;if(!layerServerName)return;var mapCtrl=this;var timerIdProp="getLayerTimerId_"+packageId;xmlhttp.open("POST",layerServerName,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(mapCtrl[timerIdProp]){window.clearTimeout(mapCtrl[timerIdProp]);mapCtrl[timerIdProp]=null;}var currentCenter=mapCtrl.mapView.conv.m_center;if(currentCenter.lat!=p.lat||currentCenter.lon!=p.lon){return;}var count=mapCtrl.layerScaleList[packageId].length;for(var i=0;i<count;++i){mapCtrl.layerScaleList[packageId].pop();mapCtrl.layerCodeList[packageId].pop();}if(xmlhttp.status==200&&xmlhttp.responseXML){var layers=AlpsUtil.getElementContent(xmlhttp.responseXML,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){mapCtrl.layerScaleList[packageId].push(parseInt(s[i]));}}var nR=xmlhttp.responseXML.getElementsByTagName("result")[0];var nRChild=nR.childNodes;for(var i=0;i<nRChild.length;++i){var n=nRChild[i];if(n.nodeType==1&&n.nodeName=="layer"){var code=n.getAttribute("code");var scale=AlpsUtil.getNodeContent(n);var layerCode=new Object;layerCode.scale=scale;layerCode.code=code;mapCtrl.layerCodeList[packageId].push(layerCode);}}}else{var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){mapCtrl.layerScaleList[packageId].push(layerCollect[i].scale);}}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId);}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var coordinates=doc.createElement("coordinates");query.appendChild(coordinates);coordinates.appendChild(doc.createTextNode(p.toString()));xmlhttp.send(doc);if(this[timerIdProp]){window.clearTimeout(this[timerIdProp]);this[timerIdProp]=null;}this[timerIdProp]=_setTimeout(this,this.getLayerTimeoutFn,3000,packageId);};ProAtlasMapCtrl.prototype.getLayerTimeoutFn=function(packageId){var count=this.layerScaleList[packageId].length;for(var i=0;i<count;++i){this.layerScaleList[packageId].pop();}var timerIdProp="getLayerTimerId_"+packageId;this[timerIdProp]=null;var layerCollect=this.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){this.layerScaleList[packageId].push(layerCollect[i].scale);}AlpsEvent.triggerEvent(this,"layerListChanged",packageId);};ProAtlasMapCtrl.prototype.updateYahooLayerScaleListByXMLHttp=function(){var xmlhttp=AlpsUtil.getXMLHttp();if(!xmlhttp)return;var p=this.mapView.conv.m_center;var layerServerName=this.yahooMapLayer;if(!layerServerName)return;var mapCtrl=this;var timerIdProp="getLayerTimerId";xmlhttp.open("POST",layerServerName,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(mapCtrl[timerIdProp]){window.clearTimeout(mapCtrl[timerIdProp]);mapCtrl[timerIdProp]=null;}var currentCenter=mapCtrl.mapView.conv.m_center;if(currentCenter.lat!=p.lat||currentCenter.lon!=p.lon){return;}if(xmlhttp.status==200&&xmlhttp.responseXML){var mappackageTags=xmlhttp.responseXML.getElementsByTagName("mappackage");for(var j=0;j<mappackageTags.length;++j){var mappackageTag=mappackageTags[j];var packageId=mappackageTag.getAttribute("id");if(!mapCtrl.IsExistPackage(packageId))continue;mapCtrl.layerScaleList[packageId]._clear();mapCtrl.layerCodeList[packageId]._clear();var layers=AlpsUtil.getElementContent(mappackageTag,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){mapCtrl.layerScaleList[packageId].push(parseInt(s[i]));}}var nR=mappackageTag;var nRChild=nR.childNodes;for(var i=0;i<nRChild.length;++i){var n=nRChild[i];if(n.nodeType==1&&n.nodeName=="layer"){var code=n.getAttribute("code");var scale=AlpsUtil.getNodeContent(n);var layerCode=new Object;layerCode.scale=scale;layerCode.code=code;mapCtrl.layerCodeList[packageId].push(layerCode);}}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId);}}else{mapCtrl.getYahooLayerTimeoutFn();}}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var coordinates=doc.createElement("coordinates");query.appendChild(coordinates);coordinates.appendChild(doc.createTextNode(p.toString()));xmlhttp.send(doc);if(this[timerIdProp]){window.clearTimeout(this[timerIdProp]);this[timerIdProp]=null;}this[timerIdProp]=_setTimeout(this,this.getYahooLayerTimeoutFn,3000);};ProAtlasMapCtrl.prototype.getYahooLayerTimeoutFn=function(){var packageList=this.getPackageList();for(var i=0;i<packageList.length;++i){var packageId=packageList[i];this.layerScaleList[packageId]._clear();var timerIdProp="getLayerTimerId";this[timerIdProp]=null;var layerCollect=this.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){this.layerScaleList[packageId].push(layerCollect[i].scale);}AlpsEvent.triggerEvent(this,"layerListChanged",packageId);}};ProAtlasMapCtrl.prototype.updateLayerScaleListByJson=function(packageId){var p=this.mapView.conv.m_center;var layerServerName=this.mapView.getMapPackage(packageId).layerServerName;if(!layerServerName)return;layerServerName=layerServerName+"?c="+p.toString();var mapCtrl=this;_cb.send(layerServerName,function(ary){if(ary!=undefined){var currentCenter=mapCtrl.mapView.conv.m_center;if(currentCenter.lat!=p.lat||currentCenter.lon!=p.lon){return;}mapCtrl.layerScaleList[packageId]._clear();mapCtrl.layerCodeList[packageId]._clear();for(var i=0;i<ary.length;++i){mapCtrl.layerScaleList[packageId].push(parseInt(ary[i].scale));var layerCode=new Object;layerCode.scale=ary[i].scale;layerCode.code=ary[i].code;mapCtrl.layerCodeList[packageId].push(layerCode);}}else {var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){mapCtrl.layerScaleList[packageId].push(layerCollect[i].scale);}}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId);});};ProAtlasMapCtrl.prototype.updateYahooLayerScaleListByJason=function(){var p=this.mapView.conv.m_center;var layerServerName=this.yahooMapLayer;if(!layerServerName)return;layerServerName=layerServerName+"?c="+p.toString();var mapCtrl=this;_cb.send(layerServerName,function(obj){if(obj!=undefined){var currentCenter=mapCtrl.mapView.conv.m_center;if(currentCenter.lat!=p.lat||currentCenter.lon!=p.lon){return;}var packageList=mapCtrl.getPackageList();for(var j=0;j<packageList.length;++j){var packageId=packageList[j];mapCtrl.layerScaleList[packageId]._clear();mapCtrl.layerCodeList[packageId]._clear();var ary=obj[packageId];if(ary!=undefined){for(var i=0;i<ary.length;++i){mapCtrl.layerScaleList[packageId].push(parseInt(ary[i].scale));var layerCode=new Object;layerCode.scale=ary[i].scale;layerCode.code=ary[i].code;mapCtrl.layerCodeList[packageId].push(layerCode);}}else{var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){mapCtrl.layerScaleList[packageId].push(layerCollect[i].scale);}}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId);}}else {var packageList=mapCtrl.getPackageList();for(var j=0;j<packageList.length;++j){var packageId=packageList[j];mapCtrl.layerScaleList[packageId]._clear();mapCtrl.layerCodeList[packageId]._clear();var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){mapCtrl.layerScaleList[packageId].push(layerCollect[i].scale);}AlpsEvent.triggerEvent(mapCtrl,"layerListChanged",packageId);}}});};ProAtlasMapCtrl.prototype.IsEnableLayer=function(packageId,layerId){var mapPackage=this.mapView.getMapPackage(packageId);var scale=mapPackage.getLayerScale(layerId);var layerScaleList=this.layerScaleList[packageId];for(var i=0;i<layerScaleList.length;++i){if(layerScaleList[i]==scale){return true;}}return false;};ProAtlasMapCtrl.prototype.toInside=function(outLL,bDoConvert){var inLL=null;if(bDoConvert&&(this.datum=="wgs84")){inLL=BesslWgs(1,outLL);}else{inLL=new LLPoint(outLL.lat,outLL.lon);}return inLL;};ProAtlasMapCtrl.prototype.toOutside=function(inLL,bDoConvert){var outLL=null;if(bDoConvert&&(this.datum=="wgs84")){outLL=BesslWgs(0,inLL);}else{outLL=new LLPoint(inLL.lat,inLL.lon);}return outLL;};ProAtlasMapCtrl.prototype.moveTo=function(lpPoint,bAvoidStopFlightScroll,fromUI,fromSmoothCentering,fromInside){var target=this.toInside(lpPoint,!fromInside);target=this.checkScrollRange(target);if(fromSmoothCentering==null){fromSmoothCentering=false;}if(!fromSmoothCentering){this.stopSmoothCentering(fromUI);}if(bAvoidStopFlightScroll==null){bAvoidStopFlightScroll=false;}if(!bAvoidStopFlightScroll){this.stopFlightScroll(fromUI);}var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(target,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"mapMoving");if(!this.isMouseDown&& !fromSmoothCentering&& this.velocityX==0&&this.velocityY==0 ){if(fromUI==null){fromUI=false;}AlpsEvent.triggerEvent(this,"mapMoved",fromUI);}};ProAtlasMapCtrl.prototype.checkScrollRange=function(lpPoint){var mapLayer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.getCurrentLayerId()];var projInfo=mapLayer.projInfo[this.mapView.frontSheet.projId];var target=new LLPoint(lpPoint.lat,lpPoint.lon);if(!mapLayer.scrollrange.enable){return target;}var conv=new CoordinatesConversion();conv.setProjConv(projInfo.code,new LLPoint(projInfo.origin.lat,projInfo.origin.lon),projInfo.subInfo);conv.setScale(this.getCurrentScale()/this.getCurrentMagnify());conv.setAngle(0);conv.setCenter(this.mapView.conv.m_center);var mtrBottomLeft=conv.LL2Meter(mapLayer.scrollrange.bottomleftLatLon);var mtrTopRight=conv.LL2Meter(mapLayer.scrollrange.toprightLatLon);var mtrTarget=conv.LL2Meter(target);var restricted=false;if(mtrTarget.x<mtrBottomLeft.x){restricted=true;mtrTarget.x=mtrBottomLeft.x;}if(mtrTarget.y<mtrBottomLeft.y){restricted=true;mtrTarget.y=mtrBottomLeft.y;}if(mtrTopRight.x<mtrTarget.x){restricted=true;mtrTarget.x=mtrTopRight.x;}if(mtrTopRight.y<mtrTarget.y){restricted=true;mtrTarget.y=mtrTopRight.y;}if(restricted){target=conv.Meter2LL(mtrTarget);}return target;};ProAtlasMapCtrl.prototype.smoothMoveTo=function(lpPoint){var target=this.toInside(lpPoint,true);this.stopSmoothCentering();this.stopFlightScroll();var targetPos=this.mapView.conv.LL2Log(target);this.startSmoothCentering(targetPos);};ProAtlasMapCtrl.prototype.emergeMoveTo=function(lpPoint){var target=this.toInside(lpPoint,true);var target=this.checkScrollRange(target);var fromUI=false;this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);if(this.mapView.isFadeinFlipping()){this.mapView.stopFadeinFlipping();}this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=false;this.mapView.backSheet.setCenterAndScale(target,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.fadeinFlipSheet("mapmove");};ProAtlasMapCtrl.prototype.packageTo=function(packageId){if(this.zoomTimerId!=0){return;}this.stopSmoothCentering();this.stopFlightScroll();var layerId=null;var scale=0;if(this.mapView.frontSheet.layerId!=null){scale=this.mapView.getMapPackage(this.mapView.frontSheet.packageId).getLayerScale(this.mapView.frontSheet.layerId);}if(scale!=0){layerId=this.mapView.getMapPackage(packageId).getLayerId(scale);}this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();var lpTarget=this.mapView.conv.m_center;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.flipSheet();AlpsEvent.triggerEvent(this,"packageChanged");if(this.mapView.frontSheet.angle!=this.mapView.backSheet.angle){AlpsEvent.triggerEvent(this,"angleChanged");}};ProAtlasMapCtrl.prototype.smoothPackageTo=function(packageId){if(_bi.type==4&&_bi.version<9){this.packageTo(packageId);return;}if(this.mapView.fadeinTimerId!=0){return;}if(this.zoomTimerId!=0){return;}if(packageId==this.mapView.frontSheet.packageId){return;}this.stopSmoothCentering();this.stopFlightScroll();AlpsEvent.triggerEvent(this,"smoothPackageChanging",this.mapView.frontSheet.packageId,packageId);var layerId=null;var scale=0;if(this.mapView.frontSheet.layerId!=null){scale=this.mapView.getMapPackage(this.mapView.frontSheet.packageId).getLayerScale(this.mapView.frontSheet.layerId);}if(scale!=0){layerId=this.mapView.getMapPackage(packageId).getLayerId(scale);}this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();var lpTarget=this.mapView.conv.m_center;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.fadeinFlipSheet("package");};ProAtlasMapCtrl.prototype.layerTo=function(layerId,sheet,fromUI){if(this.zoomTimerId!=0){return;}sheet=this.mapView.frontSheet;if(fromUI){var mapPackage=sheet.getCurrentPackage();if(0<=layerId&&layerId<mapPackage.layerCollect.length){if(!mapPackage.layerCollect[layerId].operation){return;}}}if(layerId<0){layerId=0;}else if(sheet.getCurrentPackage().layerCollect.length<=layerId){layerId=sheet.getCurrentPackage().layerCollect.length-1;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();var packageId=sheet.packageId;var lpTarget=this.mapView.conv.m_center;var magnify=sheet.magnify;var angle=sheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.flipSheet();AlpsEvent.triggerEvent(this,"layerChanged");};ProAtlasMapCtrl.prototype.smoothLayerTo=function(layerId,fromUI){if(this.zoomTimerId!=0){return;}if(this.mapView.isFadeinFlipping()){this.mapView.stopFadeinFlipping();}var mapPackage=this.mapView.frontSheet.getCurrentPackage();if(mapPackage!=null&&layerId<0){layerId=0;}else if(mapPackage!=null&&mapPackage.layerCollect.length<=layerId){layerId=mapPackage.layerCollect.length-1;}if(layerId==this.mapView.frontSheet.layerId){return;}if(fromUI){if(!mapPackage.layerCollect[layerId].operation){return;}}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);AlpsEvent.triggerEvent(this,"smoothLayerChanging",this.mapView.frontSheet.layerId,layerId);this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();this.mapView.backSheet.magnify=1;var bGetNewImage=true;this.mapView.backSheet.setTileCount(this.mapView.conv.m_windowWidth,this.mapView.conv.m_windowHeight,bGetNewImage);var packageId=this.mapView.frontSheet.packageId;var lpTarget=this.mapView.conv.m_center;var angle=this.mapView.frontSheet.angle;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,this.mapView.backSheet.magnify,angle,bGetNewImage,bProjectionChange);var currentScale=mapPackage.getLayerScale(this.mapView.frontSheet.layerId);var targetScale=mapPackage.getLayerScale(this.mapView.backSheet.layerId);this.targetMagnify=currentScale/targetScale;if(!this.enableZoomendFadeinEfct||(_bi.type==2&&_bi.subType==1&&_bi.version<1.5)||(_bi.type==2&&_bi.subType==3&&_bi.version<1.8)||(_bi.type==2&&_bi.subType==2)||(_bi.type==4&&_bi.version<9)){this.stepMagnify=Math.pow(this.targetMagnify,0.1);}else{this.stepMagnify=Math.pow(this.targetMagnify,0.2);}this.isSmoothZoomEnd=false;this.zoomTimerId=_setTimeout(this,this.smoothZoom,this.zoomElapseTime);};ProAtlasMapCtrl.prototype.moveAndLayerTo=function(lpPoint,layerId,fromInside){if(this.zoomTimerId!=0){return;}var target=this.toInside(lpPoint,!fromInside);this.stopSmoothCentering();this.stopFlightScroll();var mapPackage=this.mapView.frontSheet.getCurrentPackage();if(mapPackage!=null&&layerId<0){layerId=0;}else if(mapPackage!=null&&mapPackage.layerCollect.length<=layerId){layerId=mapPackage.layerCollect.length-1;}this.mapView.backSheet.setVisible(false);this.mapView.backSheet.resetAllTiles();var packageId=this.mapView.frontSheet.packageId;var magnify=this.mapView.frontSheet.magnify;var angle=this.mapView.frontSheet.angle;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(target,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.flipSheet();AlpsEvent.triggerEvent(this,"mapMoving");AlpsEvent.triggerEvent(this,"mapMoved",false);AlpsEvent.triggerEvent(this,"layerChanged");};ProAtlasMapCtrl.prototype.magnifyTo=function(magnify,fromUI,bGetNewImage){if(this.zoomTimerId!=0){return;}if(this.mapView.isFadeinFlipping()){this.mapView.stopFadeinFlipping();}if(bGetNewImage==undefined){bGetNewImage=true;}if(bGetNewImage){if(magnify<_minMagnify){magnify=_minMagnify;}if(magnify>_maxMagnify){magnify=_maxMagnify;}}if(this.getCurrentMagnify()==magnify){return;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);this.mapView.backSheet.setVisible(false);var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var angle=this.mapView.frontSheet.angle;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"magnifyChanged");};ProAtlasMapCtrl.prototype.defaultTo=function(){var layerId=this.mapView.getMapPackage(this.defPackageId).getLayerId(this.defScale);this.magnifyTo(1);this.packageTo(this.defPackageId);this.moveAndLayerTo(this.defPos,layerId,true);};ProAtlasMapCtrl.prototype.latLon2Log=function(lpPoint){var inLL=this.toInside(lpPoint,true);return this.mapView.conv.LL2Log(inLL);};ProAtlasMapCtrl.prototype.log2LatLon=function(point){var lpPoint=this.mapView.conv.Log2LL(point);return this.toOutside(lpPoint,true);};ProAtlasMapCtrl.prototype.setEnableDragScroll=function(bEnable){this.enableDragScroll=bEnable;};ProAtlasMapCtrl.prototype.getEnableDragScroll=function(){return this.enableDragScroll;};ProAtlasMapCtrl.prototype.setEnableDbClickCentering=function(newVal){this.enableDbClickCentering=newVal;};ProAtlasMapCtrl.prototype.getEnableDbClickCentering=function(){return this.enableDbClickCentering;};ProAtlasMapCtrl.prototype.setEnableSingleClickCentering=function(newVal){this.enableSingleClickCentering=newVal;};ProAtlasMapCtrl.prototype.getEnableSingleClickCentering=function(){return this.enableSingleClickCentering;};ProAtlasMapCtrl.prototype.setEnableKeyboardOperation=function(bEnable){this.enableKeyboardOperation=bEnable;if(!bEnable){this.arrowKeys.sleep();}else{this.arrowKeys.wakeup();this.startFlightScroll();}};ProAtlasMapCtrl.prototype.getEnableKeyboardOperation=function(){return this.enableKeyboardOperation;};ProAtlasMapCtrl.prototype.setEnableMagnifyOperation=function(bEnable){this.enableMagnifyOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableMagnifyOperation=function(){return this.enableMagnifyOperation;};ProAtlasMapCtrl.prototype.setEnableLayerOperation=function(bEnable){this.enableLayerOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableLayerOperation=function(){return this.enableLayerOperation;};ProAtlasMapCtrl.prototype.setEnableSmoothLayerOperation=function(bEnable){this.enableSmoothLayerOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableSmoothLayerOperation=function(){return this.enableSmoothLayerOperation;};ProAtlasMapCtrl.prototype.setEnableAngleOperation=function(bEnable){this.enableAngleOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnableAngleOperation=function(){return this.enableAngleOperation;};ProAtlasMapCtrl.prototype.setEnableSmoothScroll=function(bEnable){this.enableSmoothScroll=bEnable;};ProAtlasMapCtrl.prototype.getEnableSmoothScroll=function(){return this.enableSmoothScroll;};ProAtlasMapCtrl.prototype.setEnableWheelOperation=function(bEnable){this.enableWheelOperation=bEnable;if(this.enableWheelOperation){this.addWheelEvent();}else{this.removeWheelEvent();}};ProAtlasMapCtrl.prototype.getEnableWheelOperation=function(){return this.enableWheelOperation;};ProAtlasMapCtrl.prototype.setEnableZoomendFadeinEfct=function(bEnable){this.enableZoomendFadeinEfct=bEnable;};ProAtlasMapCtrl.prototype.getEnableZoomendFadeinEfct=function(){return this.enableZoomendFadeinEfct;};ProAtlasMapCtrl.prototype.setEnablePackageOperation=function(bEnable){this.enablePackageOperation=bEnable;};ProAtlasMapCtrl.prototype.getEnablePackageOperation=function(){return this.enablePackageOperation;};ProAtlasMapCtrl.prototype.setVisibleCenterMark=function(newVal){this.mapView.setVisibleCenterMark(newVal);};ProAtlasMapCtrl.prototype.getVisibleCenterMark=function(){return this.mapView.getVisibleCenterMark();};ProAtlasMapCtrl.prototype.setVisibleCopyright=function(newVal){this.mapView.setVisibleCopyright(newVal);};ProAtlasMapCtrl.prototype.getVisibleCopyright=function(){this.mapView.getVisibleCopyright();};ProAtlasMapCtrl.prototype.setEnableAutoLayerChange=function(newVal){this.enableAutoLayerChange=newVal;};ProAtlasMapCtrl.prototype.getEnableAutoLayerChange=function(){return this.enableAutoLayerChange;};ProAtlasMapCtrl.prototype.setDatum=function(newDatum){this.datum=newDatum;};ProAtlasMapCtrl.prototype.getDatum=function(){return this.datum;};ProAtlasMapCtrl.prototype.getCenterLatLon=function(){return this.toOutside(this.mapView.conv.m_center,true);};ProAtlasMapCtrl.prototype.getCurrentPackageId=function(){return this.mapView.frontSheet.packageId;};ProAtlasMapCtrl.prototype.getPackageList=function(){var array=new Array;for(var i=0;i<this.mapView.packageCollect.length;++i){array.push(this.mapView.packageCollect[i]);}return array;};ProAtlasMapCtrl.prototype.IsExistPackage=function(id){var bExist=false;for(var i=0;i<this.mapView.packageCollect.length;++i){if(this.mapView.packageCollect[i]==id){bExist=true;break;}}return bExist;};ProAtlasMapCtrl.prototype.getCurrentLayerId=function(){return this.mapView.frontSheet.layerId;};ProAtlasMapCtrl.prototype.getCurrentScale=function(){return this.getLayerScale(this.getCurrentLayerId());};ProAtlasMapCtrl.prototype.getCurrentMagnify=function(){return this.mapView.frontSheet.magnify;};ProAtlasMapCtrl.prototype.getLayerCount=function(){var mapPackage=this.mapView.frontSheet.getCurrentPackage();return mapPackage.layerCollect.length;};ProAtlasMapCtrl.prototype.getLayerId=function(scale,mode){return this.mapView.frontSheet.getCurrentPackage().getLayerId(scale,mode);};ProAtlasMapCtrl.prototype.getLayerScale=function(layerId){var mapPackage=this.mapView.frontSheet.getCurrentPackage();return mapPackage.getLayerScale(layerId);};ProAtlasMapCtrl.prototype.getContainer=function(){return this.mapView.mapContainer;};ProAtlasMapCtrl.prototype.getLayerScaleList=function(packageId){if(packageId==null){packageId=this.mapView.frontSheet.packageId;}var ret=new Array;for(var i=0;i<this.layerScaleList[packageId].length;++i){ret.push(this.layerScaleList[packageId][i]);}return ret;};ProAtlasMapCtrl.prototype.asyncGetLayerScaleList=function(packageId,lpPoint,returnFunc){if(packageId==null){packageId=this.mapView.frontSheet.packageId;}if(!this.mapView.ExistMapPackage(packageId)){return;}var lpTarget=this.toInside(lpPoint,true);if(this.mapView.getMapPackage(packageId).layerServerType=="callback"||this.yahooMapLayerType=="callback"){this.asyncGetLayerScaleListByJason(packageId,lpTarget,returnFunc);}else{this.asyncGetLayerScaleListByXMLHttp(packageId,lpTarget,returnFunc);}};ProAtlasMapCtrl.prototype.asyncGetLayerScaleListByXMLHttp=function(packageId,lpTarget,returnFunc){var xmlhttp=AlpsUtil.getXMLHttp();if(!xmlhttp)return;var layerServerName="";if(this.yahooMapLayer){layerServerName=this.yahooMapLayer;}else{layerServerName=this.mapView.getMapPackage(packageId).layerServerName;}var mapCtrl=this;xmlhttp.open("POST",layerServerName,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){var layerScaleList=new Array;if(xmlhttp.status==200&&xmlhttp.responseXML){if(mapCtrl.yahooMapLayer){var mappackageTags=xmlhttp.responseXML.getElementsByTagName("mappackage");for(var j=0;j<mappackageTags.length;++j){var mappackageTag=mappackageTags[j];if(packageId!=mappackageTag.getAttribute("id"))continue;var layers=AlpsUtil.getElementContent(mappackageTag,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){layerScaleList.push(parseInt(s[i]));}}}}else{var layers=AlpsUtil.getElementContent(xmlhttp.responseXML,"layers");if(layers){var s=layers.split(",");for(var i=0;i<s.length;++i){layerScaleList.push(parseInt(s[i]));}}}}else {var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){layerScaleList.unshift(layerCollect[i].scale);}}returnFunc(layerScaleList);}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var coordinates=doc.createElement("coordinates");query.appendChild(coordinates);coordinates.appendChild(doc.createTextNode(lpTarget.toString()));xmlhttp.send(doc);};ProAtlasMapCtrl.prototype.asyncGetLayerScaleListByJason=function(packageId,lpTarget,returnFunc){var p=this.mapView.conv.m_center;var layerServerName="";if(this.yahooMapLayer){layerServerName=this.yahooMapLayer;}else{layerServerName=this.mapView.getMapPackage(packageId).layerServerName;}if(!layerServerName)return;layerServerName=layerServerName+"?c="+lpTarget.toString();var mapCtrl=this;_cb.send(layerServerName,function(obj){var layerScaleList=new Array;if(obj!=undefined){var ary;if(mapCtrl.yahooMapLayer){ary=obj[packageId];}else{ary=obj;}if(ary){for(var i=0;i<ary.length;++i){layerScaleList.push(parseInt(ary[i].scale));}}else{var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){layerScaleList.unshift(layerCollect[i].scale);}}}else {var layerCollect=mapCtrl.mapView.getMapPackage(packageId).layerCollect;for(var i=0;i<layerCollect.length;++i){layerScaleList.unshift(layerCollect[i].scale);}}returnFunc(layerScaleList);});};ProAtlasMapCtrl.prototype.setSize=function(width,height){if(width){this.mapView.mapContainer.style.width=width+"px";}if(height){this.mapView.mapContainer.style.height=height+"px";}this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.resetCenter=function(){this.mapView.resizeMapView();AlpsEvent.triggerEvent(this,"resize");};ProAtlasMapCtrl.prototype.getProjOrigin=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);return new LLPoint(projInfo.origin.lat,projInfo.origin.lon);};ProAtlasMapCtrl.prototype.getProjection=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);if(projInfo.code==0){return 0;}else{if(projInfo.subInfo==0){return 1;}else{return 2;}}};ProAtlasMapCtrl.prototype.getProjFactor=function(){var layer=this.mapView.frontSheet.getCurrentPackage().layerCollect[this.mapView.frontSheet.layerId];var projInfo=layer.getProjInfoById(this.mapView.frontSheet.projId);if(projInfo.code==0){return projInfo.subInfo;}else{return 0;}};ProAtlasMapCtrl.prototype.getSuitableScale=function(lpBottomLeft,lpTopRight){var mtClientWidth=this.mapView.conv.m_windowWidth;var mtClientHeight=this.mapView.conv.m_windowHeight;var mtOrigin=this.mapView.conv.LL2Meter(lpBottomLeft);var mtEnd=this.mapView.conv.LL2Meter(lpTopRight);var mtTargetWidth=Math.abs(mtEnd.x-mtOrigin.x);var mtTargetHeight=Math.abs(mtEnd.y-mtOrigin.y);return Math.max(mtTargetWidth/mtClientWidth*10*1000, mtTargetHeight/mtClientHeight*10*1000);};ProAtlasMapCtrl.prototype.getSuitableLayerId=function(lpBottomLeft,lpTopRight){var mode=1; return this.getLayerId(this.getSuitableScale(lpBottomLeft,lpTopRight),mode);};ProAtlasMapCtrl.prototype.setVecHeimenVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecHeimen=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecHeimenVisible=function(){return this.vectorOpe.visibleVecHeimen;};ProAtlasMapCtrl.prototype.setVecTyukiVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecTyuki=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecTyukiVisible=function(){return this.vectorOpe.visibleVecTyuki;};ProAtlasMapCtrl.prototype.setVecRasterVisible=function(visible){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.visibleVecRaster=visible;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecRasterVisible=function(){return this.vectorOpe.visibleVecRaster;};ProAtlasMapCtrl.prototype.setVecSpecType=function(specType){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.vecSpecType=specType;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);};ProAtlasMapCtrl.prototype.getVecSpecType=function(){return this.vectorOpe.vecSpecType;};ProAtlasMapCtrl.prototype.getVecSpecTypeList=function(packageId,layerId){var layer=this.mapView.getMapPackage(packageId).layerCollect[layerId];var newSpecType=new Array;for(var i=0;i<layer.specType.length;++i){var spec=new SpecType();spec.id=layer.specType[i].id;spec.name=layer.specType[i].name;newSpecType.push(spec);}return newSpecType;};ProAtlasMapCtrl.prototype.setVecSpecItemVisible=function(itemId,visible){if(visible){var newSpecHide=new Array;var alreadyHide=false;for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){alreadyHide=true;}else{newSpecHide.push(this.vectorOpe.specHide[i]);}}if(alreadyHide){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.specHide=newSpecHide;var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);}}else{var alreadyHide=false;for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){alreadyHide=true;break;}}if(!alreadyHide){this.mapView.frontSheet.resetAllTiles();this.vectorOpe.specHide.push(itemId);var bGetNewImage=true;this.mapView.frontSheet.configureAllTiles(bGetNewImage);}}};ProAtlasMapCtrl.prototype.getVecSpecItemVisible=function(itemId){for(var i=0;i<this.vectorOpe.specHide.length;++i){if(this.vectorOpe.specHide[i]==itemId){return false;}}return true;};ProAtlasMapCtrl.prototype.getVecSpecItemList=function(packageId,layerId){var layer=this.mapView.getMapPackage(packageId).layerCollect[layerId];var newSpecItem=new Array;for(var i=0;i<layer.specItem.length;++i){var item=new SpecItem();item.id=layer.specItem[i].id;item.name=layer.specItem[i].name;newSpecItem.push(item);}return newSpecItem;};ProAtlasMapCtrl.prototype.angleTo=function(angle,fromUI){if(this.mapView.frontSheet.getCurrentPackage().mapServerSourceType!=2){return;}if(this.zoomTimerId!=0){return;}if(angle>=360) {angle-=360;}else if(angle<0){angle+=360;}if(this.getCurrentAngle()==angle){return;}this.stopSmoothCentering(fromUI);this.stopFlightScroll(fromUI);var lpTarget=this.mapView.conv.m_center;var packageId=this.mapView.frontSheet.packageId;var layerId=this.mapView.frontSheet.layerId;var magnify=this.mapView.frontSheet.magnify;var bGetNewImage=true;var bProjectionChange=false;this.mapView.frontSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);AlpsEvent.triggerEvent(this,"angleChanged");};ProAtlasMapCtrl.prototype.getCurrentAngle=function(){return this.mapView.frontSheet.angle;};ProAtlasMapCtrl.prototype.smoothAngleTo=function(angle){if(this.mapView.frontSheet.getCurrentPackage().mapServerSourceType!=2){return;}if(_bi.type!=1&&_bi.type!=2&&_bi.type!=3){this.angleTo(angle);return;}if(this.mapView.fadeinTimerId!=0){return;}if(this.zoomTimerId!=0){return;}if(angle>=360) {angle-=360;}else if(angle<0){angle+=360;}if(angle==this.getCurrentAngle()){return;}this.stopSmoothCentering();this.stopFlightScroll();AlpsEvent.triggerEvent(this,"smoothAngleChanging",this.getCurrentAngle(),angle);var lpTarget=this.mapView.conv.m_center;var packageId=this.getCurrentPackageId();var layerId=this.getCurrentLayerId();var magnify=this.mapView.frontSheet.magnify;var bGetNewImage=true;var bProjectionChange=true;this.mapView.backSheet.setCenterAndScale(lpTarget,packageId,layerId,magnify,angle,bGetNewImage,bProjectionChange);this.mapView.fadeinFlipSheet("angle");};ProAtlasMapCtrl.prototype.getMapserverSrcType=function(packageId){return this.mapView.getMapPackage(packageId).mapServerSourceType;};ProAtlasMapCtrl.prototype.setVisible=function(visible){this.mapView.frontSheet.setVisible(visible);};ProAtlasMapCtrl.prototype.release=function(){if(_bi.type!=1)return;_objrelease(this.vectorOpe,true);_objrelease(this.layerScaleList,true);_objrelease(this.layerCodeList,true);_objrelease(this);};
var _WideImage="sliderbar_wide.gif";var _WideImage_dis="disable_sliderbar_wide.gif";var _ZoomImage="sliderbar_zoom.gif";var _ZoomImage_dis="disable_sliderbar_zoom.gif";var _SlideBgImage="sliderbar_scale";var _SlideBgDisImage="disable_sliderbar_scale";var _GripImage="sliderbar_grip.gif";var _BlowImage="nomal_";var _BlowDisImage="disable-";var _BlowImgNumber=["03","06","08","10","12"];var _margin=4;var _gripLeft=12;var _blowLeft=18;var _blowTop=14;var _blowSlit=2;var _blowH=16;var _SlideBgImageH=9;var _SlideMagnBtnH=17;var _WideTooltip=decodeURIComponent("%E7%B8%AE%E5%B0%8F");var _ZoomTooltip=decodeURIComponent("%E6%8B%A1%E5%A4%A7");var _layerScales=[5000,10000,25000,70000,250000,500000,1000000,3000000,5000000,26000000];function Slider(mapCtrl,sliderImgPath){if(sliderImgPath==undefined){sliderImgPath="";}else{sliderImgPath+="/";}this.WideImage=sliderImgPath+_WideImage;this.ZoomImage=sliderImgPath+_ZoomImage;this.WideImage_dis=sliderImgPath+_WideImage_dis;this.ZoomImage_dis=sliderImgPath+_ZoomImage_dis;this.BlowImages=new Array();for(var i=0;i<5;++i){this.BlowImages.push(sliderImgPath+_BlowImage+_BlowImgNumber[i]+".gif");}this.BlowImages_dis=new Array();for(var i=0;i<5;++i){this.BlowImages_dis.push(sliderImgPath+_BlowDisImage+_BlowImgNumber[i]+".gif");}this.SlideBgImages=new Array();for(var i=0;i<10;++i){this.SlideBgImages.push(sliderImgPath+_SlideBgImage+i+".gif");}this.SlideBgImages_dis=new Array();for(var i=0;i<10;++i){this.SlideBgImages_dis.push(sliderImgPath+_SlideBgDisImage+i+".gif");}  this.GripImage=sliderImgPath+_GripImage;this.gripMouseDown=false; this.gripMouseDownY=0; this.gripPosY=0; this.gripDragged=false; this.gripdiv=null; this.blowdiv=null;this.blowimgs_normal=new Array();this.blowimgs_disable=new Array();this.timerid=null;this.slider_backbone_normal=new Array();this.slider_backbone_disable=new Array();this.wideImg_normal=null;this.wideImg_disable=null;this.zoomImg_normal=null;this.zoomImg_disable=null;this.mapCtrl=mapCtrl;this.elem=document.createElement("div");this.mapCtrl.getContainer().appendChild(this.elem);this.sliderdiv=this.createSlider(this.elem);AlpsEvent.bindEvent(this.mapCtrl,"layerChanged",this,this.layerChanged);AlpsEvent.bindEvent(this.mapCtrl,"smoothLayerChanging",this,this.smoothLayerChanging);AlpsEvent.bindEvent(this.mapCtrl,"layerListChanged",this,this.layerListChanged);this.layerChanged();};Slider.prototype.createSlider=function(elem){var sliderdiv=elem;sliderdiv.style.margin=_margin+"px";sliderdiv.style.position="absolute";var blowdiv=document.createElement("div");sliderdiv.appendChild(blowdiv);blowdiv.style.position="absolute";blowdiv.style.borderColor="orange";blowdiv.style.borderStyle="none";blowdiv.style.borderWidth="1px";blowdiv.style.cursor="pointer";blowdiv.style.visibility="hidden";var scope=this;AlpsEvent.addBuiltInEvent(sliderdiv,"mouseover",function(e){scope.onBlowMouse("mouseover");});AlpsEvent.addBuiltInEvent(sliderdiv,"mouseout",function(e){scope.onBlowMouse("mouseout");});this.blowdiv=blowdiv;for(var i=0;i<5;++i){var dis_blowimg=document.createElement("img");dis_blowimg.src=this.BlowImages_dis[i];blowdiv.appendChild(dis_blowimg);dis_blowimg.style.position="absolute";dis_blowimg.style.border="none";dis_blowimg.style.left=_blowLeft+"px";dis_blowimg.style.top=(_blowTop+_blowSlit*i+_blowH*i)+"px";dis_blowimg.style.cursor="pointer";setImageStyle(dis_blowimg);dis_blowimg.setAttribute("layer",i);AlpsEvent.addBuiltInEvent(dis_blowimg,"click",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_blowimg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_blowimg,"dblclick",function(e){CancelBubble(e);return false;});this.blowimgs_disable.push(dis_blowimg);}for(var i=0;i<5;++i){var blowimg=document.createElement("img");blowimg.src=this.BlowImages[i];blowdiv.appendChild(blowimg);blowimg.style.position="absolute";blowimg.style.border="none";blowimg.style.left=_blowLeft+"px";blowimg.style.top=(_blowTop+_blowSlit*i+_blowH*i)+"px";blowimg.style.cursor="pointer";setImageStyle(blowimg);blowimg.setAttribute("layer",i);AlpsEvent.bindBuiltInEvent(blowimg,"click",this,this.onBlowClick);AlpsEvent.addBuiltInEvent(blowimg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(blowimg,"dblclick",function(e){CancelBubble(e);return false;});this.blowimgs_normal.push(blowimg);}var bardiv=document.createElement("div");sliderdiv.appendChild(bardiv);bardiv.style.position="absolute";bardiv.style.borderColor="orange";bardiv.style.borderStyle="none";bardiv.style.borderWidth="1px";bardiv.style.cursor="pointer";var dis_wideImg=document.createElement("img");bardiv.appendChild(dis_wideImg);dis_wideImg.src=this.WideImage_dis;dis_wideImg.title=_WideTooltip;setImageStyle(dis_wideImg);dis_wideImg.style.position="absolute";AlpsEvent.addBuiltInEvent(dis_wideImg,"click",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_wideImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_wideImg,"dblclick",function(e){CancelBubble(e);return false;});this.wideImg_disable=dis_wideImg;for(var i=0;i<10;++i){var midImg=document.createElement("img");bardiv.appendChild(midImg);midImg.src=this.SlideBgImages_dis[i];midImg.setAttribute("layer",i);setImageStyle(midImg);midImg.style.position="absolute";midImg.style.top=(_SlideMagnBtnH+_SlideBgImageH*(9-i))+"px";AlpsEvent.addBuiltInEvent(midImg,"click",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(midImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(midImg,"dblclick",function(e){CancelBubble(e);return false;});this.slider_backbone_disable.push(midImg);}var dis_zoomImg=document.createElement("img");bardiv.appendChild(dis_zoomImg);dis_zoomImg.src=this.ZoomImage_dis;dis_zoomImg.title=_ZoomTooltip;setImageStyle(dis_zoomImg);dis_zoomImg.style.position="absolute";dis_zoomImg.style.top=(_SlideMagnBtnH+_SlideBgImageH*10)+"px";AlpsEvent.addBuiltInEvent(dis_zoomImg,"click",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_zoomImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(dis_zoomImg,"dblclick",function(e){CancelBubble(e);return false;});this.zoomImg_disable=dis_zoomImg;var wideImg=document.createElement("img");bardiv.appendChild(wideImg);wideImg.src=this.WideImage;wideImg.title=_WideTooltip;setImageStyle(wideImg);wideImg.style.position="absolute";AlpsEvent.bindBuiltInEvent(wideImg,"click",this,this.onWideClick);AlpsEvent.addBuiltInEvent(wideImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(wideImg,"dblclick",function(e){CancelBubble(e);return false;});this.wideImg_normal=wideImg;for(var i=0;i<10;++i){var midImg=document.createElement("img");bardiv.appendChild(midImg);midImg.src=this.SlideBgImages[i];midImg.setAttribute("layer",i);setImageStyle(midImg);midImg.style.position="absolute";midImg.style.top=(_SlideMagnBtnH+_SlideBgImageH*(9-i))+"px";AlpsEvent.bindBuiltInEvent(midImg,"click",this,this.onBgClick);AlpsEvent.addBuiltInEvent(midImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(midImg,"dblclick",function(e){CancelBubble(e);return false;});this.slider_backbone_normal.push(midImg);}var zoomImg=document.createElement("img");bardiv.appendChild(zoomImg);zoomImg.src=this.ZoomImage;zoomImg.title=_ZoomTooltip;setImageStyle(zoomImg);zoomImg.style.position="absolute";zoomImg.style.top=(_SlideMagnBtnH+_SlideBgImageH*10)+"px";AlpsEvent.bindBuiltInEvent(zoomImg,"click",this,this.onZoomClick);AlpsEvent.addBuiltInEvent(zoomImg,"mousedown",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(zoomImg,"dblclick",function(e){CancelBubble(e);return false;});this.zoomImg_normal=zoomImg;this.gripdiv=document.createElement("div");sliderdiv.appendChild(this.gripdiv);this.gripdiv.style.position="absolute";this.gripdiv.style.border="none";this.gripdiv.style.left=_gripLeft+"px";this.gripdiv.style.cursor="pointer";this.gripdiv.style.zIndex=3;var gripImg=document.createElement("img");this.gripdiv.appendChild(gripImg);gripImg.src=this.GripImage;setImageStyle(gripImg);var eventSrc=this.gripdiv.setCapture?this.gripdiv:window; AlpsEvent.bindBuiltInEvent(this.gripdiv,"mousedown",this,this.onGripMouseDown);AlpsEvent.bindBuiltInEvent(eventSrc,"mousemove",this,this.onGripMouseMove);AlpsEvent.bindBuiltInEvent(eventSrc,"mouseup",this,this.onGripMouseUp);AlpsEvent.addBuiltInEvent(this.gripdiv,"dblclick",function(e){CancelBubble(e);return false;});AlpsEvent.addBuiltInEvent(this.gripdiv,"click",function(e){CancelBubble(e);return false;});if(_bi.type==2){AlpsEvent.bindBuiltInEvent(window,"mouseout",this,this.onWindowMouseOut);}return sliderdiv;};Slider.prototype.onBlowMouse=function(op){if(this.timerid){window.clearTimeout(this.timerid);this.timerid=null;}this.timerid=_setTimeout(this,this.blowMouseTimeoutFn,100,op);};Slider.prototype.blowMouseTimeoutFn=function(op){if(op=="mouseover"){if(this.blowdiv.style.visibility=="hidden")this.blowdiv.style.visibility="visible";}else if(op=="mouseout"){if(this.blowdiv.style.visibility=="visible")this.blowdiv.style.visibility="hidden";}};function setImageStyle(img){if(_bi.type==1){img.unselectable="on";img.onselectstart=Nothing;img.galleryImg="no";}else{img.style.MozUserSelect="none";}img.oncontextmenu=Nothing;};Slider.prototype.onWideClick=function(e){if(!this.mapCtrl)return;var layerid=parseInt(this.mapCtrl.getCurrentLayerId());this.setLayer(layerid+1);CancelBubble(e);return false;};Slider.prototype.onZoomClick=function(e){if(!this.mapCtrl)return;var layerid=parseInt(this.mapCtrl.getCurrentLayerId());this.setLayer(layerid-1);CancelBubble(e);return false;};Slider.prototype.onBgClick=function(e){e=(e?e:window.event);var target=e.srcElement||e.target;this.setLayer(parseInt(target.getAttribute("layer")));CancelBubble(e);return false;};Slider.prototype.onBlowClick=function(e){e=(e?e:window.event);var target=e.srcElement||e.target;this.setLayer(9-2*parseInt(target.getAttribute("layer")));CancelBubble(e);return false;};Slider.prototype.setLayer=function(layerid){if(!this.mapCtrl)return;if(layerid>=0&&layerid<=9){this.layerto(this.checkScaleID(layerid));}};Slider.prototype.checkScaleID=function(layerid){if(!this.mapCtrl)return;var s=this.mapCtrl.getLayerScaleList();var found=false;if(layerid>=0){var scale=this.mapCtrl.getLayerScale(layerid);var nearestScale=0;for(var i=0;i<s.length;++i){if(nearestScale==0){nearestScale=s[i];}else{if(Math.abs(scale-nearestScale)>Math.abs(scale-s[i])){nearestScale=s[i];}}if(s[i]==scale){found=true;break;}}}return found?layerid:this.mapCtrl.getLayerId(nearestScale);};Slider.prototype.layerto=function(layerid){this.mapCtrl.smoothLayerTo(layerid);};Slider.prototype.setGripPos=function(layerid){if(!this.gripdiv)return;this.gripdiv.style.top=this.getYByLayerId(layerid)+"px";};Slider.prototype.getYByLayerId=function(layerid){return 15+(9-layerid)*9; };Slider.prototype.getLayerIdByY=function(gripY){return Math.round(this.getLayerIdByY2(gripY));};Slider.prototype.getLayerIdByY2=function(gripY){return (15-gripY)/9+9;};Slider.prototype.onGripMouseDown=function(e){if(!this.gripMouseDown){this.gripDragged=false;this.gripMouseDownY=e.screenY;this.gripPosY=parseInt(this.gripdiv.style.top);if(this.gripdiv.setCapture){this.gripdiv.setCapture()}this.gripMouseDown=true;CancelBubble(e);}return false;};Slider.prototype.onGripMouseMove=function(e){if(this.gripMouseDown){var gripYDiff=e.screenY-this.gripMouseDownY;var gripY=this.gripPosY+gripYDiff;if(gripY<15)gripY=15+_margin; if(gripY>15+9*9)gripY=15+9*9; this.gripdiv.style.top=gripY+"px";this.gripDragged=true;var magnify=this.getMagnifyBySliderPos(this.gripPosY,gripY);var fromUI=false;var bGetNewImage=false;this.mapCtrl.magnifyTo(magnify,fromUI,bGetNewImage);CancelBubble(e);}return false;};Slider.prototype.getMagnifyBySliderPos=function(fromPos,toPos){var fromLayerId=this.getLayerIdByY(fromPos);var toLayerId=this.getLayerIdByY2(toPos);var diff=toLayerId-Math.floor(toLayerId);toLayerId=Math.floor(toLayerId);var toScale=0;if(toLayerId>=9){toScale=_layerScales[toLayerId];}else{toScale=_layerScales[toLayerId]*(1-diff)+_layerScales[toLayerId+1]*diff;}var magnify=_layerScales[fromLayerId]/toScale;return magnify;};Slider.prototype.onGripMouseUp=function(e){if(document.releaseCapture){document.releaseCapture();}if(this.gripMouseDown){if(this.gripDragged){var gripY=parseInt(this.gripdiv.style.top);var layerid=this.getLayerIdByY(gripY);var newid=this.checkScaleID(layerid);if(newid!=this.mapCtrl.getCurrentLayerId()){this.setLayer(newid);}else{this.mapCtrl.magnifyTo(1);this.setGripPos(this.mapCtrl.getCurrentLayerId());}}this.gripMouseDown=false;CancelBubble(e);}return false;};Slider.prototype.onWindowMouseOut=function(e){if(!e.relatedTarget&&this.gripMouseDown){this.onGripMouseUp(e);}return false;};Slider.prototype.checkSliderBackboneEnable=function(){var s=this.mapCtrl.getLayerScaleList(); for(var i=0;i<10;++i){var found=false;for(var j=0;j<s.length;++j){var id=this.mapCtrl.getLayerId(s[j]);if(id==i){found=true;break;}}if(found){this.slider_backbone_normal[i].style.visibility="visible";this.slider_backbone_disable[i].style.visibility="hidden";}else{this.slider_backbone_normal[i].style.visibility="hidden";this.slider_backbone_disable[i].style.visibility="visible";}}};Slider.prototype.checkBlowEnable=function(){var s=this.mapCtrl.getLayerScaleList(); for(var i=0;i<5;++i){var layerid=9-2*i;var found=false;for(var j=0;j<s.length;++j){var id=this.mapCtrl.getLayerId(s[j]);if(id==layerid){found=true;break;}}if(found){this.blowimgs_normal[i].style.left=_blowLeft+"px";this.blowimgs_disable[i].style.left="-100px";}else{this.blowimgs_normal[i].style.left="-100px";this.blowimgs_disable[i].style.left=_blowLeft+"px";}}};Slider.prototype.checkMagnifyButtonEnable=function(){var s=this.mapCtrl.getLayerScaleList(); var curscale=this.mapCtrl.getCurrentScale(); s.sort(function(a,b){return (a<b)?-1:((a>b)?1:0);});for(var i=0;i<s.length;++i){if(s[i]==curscale){if(i==0){this.zoomImg_normal.style.visibility="hidden";}else{this.zoomImg_normal.style.visibility="visible";}if(i==s.length-2){ this.wideImg_normal.style.visibility="hidden";}else{this.wideImg_normal.style.visibility="visible";}break;}}};Slider.prototype.smoothLayerChanging=function(fromId,toId){this.setGripPos(toId);};Slider.prototype.layerChanged=function(){if(!this.gripMouseDown){var layerid=this.mapCtrl.getCurrentLayerId();this.setGripPos(layerid);}this.checkMagnifyButtonEnable();};Slider.prototype.layerListChanged=function(packageId){if(this.mapCtrl.getCurrentPackageId()!=packageId){return;}this.checkSliderBackboneEnable();this.checkBlowEnable();this.checkMagnifyButtonEnable();};Slider.prototype.getContainer=function(){return this.elem;};
function Mapsvr(){};Mapsvr.POI=1;Mapsvr.LINE=2;Mapsvr.AREA=3;Mapsvr.CIRCLE=4;function MapsvrPOI(id,name,pos,cat,popup,property){this.type=Mapsvr.POI;this.id=id;this.name=name;this.pos=pos;this.cat=cat;this.popup=popup;this.status=0;this.property=property || new Object();};MapsvrPOI.prototype.release=function(){_objrelease(this.property,true);_objrelease(this);};function MapsvrLine(id,name,pos,cat){this.type=Mapsvr.LINE;this.id=id;this.name=name;this.pos=pos;this.cat=cat;this.status=0;this.points=new Array();};MapsvrLine.prototype.release=function(){_objrelease(this);};function MapsvrArea(id,name,pos,cat){this.type=Mapsvr.AREA;this.id=id;this.name=name;this.pos=pos;this.cat=cat;this.status=0;this.points=new Array();};MapsvrArea.prototype.release=function(){_objrelease(this);};function MapsvrCircle(id,name,pos,radius,cat){this.type=Mapsvr.CIRCLE;this.id=id;this.name=name;this.pos=pos;this.radius=radius;this.cat=cat;this.status=0;};MapsvrCircle.prototype.release=function(){_objrelease(this);};function MapsvrCategory(id,name,image,size){this.id=id;this.name=name;this.iconImage=image?[image]:new Array();this.iconSize=size?[size]:new Array();this.iconDiff=new Array();this.expandImage=new Array();this.expandSize=new Array();this.expandDiff=new Array();this.style=new Array();this.auto=true;};MapsvrCategory.prototype.release=function(){_objrelease(this);};function MapsvrCtrl(map,param,type){this.map=map;this.loadParam(param,type);this.contents=new Array();this.source=new Array();this.icon=new Array();this.opacity=100;this.itimer=new Array();this.ptimer=null;this.ctimer=null;this.category=new Array();this.expand=true;this.popup=true;this.fixPopup=false;this.popupIndex=-1;this.searchOptimize=true;this.draggable=false;this.dragIndex=-1;this.dragPos=null;this.threshold=null;this.canvas=null;this.canvasPos=null;this.graphics=null;this.graphicsPos=null;this.queryParameter=new Array();this.resultProperty=new Object();this.width=map.getContainer().offsetWidth;this.height=map.getContainer().offsetHeight;AlpsEvent.addEvent(map,"mapMoving",_func(this,"mapMoving"));AlpsEvent.addEvent(map,"mapMoved",_func(this,"mapMoved"));AlpsEvent.addEvent(map,"layerChanged",_func(this,"layerChanged"));AlpsEvent.addEvent(map,"smoothLayerChanging",_func(this,"smoothLayerChanging"));AlpsEvent.addEvent(map,"magnifyChanged",_func(this,"magnifyChanged"));AlpsEvent.addEvent(map,"angleChanged",_func(this,"angleChanged"));AlpsEvent.addEvent(map,"smoothAngleChanging",_func(this,"smoothAngleChanging"));AlpsEvent.addEvent(map,"packageChanged",_func(this,"packageChanged"));AlpsEvent.addEvent(map,"resize",_func(this,"onResize"));AlpsEvent.addEvent(map,"mouseMove",_func(this,"onMouseMove"));};MapsvrCtrl.prototype.release=function(){if(_bi.type!=1) return;_objrelease(this.categoryMap,true);_objrelease(this);};MapsvrCtrl.prototype.loadParam=function(param,type){if(typeof(param)!="string") return this.loadParamObject(param);this.contentsServer=null;this.drawServer=null;this.categoryList=new Array();this.categoryMap=new Object();var doc=null;if(type=="string"){doc=AlpsUtil.getXMLDOMFromStr(param);}else{doc=AlpsUtil.getXMLDOM(param);}if(!doc) return;var n=doc.getElementsByTagName("poi")[0];if(n){this.contentsServer=n.getAttribute("server");var popup=n.getElementsByTagName("popup")[0];if(popup){this.popupServer=popup.getAttribute("server");this.popupTemp=AlpsUtil.getNodeContent(popup);}var nl0=n.getElementsByTagName("category");for(var i=0;i<nl0.length;i++){var n0=nl0[i];var c=new MapsvrCategory(n0.getAttribute("id"),n0.getAttribute("name"));if(n0.getAttribute("auto")=="no") c.auto=false;var nl1=n0.childNodes;for(var j=0;j<nl1.length;j++){var n1=nl1[j];if(n1.nodeType!=1) continue;if(n1.nodeName=="icon"){var s=parseInt(n1.getAttribute("status")||"0");c.iconImage[s]=n1.getAttribute("src");var w=parseInt(n1.getAttribute("width")||n1.getAttribute("size")||0);var h=parseInt(n1.getAttribute("height")||n1.getAttribute("size")||0);c.iconSize[s]={width:w, height:h};var dx=parseInt(n1.getAttribute("dx")||"0");var dy=parseInt(n1.getAttribute("dy")||"0");c.iconDiff[s]=new Point(dx,dy);}else if(n1.nodeName=="expand"){var s=parseInt(n1.getAttribute("status")||"0");c.expandImage[s]=n1.getAttribute("src");var w=parseInt(n1.getAttribute("width")||n1.getAttribute("size")||0);var h=parseInt(n1.getAttribute("height")||n1.getAttribute("size")||0);if(w&&h) c.expandSize[s]={width:w, height:h};var dx=parseInt(n1.getAttribute("dx")||"0");var dy=parseInt(n1.getAttribute("dy")||"0");c.expandDiff[s]=new Point(dx,dy);}}this.addCategory(c);}}var n=doc.getElementsByTagName("shape")[0];if(n){this.drawServer=n.getAttribute("server");var nl0=n.getElementsByTagName("category");for(var i=0;i<nl0.length;i++){var n0=nl0[i];var c=new MapsvrCategory(n0.getAttribute("id"),n0.getAttribute("name"));var nl1=n0.childNodes;for(var j=0;j<nl1.length;j++){var n1=nl1[j];if(n1.nodeType!=1) continue;if(n1.nodeName=="line"){var s=parseInt(n1.getAttribute("status")||"0");var style=n1.getAttribute("style");c.style[s]=style?("line:"+style):"line";}else if(n1.nodeName=="area"){var s=parseInt(n1.getAttribute("status")||"0");var style=n1.getAttribute("style");c.style[s]=style?("area:"+style):"area";}else if(n1.nodeName=="circle"){var s=parseInt(n1.getAttribute("status")||"0");var style=n1.getAttribute("style");c.style[s]=style?("circle:"+style):"circle";}}this.addCategory(c);}}};MapsvrCtrl.prototype.getImageSize=function(img,size){if(!size.width) size.width=img.width;if(!size.height) size.height=img.height;};MapsvrCtrl.prototype.loadParamObject=function(param){this.contentsServer=param.contentsServer;this.drawServer=null;this.categoryList=new Array();this.categoryMap=new Object();for(var i=0;i<param.catList.length;i++){var c=param.catList[i];this.addCategory(new MapsvrCategory(c,param.catName[c],param.iconImage[c],param.iconSize[c]));}};MapsvrCtrl.prototype.showCategories=function(cat){this.category=cat || new Array();this.findContents();};MapsvrCtrl.prototype.showAllCategories=function(){this.category=new Array();for(var i=0;i<this.categoryList.length;i++){this.category.push(this.categoryList[i]);}this.findContents();};MapsvrCtrl.prototype.addCategory=function(c){for(var i=0;c.iconImage[i];i++){if(!c.iconSize[i]) c.iconSize[i]={width:0, height:0};if(c.iconSize[i].width&&c.iconSize[i].height) continue;var img=new Image();img.onload=_func(this,"getImageSize",img,c.iconSize[i]);img.src=c.iconImage[i];}var index=this.categoryList._indexOf(c.id);if(index>=0){this.categoryList.splice(index,1);}this.categoryList.push(c.id);this.categoryMap[c.id]=c;};MapsvrCtrl.prototype.removeCategory=function(id){var index=this.categoryList._indexOf(id);if(index>=0){this.categoryList.splice(index,1);}if(this.categoryMap[id]){delete this.categoryMap[id];}};MapsvrCtrl.prototype.getCategoryList=function(){var a=new Array();for(var i=0;i<this.categoryList.length;i++){var c=this.categoryList[i];a.push(this.categoryMap[c]);}return a;};MapsvrCtrl.prototype.getCategory=function(id){return this.categoryMap[id];};MapsvrCtrl.prototype.getPOIList=function(){var a=new Array();for(var i=0;i<this.contents.length;i++){if(this.contents[i].type==Mapsvr.POI){a.push(this.contents[i]);}}if(this.map){var c=this.map.getCenterLatLon();a.sort(function(x,y){return x.pos.distance(c)-y.pos.distance(c)});}return a;};MapsvrCtrl.prototype.getContentsList=function(){var a=new Array();for(var i=0;i<this.source.length;i++){a.push(this.source[i]);}return a;};MapsvrCtrl.prototype.getContents=function(id){var i=this.getContentsIndex(id,this.source);if(i>=0) return this.source[i];i=this.getContentsIndex(id);if(i>=0) return this.contents[i];};MapsvrCtrl.prototype.addContents=function(contents,addonly){var deleted=false;for(var i=0;i<this.source.length;i++){if(this.source[i].id==contents.id){_objrelease(this.source[i]);this.source.splice(i,1);i--;deleted=true;}}this.pointsConvert(contents);this.source.push(contents);if(this.searchOptimize){this.source.sort(function(a,b){return (a.id<b.id)?-1:((a.id>b.id)?1:0)});}if(addonly) return;if(deleted||this.contentsServer||contents.type!=Mapsvr.POI){  this.findContents();}else{if(this.overThreshold()) return;if(this.category._indexOf(contents.cat)<0) return;this.contents.push(contents);if(this.searchOptimize){this.contents.sort(function(a,b){return (a.id<b.id)?-1:((a.id>b.id)?1:0)});}this.initCanvas();var index=this.getContentsIndex(contents.id);if(index>=0){this.createIcon(index);AlpsEvent.triggerEvent(this,"POIListChanged");}}};MapsvrCtrl.prototype.removeContents=function(id,removeonly){for(var i=0;i<this.source.length;i++){if(this.source[i].id==id){_objrelease(this.source[i]);this.source.splice(i,1);i--;}}if(removeonly) return;this.findContents();};MapsvrCtrl.prototype.clearContents=function(){for(var i=0;i<this.source.length;i++){_objrelease(this.source[i]);}this.source._clear();this.findContents();};MapsvrCtrl.prototype.addQueryParameter=function(name,value,type){this.removeQueryParameter(name);this.queryParameter.push({name:name,value:value,type:type});};MapsvrCtrl.prototype.removeQueryParameter=function(name){for(var i=0;i<this.queryParameter.length;i++){if(this.queryParameter[i].name==name){_objrelease(this.queryParameter[i]);this.queryParameter.splice(i,1);i--;}}};MapsvrCtrl.prototype.clearQueryParameter=function(){this.queryParameter._clear();};MapsvrCtrl.prototype.getResultProperty=function(name){return this.resultProperty[name];};MapsvrCtrl.prototype.setContentsStatus=function(id,status){var i=this.getContentsIndex(id);if(i<0){i=this.getContentsIndex(id,this.source);if(i>=0) this.source[i].status=status;return;}var c=this.contents[i];c.status=status;var icon=this.icon[i];if(!icon){this.dispShape();return;}icon.src=this.categoryMap[c.cat].iconImage[c.status];var size=this.categoryMap[c.cat].iconSize[c.status]||{width:0, height:0};icon.width=size.width;icon.height=size.height;this.dispIcon(i);};MapsvrCtrl.prototype.getIconElement=function(id){var i=this.getContentsIndex(id);if(i>=0) return this.icon[i];};MapsvrCtrl.prototype.setIconOpacity=function(opacity){this.opacity=opacity;for(var i=0;i<this.contents.length;i++){this.dispIcon(i);}};MapsvrCtrl.prototype.getIconOpacity=function(){return this.opacity;};MapsvrCtrl.prototype.setEnableExpand=function(newVal){this.expand=newVal;};MapsvrCtrl.prototype.getEnableExpand=function(){return this.expand;};MapsvrCtrl.prototype.setEnablePopup=function(newVal){this.popup=newVal;};MapsvrCtrl.prototype.getEnablePopup=function(){return this.popup;};MapsvrCtrl.prototype.setIconThreshold=function(threshold){this.threshold=threshold;this.findContents();};MapsvrCtrl.prototype.getIconThreshold=function(){return this.threshold;};MapsvrCtrl.prototype.setEnableFixPopup=function(newVal){this.fixPopup=newVal};MapsvrCtrl.prototype.getEnableFixPopup=function(){return this.fixPopup;};MapsvrCtrl.prototype.setEnableSearchOptimize=function(newVal){this.searchOptimize=newVal;};MapsvrCtrl.prototype.getEnableSearchOptimize=function(){return this.searchOptimize;};MapsvrCtrl.prototype.setEnableDraggableMode=function(newVal){this.draggable=newVal;};MapsvrCtrl.prototype.getEnableDraggableMode=function(){return this.draggable;};MapsvrCtrl.prototype.openPopup=function(id){var index=this.getContentsIndex(id);if(index>=0) this.showPopup(index);};MapsvrCtrl.prototype.closePopup=function(param){var e=this.hidePopup();this.popupIndex=-1;if(e) AlpsEvent.triggerEvent(this,"closePopup",param);};MapsvrCtrl.prototype.getContentsIndex=function(id,src){if(!src) src=this.contents;if(this.searchOptimize){var start=0,end=src.length;while(start<end){var h=Math.floor((start+end)/2);var hid=src[h].id;if(id==hid) return h;if(id<hid){end=h;}else if(start==h){start=h+1;}else{start=h;}}}else{for(var i=0;i<src.length;i++){if(src[i].id==id){return i;}}}return -1;};MapsvrCtrl.prototype.overThreshold=function(){if(!this.map) return;if(!this.threshold) return;return this.map.getCurrentScale()>this.threshold;};MapsvrCtrl.prototype.releaseContents=function(){for(var i=0;i<this.contents.length;i++){if(this.contents[i].type==Mapsvr.POI&&this.contents[i].property['iconid']){_objrelease(this.contents[i]);}}this.contents._clear();};MapsvrCtrl.prototype.findContents=function(){if(this.draggable){this.dragIndex=-1;this.dragPos=null;}var num=this.contents.length;this.releaseContents();this.resultProperty=new Object();if (!this.category.length||this.overThreshold()){this.pourContents();this.showContents();if(num) AlpsEvent.triggerEvent(this,"POIListChanged");return;}if (!this.contentsServer){this.pourContents();this.showContents();if(this.contents.length) AlpsEvent.triggerEvent(this,"POIListChanged");return;}if (!this.map) return;var pos=new Array();pos.push(this.map.log2LatLon(new Point(0,0)));pos.push(this.map.log2LatLon(new Point(this.width,0)));pos.push(this.map.log2LatLon(new Point(this.width,this.height)));pos.push(this.map.log2LatLon(new Point(0,this.height)));var bl=pos[3],tr=pos[1];for(var i=0;i<pos.length;i++){if(pos[i].lat<bl.lat) bl.lat=pos[i].lat;if(pos[i].lon<bl.lon) bl.lon=pos[i].lon;if(pos[i].lat>tr.lat) tr.lat=pos[i].lat;if(pos[i].lon>tr.lon) tr.lon=pos[i].lon;}var ms=this;var xmlhttp=AlpsUtil.getXMLHttp();if (!xmlhttp) return;xmlhttp.open("POST", this.contentsServer, true);xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {ms.releaseContents();ms.resultProperty=new Object();if(ms.overThreshold()) return;var ver=parseFloat(xmlhttp.responseXML.documentElement.getAttribute("version")||"1.0");if(ver<2.0){var pois=xmlhttp.responseXML.getElementsByTagName("poi");for(var i=0;i<pois.length;i++){var prop=AlpsUtil.getProperties(pois[i]);prop['identifier_uri']=AlpsUtil.getElementAttribute(pois[i],"identifier","uri");var id=prop["iconid"];var name=AlpsUtil.getElementAttribute(pois[i],"title","name");var cat=AlpsUtil.getElementAttribute(pois[i],"category","xml:id");if(!cat) cat=AlpsUtil.getElementAttribute(pois[i],"category","id");if(!cat) cat=AlpsUtil.getElementAttribute(pois[i],"category","type");var place=pois[i].getElementsByTagName("place")[0];var pos=AlpsUtil.getElementAttribute(place,"variation","placeID");var popup=AlpsUtil.getElementContent(pois[i],"popup");ms.contents.push(new MapsvrPOI(id,name,new LLPoint(pos),cat,popup,prop));}}else{var pois=xmlhttp.responseXML.getElementsByTagName("poiarray");for(var i=0;i<pois.length;i++){var prop=AlpsUtil.getProperties(pois[i]);var pos=prop['DMS'];var cat=AlpsUtil.getElementAttribute(pois[i],"category","xml:id");if(!cat) cat=AlpsUtil.getElementAttribute(pois[i],"category","id");var poi=pois[i].getElementsByTagName("poi");var ids=new Array();var titles=new Array();for(var j=0;j<poi.length;j++){var id=poi[j].getAttribute("xml:id");if(!id) id=poi[j].getAttribute("id");if(id) ids.push(id);var title=AlpsUtil.getElementAttribute(poi[j],"title","name");if(title) titles.push(title);}var poi=new MapsvrPOI(ids.join(","),titles.join(","),new LLPoint(pos),cat,null,prop);ms.contents.push(poi);}}var props=xmlhttp.responseXML.getElementsByTagName("properties")[0];if(props) ms.resultProperty=AlpsUtil.getProperties(props);ms.pourContents();ms.showContents();AlpsEvent.triggerEvent(ms,"POIListChanged");}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var bottomleft=doc.createElement("bottomleft");query.appendChild(bottomleft);bottomleft.appendChild(doc.createTextNode(bl));var topright=doc.createElement("topright");query.appendChild(topright);topright.appendChild(doc.createTextNode(tr));for(var i=0;i<this.category.length;i++){var c=this.categoryMap[this.category[i]];if(c&&c.style[0]) continue;if(c&&!c.auto) continue;var category=doc.createElement("category");category.appendChild(doc.createTextNode(this.category[i]));query.appendChild(category);}for(var i=0;i<this.queryParameter.length;i++){var p=this.queryParameter[i];var e=doc.createElement("parameter");query.appendChild(e);e.setAttribute("name",p.name);if(p.type=="text"){e.appendChild(doc.createTextNode(p.value));}else if(p.type=="cdata"){e.appendChild(doc.createCDATASection(p.value));}else{e.setAttribute("value",p.value);}}if(!doc.getElementsByTagName("category").length){this.pourContents();this.showContents();AlpsEvent.triggerEvent(this,"POIListChanged");return;}xmlhttp.setRequestHeader("Content-Type","text/xml");xmlhttp.send(doc)};MapsvrCtrl.prototype.pourContents=function(){if(this.category.length){for(var i=0;i<this.source.length;i++){if(this.source[i].type==Mapsvr.POI&&this.overThreshold()) continue;if(this.category._indexOf(this.source[i].cat)>=0){this.contents.push(this.source[i]);}}}if(this.searchOptimize){this.contents.sort(function(a,b){return (a.id<b.id)?-1:((a.id>b.id)?1:0)});}};MapsvrCtrl.prototype.showContents=function(){for(var i=0;i<this.icon.length;i++){window.clearTimeout(this.itimer[i]);}this.itimer._clear();this.icon._clear();this.closePopup(true);if(!this.contents.length) return this.removeCanvas();this.clearCanvas();var shapeCount=0;for(var i=0;i<this.contents.length;i++){var cnt=this.contents[i];if(cnt.type!=Mapsvr.POI){shapeCount++;continue;}this.createIcon(i);}if(shapeCount){this.dispShape();}else if(this.graphics){this.graphics.innerHTML="";this.graphics.style.filter="";this.graphics.style.backgroundImage="";}};MapsvrCtrl.prototype.createIcon=function(index){var cnt=this.contents[index];if(cnt.type!=Mapsvr.POI) return;if(!this.categoryMap[cnt.cat]) return;var icon=ImageMaker.createImg(this.categoryMap[cnt.cat].iconImage[cnt.status]);icon.onmouseover=_func(this,"expandIcon",index);icon.onmouseout=_func(this,"deflateIcon",index);icon.onclick=_func(this,"triggerEvent","click",cnt.id);icon.onmousedown=_func(this,"triggerEvent","mouseDown",cnt.id);icon.onmouseup=_func(this,"triggerEvent","mouseUp",cnt.id);icon.ondblclick=_func(this,"triggerEvent","dblclick",cnt.id);var size=this.categoryMap[cnt.cat].iconSize[cnt.status]||{width:0, height:0};icon.width=size.width;icon.height=size.height;icon.style.position="absolute";icon.style.display='none';icon.style.zIndex=0;var order=this.resultProperty["order"];if(order=="reverse"){this.canvas.insertBefore(icon,this.canvas.firstChild);}else if(order=="random"){var nl=this.canvas.childNodes;var idx=Math.floor(Math.random()*nl.length);this.canvas.insertBefore(icon,nl[idx]);}else{this.canvas.appendChild(icon);}this.icon[index]=icon;this.dispIcon(index);};MapsvrCtrl.prototype.triggerEvent=function(type,id,e){if(!this.contents.length) return;if(this.draggable){if(type=="mouseDown"){this.dragIndex=this.getContentsIndex(id);this.dragPos=getRelativePos(e||window.event,this.canvas);this.closePopup();}else if(type=="mouseUp"){var index=this.getContentsIndex(id);if(index==this.dragIndex){this.dragIndex=-1;this.dragPos=null;AlpsEvent.triggerEvent(this,"iconMoved",id);}}}AlpsEvent.triggerEvent(this,type,id);CancelBubble(e);};MapsvrCtrl.prototype.dispShape=function(){if(!this.graphics) return;var ag=null;if(typeof(AlpsGraphics)!="undefined"){var g=this.createCanvas();this.map.getContainer().insertBefore(g,this.graphics);ag=new AlpsGraphics(g);if(!ag.type){this.map.getContainer().removeChild(g);ag=null;}else{this.map.getContainer().removeChild(this.graphics);this.graphics=g;}}if(ag){ag.clear();var lineWidth=2;for(var i=0;i<this.contents.length;i++){var cnt=this.contents[i];if(cnt.type==Mapsvr.POI) continue;if(!this.categoryMap[cnt.cat]) continue;var style=this.categoryMap[cnt.cat].style[cnt.status];if(!style) continue;ag.setStrokeColor(0,0,255);ag.setStrokeOpacity(1.0);ag.setFillOpacity(0);var s=style.split(":");for(var j=0;j<s.length;j++){if(!s[j].length) continue;switch(j){case 1:ag.setStrokeColor(s[j]);break;case 2:ag.setStrokeOpacity(parseFloat(s[j]));break;case 3:lineWidth=parseFloat(s[j]);break;case 4:ag.setFillColor(s[j]);ag.setFillOpacity(1.0);break;case 5:ag.setFillOpacity(parseFloat(s[j]));break;}}if(cnt.type==Mapsvr.CIRCLE){var p=this.map.latLon2Log(cnt.pos);var r=(cnt.radius>0)?(cnt.radius*10000/this.map.getCurrentScale()):(-cnt.radius);if(!this.isValidCircle(p,r)) continue;ag.drawCircle(p,r,lineWidth);}else if(cnt.type==Mapsvr.AREA){var ss=new Array();var org=this.map.latLon2Log(this.map.getProjOrigin());for(var j=0;j<cnt.points.length;j++){ss.push(new Point(org.x+cnt.points[j].x,org.y+cnt.points[j].y));}if(!this.isValidArea(ss)) continue;ag.drawArea(ss,lineWidth);}else if(cnt.type==Mapsvr.LINE){var ss=new Array();var org=this.map.latLon2Log(this.map.getProjOrigin());for(var j=0;j<cnt.points.length;j++){ss.push(new Point(org.x+cnt.points[j].x,org.y+cnt.points[j].y));}if(!this.isValidArea(ss)) continue;ag.drawLine(ss,lineWidth);}}this.graphicsPos=this.map.log2LatLon(new Point(0,0));this.moveContents();}else if(this.drawServer){var bl=this.map.log2LatLon(new Point(0,this.height));var tr=this.map.log2LatLon(new Point(this.width,0));var url=this.drawServer+"?w="+this.width+"&h="+this.height+"&p="+this.makePath();var gp=this.map.log2LatLon(new Point(0,0));if(_bi.type==1){this.graphics.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"')";this.graphicsPos=gp;this.moveContents();}else{var ms=this;var timer=null;var func=function(){if(timer) window.clearTimeout(timer);if(ms.graphics){ms.graphics.style.backgroundImage="url("+url+")";ms.graphics.style.backgroundPosition="0px 0px";ms.graphics.style.backgroundRepeat="no-repeat";ms.graphicsPos=gp;}ms.moveContents();};var img=new Image();img.onload=func;timer=window.setTimeout(func,2000);img.src=url;}}else{this.graphics.innerHTML="";this.graphics.style.filter="";this.graphics.style.backgroundImage="";}};MapsvrCtrl.prototype.makePath=function(){var ret=new Array();var points=0;var pstyle=null;for(var i=0;i<this.contents.length;i++){var cnt=this.contents[i];if(cnt.type==Mapsvr.POI) continue;if(!this.categoryMap[cnt.cat]) continue;var style=this.categoryMap[cnt.cat].style[cnt.status];if(!style) continue;if(cnt.type==Mapsvr.CIRCLE){var p=this.map.latLon2Log(cnt.pos);var r=(cnt.radius>0)?(cnt.radius*10000/this.map.getCurrentScale()):(-cnt.radius);if(!this.isValidCircle(p,r)) continue;if(style!=pstyle){ret.push("s"+style);pstyle=style;}var b=this.makeDword(Math.floor(p.x))+this.makeDword(Math.floor(p.y))+this.makeDword(Math.floor(r));ret.push("c"+b);}else if(cnt.type==Mapsvr.AREA){var ss=new Array();var org=this.map.latLon2Log(this.map.getProjOrigin());for(var j=0;j<cnt.points.length;j++){ss.push(new Point(org.x+cnt.points[j].x,org.y+cnt.points[j].y));}if(!this.isValidArea(ss)) continue;var s="";for(var j=0;j<ss.length;j++){if(j>0&&this.isSamePixel(ss[j-1],ss[j])) continue;s+=this.makeDword(Math.floor(ss[j].x))+this.makeDword(Math.floor(ss[j].y));}var num=s.length/8;if(num<2) continue;if(style!=pstyle){ret.push("s"+style);pstyle=style;}points+=num;ret.push("a"+s);}else if(cnt.type==Mapsvr.LINE){var s="";var ss=new Array();var pp=null;var pb=null;var org=this.map.latLon2Log(this.map.getProjOrigin());for(var j=0;j<cnt.points.length;j++){var p=new Point(org.x+cnt.points[j].x,org.y+cnt.points[j].y);var b=this.makeDword(Math.floor(p.x))+this.makeDword(Math.floor(p.y));if(pp&&!this.isSamePixel(pp,p)){if(this.isValidLine(pp,p)){if(pb){s+=pb;pb=null;}s+=b;}else{if(s){ss.push(s);s="";}pb=b;}}else{pb=b;}pp=p;}if(s){ss.push(s);s="";}if(ss.length){if(style!=pstyle){ret.push("s"+style);pstyle=style;}for(var j=0;j<ss.length;j++){var num=ss[j].length/8;if(num<2) continue;points+=num;ret.push("l"+ss[j]);}}}}var reduce=null;if(points>600){reduce=0;var c=Math.ceil(points/600.0);for(var i=0;i<ret.length;i++){if(ret[i].charAt(0)=="l"||ret[i].charAt(0)=="a"){var num=(ret[i].length-1)/8;var s=ret[i].charAt(0);for(var j=0;j<num;j++){if(j==0||j==num-1||j%c==0){s+=ret[i].substr(1+j*8,8);reduce++;}}ret[i]=s;}}}var s="";for(var i=0;i<ret.length;i++){if(s) s+=",";if(ret[i].charAt(0)=="s"){s+=":"+ret[i].substring(1);}else if(ret[i].charAt(0)=="l"){s+=this.fake64encode(this.byterleComp(this.rearrange(ret[i].substring(1))));}else if(ret[i].charAt(0)=="a"){s+=this.fake64encode(this.byterleComp(this.rearrange(ret[i].substring(1))));}else if(ret[i].charAt(0)=="c"){s+=this.fake64encode(ret[i].substring(1));}}return s;};MapsvrCtrl.prototype.isSamePixel=function(p1,p2){return Math.floor(p1.x)==Math.floor(p2.x)&&Math.floor(p1.y)==Math.floor(p2.y);};MapsvrCtrl.prototype.isValidLine=function(p1,p2){var margin=20;var mleft=-margin;var mright=this.width+margin;var mtop=-margin;var mbottom=this.height+margin;var left=Math.min(p1.x,p2.x);var right=Math.max(p1.x,p2.x);var top=Math.min(p1.y,p2.y);var bottom=Math.max(p1.y,p2.y);return (left<=mright)&&(top<=mbottom)&&(right>=mleft)&&(bottom>=mtop);};MapsvrCtrl.prototype.isValidArea=function(points){if(!points.length) return false;var margin=20;var mleft=-margin;var mright=this.width+margin;var mtop=-margin;var mbottom=this.height+margin;var left=null;var right=null;var top=null;var bottom=null;for(var i=0;i<points.length;i++){var p=points[i];if(left==null||p.x<left) left=p.x;if(right==null||p.x>right) right=p.x;if(top==null||p.y<top) top=p.y;if(bottom==null||p.y>bottom) bottom=p.y;}return (left<=mright)&&(top<=mbottom)&&(right>=mleft)&&(bottom>=mtop);};MapsvrCtrl.prototype.isValidCircle=function(p,r){if(!r) return false;var margin=20;var mleft=-margin;var mright=this.width+margin;var mtop=-margin;var mbottom=this.height+margin;var left=p.x-r;var right=p.x+r;var top=p.y-r;var bottom=p.y+r;return (left<=mright)&&(top<=mbottom)&&(right>=mleft)&&(bottom>=mtop);};MapsvrCtrl.prototype.makeDword=function(val){var ret="";for(var i=0;i<4;i++){var c=(val>>((3-i)*8))&0xff;if(val<0&&i==0) c=c|0x80;ret+=String.fromCharCode(c);}return ret;};MapsvrCtrl.prototype.pointsConvert=function(c){if(!c){for(var i=0;i<this.source.length;i++){this.pointsConvert(this.source[i]);}}else if(c.type==Mapsvr.LINE||c.type==Mapsvr.AREA){var org=this.map.latLon2Log(this.map.getProjOrigin());c.points._clear();for(var i=0;i<c.pos.length;i++){var p=this.map.latLon2Log(c.pos[i]);c.points.push(new Point(p.x-org.x,p.y-org.y));}}};MapsvrCtrl.prototype.dispIcon=function(index){if(!this.map)return;var c=this.contents[index];if(!c) return;if(c.type!=Mapsvr.POI) return;var p=this.map.latLon2Log(c.pos);var icon=this.icon[index];if(_bi.type==1){icon.style.filter='alpha(opacity='+this.opacity+')';}else{icon.style.opacity=this.opacity/100.0;icon.style.MozOpacity=this.opacity/100.0;}if(p.x>0&&p.x<this.width&&p.y>0&&p.y<this.height){icon.style.display='block';}else{icon.style.display='none';}var d=this.categoryMap[c.cat].iconDiff[c.status]||new Point(0,0);var cp=this.canvasPos?this.map.latLon2Log(this.canvasPos):new Point(0,0);var size=this.categoryMap[c.cat].iconSize[c.status]||{width:0, height:0};if(this.expand&&this.categoryMap[c.cat].expandSize[c.status]){var fx=size.width?icon.width/size.width:1;var fy=size.height?icon.width/size.height:1;icon.style.left=Math.floor(p.x-cp.x-icon.width/2+d.x*fx)+"px";icon.style.top=Math.floor(p.y-cp.y-icon.height/2+d.y*fy)+"px";}else{icon.style.left=Math.floor(p.x-cp.x-size.width/2+d.x)+"px";icon.style.top=Math.floor(p.y-cp.y-size.height/2+d.y)+"px";}};MapsvrCtrl.prototype.moveContents=function(){if(this.graphics&&this.graphicsPos){var p=this.map.latLon2Log(this.graphicsPos);this.graphics.style.width=this.width+"px";this.graphics.style.height=this.height+"px";this.graphics.style.left=Math.floor(p.x)+"px";this.graphics.style.top=Math.floor(p.y)+"px";}if(this.canvas&&this.canvasPos){var p=this.map.latLon2Log(this.canvasPos);this.canvas.style.left=Math.floor(p.x)+"px";this.canvas.style.top=Math.floor(p.y)+"px";}};MapsvrCtrl.prototype.resizeCanvas=function(){if(this.canvas){this.canvas.style.width=this.width+"px";this.canvas.style.height=this.height+"px";this.canvas.style.left="0px";this.canvas.style.top="0px";this.canvasPos=this.map.log2LatLon(new Point(0,0));}};MapsvrCtrl.prototype.createCanvas=function(){var e=document.createElement("div");e.style.position="absolute";e.style.display="block";e.style.width=this.width+"px";e.style.height=this.height+"px";e.style.left="0px";e.style.top="0px";e.oncontextmenu=Nothing;return e;};MapsvrCtrl.prototype.initCanvas=function(){if(!this.graphics){this.graphics=this.createCanvas();this.map.getContainer().appendChild(this.graphics);}if(!this.canvas){this.canvas=this.createCanvas();this.map.getContainer().appendChild(this.canvas);}this.resizeCanvas();};MapsvrCtrl.prototype.clearCanvas=function(){this.initCanvas();this.canvas.innerHTML="";};MapsvrCtrl.prototype.removeCanvas=function(){if(this.graphics){this.map.getContainer().removeChild(this.graphics);this.graphics=null;}if(this.canvas){this.map.getContainer().removeChild(this.canvas);this.canvas=null;}};MapsvrCtrl.prototype.onClick=function(index){var ms=this;return function(e){if(!ms.contents.length) return;AlpsEvent.triggerEvent(ms,"click",ms.contents[index].id);CancelBubble(e);};};MapsvrCtrl.prototype.expandIcon=function(index){if(!this.contents.length) return;this.icon[index].style.zIndex=1;if(this.expand){window.clearTimeout(this.itimer[index]);this.itimer[index]=window.setTimeout(_func(this,"gidle",index,true),20);if(!this.fixPopup) this.closePopup();}else if(this.popup){this.showPopup(index);}AlpsEvent.triggerEvent(this,"mouseOver",this.contents[index].id);};MapsvrCtrl.prototype.deflateIcon=function(index){if(!this.contents.length) return;if(this.draggable&&this.dragIndex==index) return;this.icon[index].style.zIndex=0;if(this.expand){window.clearTimeout(this.itimer[index]);this.itimer[index]=window.setTimeout(_func(this,"gidle",index,false),20);}if(!this.fixPopup) this.ptimer=window.setTimeout(_func(this,"closePopup",false),10);AlpsEvent.triggerEvent(this,"mouseOut",this.contents[index].id);};MapsvrCtrl.prototype.gidle=function(index,xp){if(!this.contents[index]) return;var c=this.contents[index].cat;var s=this.contents[index].status;var gidle_min=this.categoryMap[c].iconSize[s]||{width:0, height:0};var gidle_max=this.categoryMap[c].expandSize[s]||gidle_min;var min_width = gidle_min.width;var min_height = gidle_min.height;var max_width = Math.max(gidle_min.width,gidle_max.width);var max_height = Math.max(gidle_min.height,gidle_max.height);var dw=Math.ceil((max_width-min_width)/8.0);var dh=Math.ceil((max_height-min_height)/8.0);var p=this.icon[index];var width=p.width+(xp?dw:-dw);var height=p.height+(xp?dh:-dh);if(xp&&width>=max_width){width=max_width;}else if(!xp&&width<=min_width){width=min_width;}if(xp&&height>=max_height){height=max_height;}else if(!xp&&height<=min_height){height=min_height;}var icon_min=this.categoryMap[c].iconImage[s];var icon_max=this.categoryMap[c].expandImage[s]||icon_min;var diff_min=this.categoryMap[c].iconDiff[s]||new Point(0,0);var diff_max=this.categoryMap[c].expandDiff[s]||new Point(0,0);var d=new Point(0,0);var fw=1,fh=1;if(width<(max_width+min_width)/2.0){p.src=icon_min;d=diff_min;fw=width/min_width;}else if(width==(max_width+min_width)/2.0){if(xp){p.src=icon_max;d=diff_max;fw=width/max_width;}else{p.src=icon_min;d=diff_min;fw=width/min_width;}}else{p.src=icon_max;d=diff_max;fw=width/max_width;}if(height<(max_height+min_height)/2.0){p.src=icon_min;d=diff_min;fh=height/min_height;}else if(height==(max_height+min_height)/2.0){if(xp){p.src=icon_max;d=diff_max;fh=height/max_height;}else{p.src=icon_min;d=diff_min;fh=height/min_height;}}else{p.src=icon_max;d=diff_max;fh=height/max_height;}if(p.width!=width||p.height!=height){p.width=width;p.height=height;var center=this.map.latLon2Log(this.contents[index].pos);var cp=this.canvasPos?this.map.latLon2Log(this.canvasPos):new Point(0,0);p.style.left=Math.floor(center.x-cp.x-p.width/2+d.x*fw)+"px";p.style.top=Math.floor(center.y-cp.y-p.height/2+d.y*fh)+"px";}if((xp&&width<max_width)||(!xp&&width>min_width)||(xp&&height<max_height)||(!xp&&height>min_height)){this.itimer[index]=window.setTimeout(_func(this,"gidle",index,xp),20);}else if(xp&&this.popup){this.showPopup(index);}};MapsvrCtrl.prototype.hidePopup=function(){window.clearTimeout(this.ptimer);var a=["popup","popup_topleft","popup_topright","popup_bottomleft","popup_bottomright"];var e=false;for(var i=0;i<a.length;i++){var p=document.getElementById(a[i]);if(p){if(p.style.display!='none'){p.style.display='none';e=true;}}}return e;};MapsvrCtrl.prototype.showPopup=function(index){if(!this.map) return;if(this.draggable&&this.dragIndex==index) return;var e=true;if(index<0){e=false;index=this.popupIndex;if(index<0) return;}else if(this.popupIndex>=0){this.closePopup();}this.popupIndex=index;var c=this.contents[index];if(!c.popup){if(!this.popupServer) return;if(this.getContentsIndex(c.id,this.source)>=0) return;}var i=this.icon[index];if(i.style.display=="none") return;window.clearTimeout(this.ptimer);var center=this.map.latLon2Log(c.pos);var type="";if(center.y<this.height/3){if(center.x<this.width/2){type="bottomright";}else{type="bottomleft";}}else{if(center.x<this.width/2){type="topright";}else{type="topleft";}}var p=document.getElementById("popup_"+type);if(!p) p=document.getElementById("popup");if(!p){p=document.createElement("div");p.id="popup";p.style.display="none";p.style.backgroundColor="#eef";p.style.color="#000";p.style.borderStyle="solid";p.style.borderColor="#000";p.style.borderWidth="1px 2px 2px 1px";p.style.fontSize="11px";p.style.padding="1px 2px";p.innerHTML='<span id="popup_message"></span>';document.body.appendChild(p);}p.style.position="absolute";p.style.zIndex=1;var ms=this;var pm=document.getElementById(p.id+"_message");if(pm){if(c.popup){pm.innerHTML=c.popup;}else if(this.popupServer){var xmlhttp=AlpsUtil.getXMLHttp();if(xmlhttp){xmlhttp.open("POST",this.popupServer,true);xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {c.popup=xmlhttp.responseText;if(c.popup) ms.showPopup(ms.popupIndex);}};var doc=AlpsUtil.createXMLDOM();var query=doc.createElement("query");doc.appendChild(query);var ids=c.id.split(/,/);for(var j=0;j<ids.length;j++){var id=doc.createElement("id");query.appendChild(id);id.appendChild(doc.createTextNode(ids[j]));}xmlhttp.setRequestHeader("Content-Type","text/xml");xmlhttp.send(doc);if(this.popupTemp){pm.innerHTML=this.popupTemp;}else{return;}}}}var pc=document.getElementById(p.id+"_close");if(pc){pc.onclick=function(){ms.closePopup();};}p.onmouseover=function(){window.clearTimeout(ms.ptimer);};p.onmouseout=function(){window.clearTimeout(ms.ptimer);if(!ms.fixPopup) ms.ptimer=window.setTimeout(_func(ms,"closePopup",false),10);};var pos=(p.getAttribute("pos")||"right:top").split(":");var dx=parseInt(p.getAttribute("dx")||"0");var dy=parseInt(p.getAttribute("dy")||"0");var op=getObjPos3(i);if(p.parentNode==this.map.getContainer()){p.style.zIndex=2;var func=function(e){if(!e) e=window.event;e.cancelBubble=true;};p.onmousedown=func;p.onmouseup=func;p.onclick=func;op=getObjPos(i,this.map.getContainer());}p.style.visibility='hidden';p.style.left=p.style.right=p.style.top=p.style.bottom="";p.style.display='block';var pw=p.offsetWidth;var ph=p.offsetHeight;if(pos[0]=="top"){p.style.top=Math.floor(op.y-ph+dy)+"px";}else if(pos[0]=="bottom"){p.style.top=Math.floor(op.y+i.height+dy)+"px";}else if(pos[0]=="left"){p.style.left=Math.floor(op.x-pw+dx)+"px";}else if(pos[0]=="right"){p.style.left=Math.floor(op.x+i.width+dx)+"px";}if(pos[1]=="top"){p.style.top=Math.floor(op.y+dy)+"px";}else if(pos[1]=="bottom"){p.style.top=Math.floor(op.y+i.height-ph+dy)+"px";}else if(pos[1]=="left"){p.style.left=Math.floor(op.x+dx)+"px";}else if(pos[1]=="right"){p.style.left=Math.floor(op.x+i.width-pw+dx)+"px";}else if(pos[1]=="ctop"){p.style.top=Math.floor(op.y+i.height/2+dy)+"px";}else if(pos[1]=="cbottom"){p.style.top=Math.floor(op.y+i.height/2-ph+dy)+"px";}else if(pos[1]=="cleft"){p.style.left=Math.floor(op.x+i.width/2+dx)+"px";}else if(pos[1]=="cright"){p.style.left=Math.floor(op.x+i.width/2-pw+dx)+"px";}p.style.visibility='visible';if(e) AlpsEvent.triggerEvent(this,"openPopup",c.id);};MapsvrCtrl.prototype.fake64encode=function(str){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@/";var len=str.length;var ret="";    for(var i=0;i<len;) {var c1 = str.charCodeAt(i++) & 0xff;if(i == len){     ret += b64.charAt(c1 >> 2);     ret += b64.charAt((c1 & 0x3) << 4);     break;}var c2 = str.charCodeAt(i++);if(i == len){     ret += b64.charAt(c1 >> 2);     ret += b64.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));     ret += b64.charAt((c2 & 0xF) << 2);     break;}var c3 = str.charCodeAt(i++);ret += b64.charAt(c1 >> 2);ret += b64.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));ret += b64.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));ret += b64.charAt(c3 & 0x3F);    }return ret;};MapsvrCtrl.prototype.rearrange=function(str){var ret="";for(var i=0;i<4;i++){for(var j=0;j<2;j++){for(var k=0;k<str.length/8;k++){ret+=str.charAt(k*8+j*4+i);}}}return ret;};MapsvrCtrl.prototype.byterleComp=function(str){var Raw_Rle_Sep=192;var Equal_Data_Max=(Raw_Rle_Sep+3);var Raw_Data_Max=(256 - Raw_Rle_Sep);switch(str.length){case 0:return "";case 1:return String.fromCharCode(1+Raw_Rle_Sep)+str;}var ret="";var inend=str.length;var raw_data="";for(var inbuff=0;inbuff<inend;){var max_cnt = inend - inbuff;if(max_cnt > Equal_Data_Max) max_cnt=Equal_Data_Max;var cnt=0;for(var i=1;i<max_cnt;i++){if(str.charCodeAt(inbuff)==str.charCodeAt(inbuff+i)){cnt=i+1;}else{break;}}if(cnt<3){raw_data+=str.charAt(inbuff++);if(raw_data.length>=(Raw_Data_Max-1)){ret+=String.fromCharCode(raw_data.length+Raw_Rle_Sep)+raw_data;raw_data="";}}else{if(raw_data){ret+=String.fromCharCode(raw_data.length+Raw_Rle_Sep)+raw_data;raw_data="";}ret+=String.fromCharCode(cnt-3)+str.charAt(inbuff);inbuff+=cnt;}}if(raw_data){ret+=String.fromCharCode(raw_data.length+Raw_Rle_Sep)+raw_data;}return ret;};MapsvrCtrl.prototype.mapMoving=function(){if(this.ctimer) window.clearTimeout(this.ctimer);this.hidePopup();this.moveContents();this.showPopup(-1);};MapsvrCtrl.prototype.mapMoved=function(){if(this.ctimer) window.clearTimeout(this.ctimer);if(_delaytime>0){this.ctimer=window.setTimeout(_func(this,"findContents"),_delaytime);}else{this.findContents();}};MapsvrCtrl.prototype.layerChanged=function(){this.pointsConvert();if(this.ctimer) window.clearTimeout(this.ctimer);if(_delaytime>0){this.ctimer=window.setTimeout(_func(this,"findContents"),_delaytime);}else{this.findContents();}};MapsvrCtrl.prototype.smoothLayerChanging=function(){if(this.ctimer) window.clearTimeout(this.ctimer);if(this.contents.length){this.contents._clear();this.showContents();}};MapsvrCtrl.prototype.magnifyChanged=function(){this.pointsConvert();if(this.ctimer) window.clearTimeout(this.ctimer);if(_delaytime>0){this.ctimer=window.setTimeout(_func(this,"findContents"),_delaytime);}else{this.findContents();}};MapsvrCtrl.prototype.angleChanged=function(){this.pointsConvert();if(this.ctimer) window.clearTimeout(this.ctimer);if(_delaytime>0){this.ctimer=window.setTimeout(_func(this,"findContents"),_delaytime);}else{this.findContents();}};MapsvrCtrl.prototype.smoothAngleChanging=function(){if(this.ctimer) window.clearTimeout(this.ctimer);if(this.contents.length){this.contents._clear();this.showContents();}};MapsvrCtrl.prototype.packageChanged=function(){this.pointsConvert();};MapsvrCtrl.prototype.onResize=function(){this.width=this.map.getContainer().offsetWidth;this.height=this.map.getContainer().offsetHeight;if(this.canvas){this.moveContents();this.resizeCanvas();for(var i=0;i<this.contents.length;i++){if(this.contents[i].type==Mapsvr.POI){this.dispIcon(i);}}}this.findContents();};MapsvrCtrl.prototype.onMouseMove=function(p){if(!this.draggable||this.dragIndex<0||!this.dragPos) return;var pos=this.map.latLon2Log(p);var c=this.contents[this.dragIndex];if(!c) return;var p=this.map.latLon2Log(c.pos);p.x+=pos.x-this.dragPos.x;p.y+=pos.y-this.dragPos.y;var llp=this.map.log2LatLon(p);c.pos=llp;var index=this.getContentsIndex(c.id,this.source);if(index>=0){this.source[index].pos=llp;}this.dragPos=pos;this.dispIcon(this.dragIndex);AlpsEvent.triggerEvent(this,"iconMoving",c.id);};function getObjPos3(obj){var p=new Point(0,0);if(obj.parentNode === null || obj.style.display == 'none'){return p;}var parent = null;            if(obj.getBoundingClientRect){  var box = obj.getBoundingClientRect();var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);return new Point(box.left + scrollLeft, box.top + scrollTop);}else if(document.getBoxObjectFor){  var box = document.getBoxObjectFor(obj);p = new Point(box.x, box.y);}else{  p = new Point(obj.offsetLeft, obj.offsetTop);parent = obj.offsetParent;if(parent != obj){while(parent){p.x += parent.offsetLeft;p.y += parent.offsetTop;parent = parent.offsetParent;}}}            if(obj.parentNode){parent = obj.parentNode;}else{parent = null;}while(parent && parent.tagName != 'BODY' && parent.tagName != 'HTML'){  p.x -= parent.scrollLeft;p.y -= parent.scrollTop;      if(parent.parentNode){parent = parent.parentNode;}else{parent = null;}}return p;};function _func(obj,name){var args0=new Array();for(var i=2;i<arguments.length;i++){args0.push(arguments[i]);}return function(){var args=new Array();for(var i=0;i<args0.length;i++){args.push(args0[i]);}for(var i=0;i<arguments.length;i++){args.push(arguments[i]);}obj[name].apply(obj,args);};};
/* 2007.04.16 */
