﻿var swm;var map=null;var pan=null;var ge=null;function SWM(){this.k=null;this.af=15;this.I=200;this.I=200;this.bh=null;this.B=eid("mapDiv");this.C=eid("panDiv");this.H=eid("bingDiv");this.F=eid("osmDiv");this.G=eid("yahooDiv");this.P=eid("aboutDiv");this.bf=eid("mapOptions");this.aR=eid("earthOptions");this.as=new GStreetviewClient();this.bn=null;this.U=null;this.ab=false;this.D=1;this.f=new SWMconfig();};SWM.prototype.t=function(J){this.B.style.top=(J==this.B)?"30px":"-1000000px";this.C.style.top=(J==this.C)?"30px":"-1000000px";this.H.style.top=(J==this.H)?"30px":"-1000000px";this.F.style.top=(J==this.F)?"30px":"-1000000px";this.G.style.top=(J==this.G)?"30px":"-1000000px";this.P.style.top=(J==this.P)?"30px":"-1000000px";this.bf.style.display=(swm.D<5&&this.f.O)?"block":"none";this.aR.style.display=(swm.D==5)?"block":"none";};function loadPage(){swm=new SWM();swm.aS();};function loadPage2(){swm.bk();resizePage();swm.bj();mapTypeChange(swm.f.j);eid("swmList").value=swm.f.j;};function unloadPage(){GUnload();};function resizePage(){swm.aU();var wd=swm.I;var ht=swm.K-30;swm.B.style.width=wd+"px";swm.B.style.height=ht+"px";swm.C.style.width=wd+"px";swm.C.style.height=ht+"px";swm.H.style.width=wd+"px";swm.H.style.height=ht+"px";swm.F.style.width=wd+"px";swm.F.style.height=ht+"px";swm.G.style.width=wd+"px";swm.G.style.height=ht+"px";swm.P.style.width=wd+"px";swm.P.style.height=ht+"px";};SWM.prototype.aU=function(){var au=true;if(typeof(window.innerHeight)=="number"){au=false;}if(au){this.I=parseInt(document.documentElement.clientWidth);this.K=parseInt(document.documentElement.clientHeight);}else{this.I=parseInt(window.innerWidth);this.K=parseInt(window.innerHeight);}};function RefreshGPos(a){var g=a.split(" ");if(g.length>2){var x=parseFloat(g[0]);var y=parseFloat(g[1]);var z=parseInt(g[2]);var pt=new GLatLng(y,x);map.setCenter(pt,z);}};SWM.prototype.bc=function(){var wd=this.I;var ht=this.K-30;var v=map.getCenter();var x=v.lng();var y=v.lat();var z=map.getZoom();if(!this.H.innerHTML){var mx=this.k.lng();var my=this.k.lat();var L="bing.htm?x="+x+"&y="+y+"&z="+z+"&mx="+mx+"&my="+my;this.H.innerHTML="<iframe name='veFrame' id='veFrame' src='"+L+"' style='width:"+wd+"px;height:"+ht+"px' frameborder='0' marginwidth='0' marginheight='0' scrolling='off' ></iframe>";}else{if(window.frames.veFrame&&window.frames.veFrame.setVEpos){window.frames.veFrame.setVEpos(x,y,z);}}};function SWMconfig(){this.ak=true;this.al=true;this.R=true;this.M=true;this.O=true;this.T=true;this.Q=true;this.aa=true;this.ar=2;this.aO=0;this.ad=1;this.ac=0;this.j=1;this.ap=0;this.ao=0;this.ae=1000;this.ag=45;this.aj=5;this.aH=false;this.aF=0;this.aG=0;this.aI=0;this.aJ=0;this.am="";};SWM.prototype.o=function(q,n){var r="";if(q&&q.length>0&&n&&n.length){var p=n+"=";var b=q.indexOf(p);if(b!= -1){b+=p.length;var e=q.indexOf("&",b);if(e== -1)e=n.length;r=unescape(q.substring(b,e));}}return r;};SWM.prototype.aS=function(){var c=this.f;var l=document.location.search.substring(1)+"&";var aL=this.o(l,"x");var aN=this.o(l,"y");if(aL&&aN){var x=parseFloat(aL);var y=parseFloat(aN);this.k=new GLatLng(y,x);}else{var x= -121.8914807;var y=37.339085;this.k=new GLatLng(y,x);}var aP=this.o(l,"z");if(aP){this.af=parseInt(aP);}var at=this.o(l,"l");if(at){c.ak=false;c.al=false;c.R=false;c.M=false;c.O=false;c.T=false;c.Q=false;c.aa=false;var g=at.split(",");for(var i=0;i<g.length;i++){var bb=g[i].toLowerCase();switch(bb){case "sat":c.ak=true;break;case "hyb":c.al=true;break;case "phy":c.R=true;break;case "ge":c.M=true;break;case "sv":c.O=true;break;case "bing":c.T=true;break;case "osm":c.Q=true;break;case "yahoo":c.aa=true;break;}}}aD=this.o(l,"c");if(aD){c.ar=parseInt(aD);}aC=this.o(l,"d");if(aC){c.aO=parseInt(aC);}aB=this.o(l,"a");if(aB){c.ad=parseInt(aB);}aE=this.o(l,"s");if(aE){c.ac=parseInt(aE);}ay=this.o(l,"i");if(ay){c.j=parseInt(ay);}var ax=this.o(l,"e");if(ax){var g=ax.split(",");if(g.length>4){c.ap=parseInt(g[0]);c.ao=parseFloat(g[1]);c.ae=parseInt(g[2]);c.ag=parseInt(g[3]);c.aj=parseInt(g[4]);}}var aM=this.o(l,"v");if(aM){var g=aM.split(",");if(g.length>4){c.aH=true;c.aF=parseFloat(g[0]);c.aG=parseFloat(g[1]);c.aI=parseFloat(g[2]);c.aJ=parseFloat(g[3]);c.aQ=parseInt(g[4]);}}if(c.ac||c.ad){c.M=false;}if(c.j==4&& !c.R){c.j=1;}if(c.j==5&& !c.M){c.j=1;}if(c.j==6&& !c.O){c.j=6;}if(c.j==7&& !c.T){c.j=1;}if(c.j==8&& !c.Q){c.j=1;}if(c.j==9&& !c.aa){c.j=1;}az=this.o(l,"addr");if(az){c.am=az;}if(c.am){this.aT();}else{loadPage2();}};SWM.prototype.aT=function(){var aA=this.f.am;var ba=new GClientGeocoder(new GGeocodeCache());ba.getLatLng(aA,function(ah){if(ah){var x=ah.lng();var y=ah.lat();swm.k=new GLatLng(y,x);}else{GLog.write("address geocode error : "+aA);}loadPage2();});};function cbGE(a){ge=a;swm.bg();};function orbitReset(){eid("orbitBox").checked=0;swm.orbitRate=0;};function orbitCheck(a){orbitApply();};function orbitApply(){if(eid("orbitBox").checked){swm.orbitRate=swm.f.aj;var pt=map.getCenter();swm.orbitX=pt.lng();swm.orbitY=pt.lat();}else{swm.orbitRate=0;}};SWM.prototype.bg=function(){this.V=ge.createLookAt('');this.heading=this.f.ao;this.orbitRate=this.f.ap?this.f.aj:0;var pt=map.getCenter();this.orbitX=pt.lng();this.orbitY=pt.lat();this.aq=false;setTimeout("swm.orbitStep()",200);};SWM.prototype.orbitStep=function(){if(!this.aq){this.aq=true;this.V.set(this.orbitY,this.orbitX,0,ge.ALTITUDE_RELATIVE_TO_GROUND,this.heading,this.f.ag,this.f.ae);ge.getView().setAbstractView(this.V);if(this.orbitRate>0){eid("orbitBox").checked=true;}}if(this.orbitRate!=0&&this.D==5){this.V.set(this.orbitY,this.orbitX,0,ge.ALTITUDE_RELATIVE_TO_GROUND,this.heading,this.f.ag,this.f.ae);ge.getView().setAbstractView(this.V);this.heading+=this.orbitRate;if(this.heading>360){this.heading=0;}}setTimeout("swm.orbitStep()",200);};SWM.prototype.aK=function(){if(this.f.aO){var v=map.getCenter();var x=formatFloat(v.lng(),6);var y=formatFloat(v.lat(),6);var z=map.getZoom();var aW="lat:<b>"+y+"</b> lng:<b>"+x+"</b> zoom:<b>"+z+"</b>";eid("swmInfo").innerHTML=aW;}};SWM.prototype.bj=function(){var mapDiv=eid("mapDiv");map=new GMap2(mapDiv);map.setCenter(this.k,this.af);map.addControl(new GScaleControl());if(this.f.ac){map.enableGoogleBar();}switch(this.f.ar){case 1:map.addControl(new GSmallZoomControl3D());break;case 2:map.addControl(new GLargeMapControl3D());break;}map.enableRotation();map.enableScrollWheelZoom();GEvent.addListener(map,"moveend",function(){swm.aK();});if(this.f.ad){var aX={maxAdsOnMap:8,style:"adunit",channel:"1214357017"};var aY=new GAdsManager(map,"pub-5408854154696215",aX);aY.enable();}this.aK();this.bm();};SWM.prototype.bm=function(){var av=new GMarker(this.k);map.addOverlay(av);this.bh=av;};SWM.prototype.bl=function(){var wd=this.I;var ht=this.K-30;var v=map.getCenter();var x=v.lng();var y=v.lat();var z=map.getZoom();if(!this.F.innerHTML){var mx=this.k.lng();var my=this.k.lat();var L="osm.htm?x="+x+"&y="+y+"&z="+z+"&mx="+mx+"&my="+my;this.F.innerHTML="<iframe name='osmFrame' id='osmFrame' src='"+L+"' style='width:"+wd+"px;height:"+ht+"px' frameborder='0' marginwidth='0' marginheight='0' scrolling='off' ></iframe>";}else{if(window.frames.osmFrame&&window.frames.osmFrame.setOSMpos){window.frames.osmFrame.setOSMpos(x,y,z);}}};SWM.prototype.be=function(){if(this.f.aH){map.setCenter(this.k);this.bi();}else{var pt=map.getCenter();this.as.getNearestPanorama(pt,loadPanorama);}};SWM.prototype.bi=function(){pan=new GStreetviewPanorama(swm.C);GEvent.addListener(pan,"initialized",function(a){map.setCenter(a.latlng);});var pt=new GLatLng(this.f.aG,this.f.aF);pan.setLocationAndPOV(pt,{"yaw":this.f.aI,"pitch":this.f.aJ,"zoom":this.f.aQ});};function loadPanorama(ai){if(ai&&ai.location){if(swm.D!=6){swm.D=6;eid("swmList").value=6;swm.t(swm.C);}var aw=ai.location.latlng;aZ=swm.aV(aw,swm.k);pan=new GStreetviewPanorama(swm.C);GEvent.addListener(pan,"initialized",function(a){map.setCenter(a.latlng);});pan.setLocationAndPOV(aw,{"yaw":aZ});}else{mapTypeChange(1);eid("swmList").value=1;var an=eid("svBox");if(an){an.checked=true;streetviewLayerCheck(an);alert("Street View is not available here");}}};SWM.prototype.aV=function(p1,p2){var angle=null;if(p1!=null&&p2!=null&& !p1.equals(p2)){var y1=p1.latRadians();var x1=p1.lngRadians();var y2=p2.latRadians();var x2=p2.lngRadians();var a=Math.sin(x1-x2)*Math.cos(y2);var b=Math.cos(y1)*Math.sin(y2)-Math.sin(y1)*Math.cos(y2)*Math.cos(x1-x2);angle= -(Math.atan2(a,b));if(angle<0.0){angle+=Math.PI*2.0;}}return parseInt(angle*180.0/Math.PI);};function streetviewLayerCheck(a){if(!swm.U){swm.U=new GStreetviewOverlay();GEvent.addListener(map,"click",function(ov,pt){if(swm.ab&&pt){swm.as.getNearestPanorama(pt,loadPanorama);}});}if(a.checked){map.addOverlay(swm.U);swm.ab=true;}else{map.removeOverlay(swm.U);swm.ab=false;}};SWM.prototype.bk=function(){var A=eid("swmList");var i=0;A.options[i++]=new Option("Road Map",1);if(this.f.ak){A.options[i++]=new Option("Satellite",2);}if(this.f.al){A.options[i++]=new Option("Hybrid",3);}if(this.f.R){A.options[i++]=new Option("Physical",4);}if(this.f.M){A.options[i++]=new Option("Earth (3D)",5);}if(this.f.O){A.options[i++]=new Option("Street View",6);}if(this.f.T){A.options[i++]=new Option("Bing Map",7);}if(this.f.Q){A.options[i++]=new Option("Open Street Map",8);}if(this.f.aa){A.options[i++]=new Option("Yahoo Map",9);}A.options[i++]=new Option("About",10);};function mapTypeChange(a){swm.D=parseInt(a);orbitReset();switch(swm.D){case 1:swm.t(swm.B);map.setMapType(G_NORMAL_MAP);break;case 2:swm.t(swm.B);map.setMapType(G_SATELLITE_MAP);break;case 3:swm.t(swm.B);map.setMapType(G_HYBRID_MAP);break;case 4:swm.t(swm.B);map.setMapType(G_PHYSICAL_MAP);break;case 5:swm.t(swm.B);map.setMapType(G_SATELLITE_3D_MAP);if(!ge){map.getEarthInstance(cbGE)}break;case 6:swm.t(swm.C);swm.be();break;case 7:swm.t(swm.H);swm.bc();break;case 8:swm.t(swm.F);swm.bl();break;case 9:swm.t(swm.G);swm.bd();break;case 10:swm.t(swm.P);break;}};function mapReset(){eid("swmList").value=1;map.setCenter(swm.k,swm.af);mapTypeChange(1);};function eid(id){return document.getElementById(id);};function formatFloat(n,d){var m=Math.pow(10,d);return Math.round(n*m,10)/m;};SWM.prototype.bd=function(){var wd=this.I;var ht=this.K-30;var v=map.getCenter();var x=v.lng();var y=v.lat();var z=map.getZoom();if(!this.G.innerHTML){var mx=this.k.lng();var my=this.k.lat();var L="yahoo.htm?x="+x+"&y="+y+"&mx="+mx+"&my="+my+"&z="+z;this.G.innerHTML="<iframe name='yahooFrame' id='yahooFrame' src='"+L+"' style='width:"+wd+"px;height:"+ht+"px' frameborder='0' marginwidth='0' marginheight='0' scrolling='off' ></iframe>";}else{if(window.frames.yahooFrame&&window.frames.yahooFrame.setYahooPos){window.frames.yahooFrame.setYahooPos(x,y,z);}}}
