﻿var Utilities={isDefined:function(uq){return typeof uq!="undefined";},ifDefined:function(aw,kK){return Utilities.isDefined(aw)?aw:kK;},hasValue:function(aw){return Utilities.isDefined(aw)&&aw!=null&&(typeof aw=="string"?aw!="":true);},ifHasValue:function(aw,kK){return Utilities.hasValue(aw)?aw:kK;}};var $defined=Utilities.isDefined;var $ifDefined=Utilities.ifDefined;var $hasValue=Utilities.hasValue;var $ifHasValue=Utilities.ifHasValue;Utilities.Window=Object.extend(Utilities,{getSize:function(){var lp,lu;if(window.innerWidth){lp=window.innerWidth;lu=window.innerHeight;}else{lp=document.compatMode=='CSS1Compat'?document.documentElement.clientWidth:document.body.clientWidth;lu=document.compatMode=='CSS1Compat'?document.documentElement.clientHeight:document.body.clientHeight;}return{width:lp,height:lu}},addFavorite:function(aS,aM){if(window.sidebar){window.sidebar.addPanel(aS,aM,"");}else if(window.external){try{window.external.AddFavorite(aM,aS);}catch(e){}}},getBaseUrl:function(){var aM=window.location.href;var ar=window.location.href.indexOf("?");if(ar!= -1){aM=window.location.href.substring(0,ar);}ar=aM.indexOf("#");if(ar!= -1){aM=aM.substring(0,ar);}return aM;},getSiteUrl:function(){var aM=window.location.href;var ar=window.location.href.indexOf("/",8);if(ar!= -1){aM=window.location.href.substring(0,ar);}else{ar=aM.indexOf("?");if(ar!= -1){aM=aM.substring(0,ar);}}return aM;},navigateTo:function(sP){var aM=Utilities.Window.getSiteUrl()+sP;if(window.parent!=null){window.parent.location.href=aM;}else{window.location.href=aM;}}});Utilities.Page=Object.extend(Utilities,{rn:false,lX:[],wh:function(ej){if(!Utilities.Page.rn){Utilities.Page.lX.push(ej);}else{ej();}},uV:function(){Utilities.Page.rn=true;try{Utilities.Page.lX.each(function(ej){ej();});}finally{Utilities.Page.lX.clear();}},setCookie:function(rW,jb,iJ){var tF=new Date();var kO=new Date();if(!$defined(iJ)||iJ==null||iJ==0)iJ=1;kO.setTime(tF.getTime()+3600000*24*iJ);document.cookie=rW+"="+encodeURI(jb)+";expires="+kO.toGMTString()+";path=/Map/Page/";document.cookie=rW+"="+encodeURI(jb)+";expires="+kO.toGMTString()+";path=/Map/Service/";}});var $attemptInvoke=Utilities.Page.wh;var $invokePending=Utilities.Page.uV;Utilities.DOM=Object.extend(Utilities,{create:function(wV,bz,eJ,aB){return $(document.createElement(wV)).$add(eJ).$text(bz).$addTo(aB);},vT:function(av,bM,aw){if(bM=="style"){try{var cj=aw.split(";").compact();var jV=cj.inject({},function(rQ,tp){var je=tp.split(':');rQ[je[0]]=je[1];return rQ;});Element.setStyle(av,jV);}catch(e){alert("Exception adding attribute style: "+e.message);}}else if(bM=="class"){av.className=aw;}else{av.setAttribute(bM,aw);}return av;},vV:function(av,bM,aw,wQ){return wQ?av.$attr(bM,aw):av;},wg:function(av){av.appendChild($dom.apply(this,$A(arguments).slice(1)));return av;},vx:function(av,bz){if(typeof bz!="undefined"&&bz!=null){bz=bz.gsub("&nbsp;","\u00a0");bz=bz.gsub("&aelig;","\u00E6");bz=bz.gsub("&oslash;","\u00F8");bz=bz.gsub("&aring;","\u00E5");bz=bz.gsub("&AElig","\u00C6");bz=bz.gsub("&Oslash;","\u00D8");bz=bz.gsub("&Aring;","\u00C5");var eP=document.createTextNode(bz);av.appendChild(eP);}return av;},vz:function(av,aB){if(typeof aB!="undefined"&&aB!=null){aB.appendChild(av);}return av;},vU:function(av,eJ){if(typeof eJ!="undefined"&&eJ!=null){try{if(typeof eJ.length!="undefined"){var i,ao=eJ.length;for(var i=0;i<ao;i++){av.appendChild(eJ[i]);}}else{av.appendChild(eJ);}}catch(e){throw{message:"Invalid child node "+eJ[i]+". "+e.message};}}return av;}});Element.addMethods({$attr:Utilities.DOM.vT,$condAttr:Utilities.DOM.vV,$dom:Utilities.DOM.wg,$text:Utilities.DOM.vx,$addTo:Utilities.DOM.vz,$add:Utilities.DOM.vU});var $dom=Utilities.DOM.create;Utilities.Event=Object.extend(Utilities,{Button:{LEFT:1,RIGHT:2,MIDDLE:3},whichButton:function(bi){var fp;if(bi.which==null){fp=(bi.button<2)?Utilities.Event.Button.LEFT:((bi.button==4)?Utilities.Event.Button.MIDDLE:Utilities.Event.Button.RIGHT);}else{fp=(bi.which<2)?Utilities.Event.Button.LEFT:((bi.which==2)?Utilities.Event.Button.MIDDLE:Utilities.Event.Button.RIGHT);}return fp;}});Utilities.Trans=Object.extend(Utilities,{UTMToLatLon:function(){if(arguments.length==1){return Utilities.Trans.mN(arguments[0]);}else if(typeof arguments[0]=="number"){var bE={x:arguments[1],y:arguments[0]};return Utilities.Trans.mN(bE);}else{var bE={x:Number(arguments[1]),y:Number(arguments[0])};return Utilities.Trans.mN(bE);}},mN:function(oE){var gQ=3.14159265;var kj=gQ/180;var ka=180.0/gQ;var hD=0.9996;var hz=6378137;var bc=0.00669438;var es;var dp=(1-Math.sqrt(1-bc))/(1+Math.sqrt(1-bc));var lV,eS,ed,sz,bZ,iO;var iQ;var jj,sS,du;var x,y;var hb=33;var ot;x=oE.x-500000.0;y=oE.y;if(hb>=0){ot=1;}else{ot=0;y-=10000000.0;}iQ=(hb-1)*6-180+3;es=(bc)/(1-bc);iO=y/hD;jj=iO/(hz*(1-bc/4-3*bc*bc/64-5*bc*bc*bc/256));du=jj+(3*dp/2-27*dp*dp*dp/32)*Math.sin(2*jj)+(21*dp*dp/16-55*dp*dp*dp*dp/32)*Math.sin(4*jj)+(151*dp*dp*dp/96)*Math.sin(6*jj);sS=du*ka;lV=hz/Math.sqrt(1-bc*Math.sin(du)*Math.sin(du));eS=Math.tan(du)*Math.tan(du);ed=es*Math.cos(du)*Math.cos(du);sz=hz*(1-bc)/Math.pow(1-bc*Math.sin(du)*Math.sin(du),1.5);bZ=x/(lV*hD);Lat=du-(lV*Math.tan(du)/sz)*(bZ*bZ/2-(5+3*eS+10*ed-4*ed*ed-9*es)*bZ*bZ*bZ*bZ/24+(61+90*eS+298*ed+45*eS*eS-252*es-3*ed*ed)*bZ*bZ*bZ*bZ*bZ*bZ/720);Lat=Lat*ka;Long=(bZ-(1+2*eS+ed)*bZ*bZ*bZ/6+(5-2*ed+28*eS-3*ed*ed+8*es+24*eS*eS)*bZ*bZ*bZ*bZ*bZ/120)/Math.cos(du);Long=iQ+Long*ka;return({'x':Long,'y':Lat,'lon':Long,'lat':Lat});},decimalDegreesToUTM:function(rV){var or=parseFloat(rV.x);var xQ=parseFloat(rV.y);var gQ=3.14159265;var yB=gQ/4;var kj=gQ/180;var ka=180.0/gQ;var hz=6378137;var bc=0.00669438;var hD=0.9996;var iQ;var es;var nF;var eV;var gl;var bV;var iO;var nT=(or+180)-parseInt((or+180)/360)*360-180;var dJ=xQ*kj;var xF=nT*kj;var nU;var hb;hb=parseInt((nT+180)/6)+1;hb=33;iQ=(hb-1)*6-180+3;nU=iQ*kj;es=(bc)/(1-bc);nF=hz/Math.sqrt(1-bc*Math.sin(dJ)*Math.sin(dJ));eV=Math.tan(dJ)*Math.tan(dJ);gl=es*Math.cos(dJ)*Math.cos(dJ);bV=Math.cos(dJ)*(xF-nU);iO=hz*((1-bc/4-3*bc*bc/64-5*bc*bc*bc/256)*dJ-(3*bc/8+3*bc*bc/32+45*bc*bc*bc/1024)*Math.sin(2*dJ)+(15*bc*bc/256+45*bc*bc*bc/1024)*Math.sin(4*dJ)-(35*bc*bc*bc/3072)*Math.sin(6*dJ));var sX=(hD*nF*(bV+(1-eV+gl)*bV*bV*bV/6+(5-18*eV+eV*eV+72*gl-58*es)*bV*bV*bV*bV*bV/120)+500000.0);var ub=(hD*(iO+nF*Math.tan(dJ)*(bV*bV/2+(5-eV+9*gl+4*gl*gl)*bV*bV*bV*bV/24+(61-58*eV+eV*eV+600*gl-330*es)*bV*bV*bV*bV*bV*bV/720)));return{'x':sX,'y':ub};},deg2LLstring:function(ddeg){var kN=ddeg-Math.floor(ddeg);return Math.floor(ddeg)+"&ordm; "+Math.floor(kN*60)+"' "+(60*(60*kN-Math.floor(60*kN))).toFixed(3)+"\'\'";}});Utilities.Karto=Object.extend(Utilities,{getDistance:function(aE){for(var i=0;i<aE.length;i++){aE[i]=aE[i].transform('EPSG:32633');}var ho=0.0;for(var i=0;i<aE.length-1;i++){var eL=aE[i];var eZ=aE[i+1];var distance=Math.sqrt((eZ.x-eL.x)*(eZ.x-eL.x)+(eL.y-eZ.y)*(eL.y-eZ.y));ho+=distance;}return ho;},pointDistance:function(aX,aY,bX,bY){var d1=aX-bX;var d2=aY-bY;return Math.sqrt(d1*d1+d2*d2);},getArea:function(aE){for(var i=0;i<aE.length;i++){aE[i]=aE[i].transform('EPSG:32633');}var t=0.0;if(aE.length>2){var numPoints=aE.length;t=(aE[aE.length-1].x*aE[0].y)-(aE[0].x*aE[aE.length-1].y);for(var i=0;i<numPoints-1;i++){t=t+(aE[i].x*aE[i+1].y)-(aE[i+1].x*aE[i].y);}t=t/2;}if(t<0){t= -t;}return t;},getPerimeter:function(aE){for(var i=0;i<aE.length;i++){aE[i]=aE[i].transform('EPSG:32633');}var ho=0.0;if(aE.length>2){for(var i=0;i<aE.length-1;i++){var eL=aE[i];var eZ=aE[i+1];var cA=Math.sqrt((eZ.x-eL.x)*(eZ.x-eL.x)+(eL.y-eZ.y)*(eL.y-eZ.y));ho+=cA;}}if(aE.length>2){var cA=Math.sqrt((aE[aE.length-1].x-aE[0].x)*(aE[aE.length-1].x-aE[0].x)+(aE[0].y-aE[aE.length-1].y)*(aE[0].y-aE[aE.length-1].y));ho+=cA;}return ho;}});String.prototype.trim=new Function("return this.replace(/^\\s+|\\s+$/g,'')");Array.prototype.sum=function(){for(var i=0,sum=0;i<this.length;sum+=this[i++]);return sum;};Array.prototype.swap=function(a,b){var tmp=this[a];this[a]=this[b];this[b]=tmp;}