var imageDirsToCache=new Array("arrow","arrow200","blueCar","blueCar200","blueCarSpotty","blueCarSpotty200","yellowCar","yellowCar200","yellowCarSpotty","yellowCarSpotty200");var imageCache=new Array();var imageNameArray=new Array("car_0.png","car_22_5.png","car_45.png","car_67_5.png","car_90.png","car_112_5.png","car_135.png","car_157_5.png","car_n180.png","car_n22_5.png","car_n45.png","car_n67_5.png","car_n90.png","car_n112_5.png","car_n135.png","car_n157_5.png");var shiftDown=false;function GetTopBoundary(){var el=document.getElementById("wl_ve_headerLinks");return GetTopPosition(el)+el.offsetHeight;}function CarCompass(b,c,g){Ib("yellowCar200");Ib("yellowCarSpotty200");window.setTimeout("carcompass.PreCacheCarImagesDirectory(\"blueCar200\")",1000000);window.setTimeout("carcompass.PreCacheCarImagesDirectory(\"blueCarSpotty200\")",200000);window.setTimeout("carcompass.PreCacheCarImagesDirectory(\"arrow200\")",4000000);var carElement=document.createElement("div");var x;var y;var rotatingCar=false;var cPanning=false;var maxScrollSpeed=15;var currentDirection=90;var currentImageIndex=4;carDriveSpeed=8;var map=c;var cartype=g;var currentAngle=90;var currentQuadKey=null;var currentQuadStrip=null;var keyboard=null;var detectedImages=false;var currentStrip=null;var keyPanning=false;var strafePanning=false;var iconBaseNoSpot="yellowCarSmall";var iconBaseSpot="yellowSpottySmall";var imageArray=new Array();imageArray[0]=document.createElement("div");imageArray[0].className="yellowSpottySmall0";imageArray[1]=document.createElement("div");imageArray[1].className="yellowSpottySmall1";imageArray[2]=document.createElement("div");imageArray[2].className="yellowSpottySmall2";imageArray[3]=document.createElement("div");imageArray[3].className="yellowSpottySmall3";imageArray[4]=document.createElement("div");imageArray[4].className="yellowSpottySmall4";imageArray[5]=document.createElement("div");imageArray[5].className="yellowSpottySmall5";imageArray[6]=document.createElement("div");imageArray[6].className="yellowSpottySmall6";imageArray[7]=document.createElement("div");imageArray[7].className="yellowSpottySmall7";imageArray[8]=document.createElement("div");imageArray[8].className="yellowSpottySmall8";imageArray[9]=document.createElement("div");imageArray[9].className="yellowSpottySmall9";imageArray[10]=document.createElement("div");imageArray[10].className="yellowSpottySmall10";imageArray[11]=document.createElement("div");imageArray[11].className="yellowSpottySmall11";imageArray[12]=document.createElement("div");imageArray[12].className="yellowSpottySmall12";imageArray[13]=document.createElement("div");imageArray[13].className="yellowSpottySmall13";imageArray[14]=document.createElement("div");imageArray[14].className="yellowSpottySmall14";imageArray[15]=document.createElement("div");imageArray[15].className="yellowSpottySmall15";function h(){if(GetTopPosition(carElement)<=GetTopBoundary())carElement.style.top=GetTopBoundary()+1+"px";}this.SetIconClasses=function(j,k,l){carElement.style.width=l+"px";carElement.style.height=l+"px";iconBaseNoSpot=j;iconBaseSpot=k;ob();};this.SetFocus=function(){keyboard.focus();};function m(n){for(var i=0;i<imageArray.length;i++){imageArray[i].className=n+i;}}function o(e){e=GetEvent(e);switch(e.keyCode){case 16:shiftDown=true;case 9:return true;case 37:if(shiftDown){carcompass.MoveMapLeft();strafePanning=true;}else carcompass.TurnLeft();break;case 38:carcompass.MoveMapForward();keyPanning=true;break;case 39:if(shiftDown){strafePanning=true;carcompass.MoveMapRight();}else carcompass.TurnRight();break;case 40:carcompass.MoveMapBackward();keyPanning=true;break;case 107:case 187:case 61:case 43:map.ZoomIn();VE_Analytics.Log("Home Page","Zoom In","Keyboard");break;case 109:case 189:map.ZoomOut();VE_Analytics.Log("Home Page","Zoom Out","Keyboard");break;default:return false;}return false;}function p(e){e=GetEvent(e);switch(e.keyCode){case 16:shiftDown=false;case 9:return true;case 37:if(strafePanning){map.StopContinuousPan();strafePanning=false;VE_Analytics.Log("Home Page","Car Strafe Left","Keyboard");}break;case 38:map.StopContinuousPan();keyPanning=false;VE_Analytics.Log("Home Page","Car Drive Forward","Keyboard");break;case 39:if(strafePanning){map.StopContinuousPan();strafePanning=false;VE_Analytics.Log("Home Page","Car Strafe Right","Keyboard");}break;case 40:map.StopContinuousPan();keyPanning=false;VE_Analytics.Log("Home Page","Car Drive Reverse","Keyboard");break;default:return false;}}function q(){map.ZoomIn();VE_Analytics.Log("Home Page","Zoom In","Mouse:Car");}this.Init=function(){carElement.id="carcompassicon";carElement.style.position="absolute";carElement.style.width="200px";carElement.style.height="200px";carElement.style.zIndex=400;carElement.style.display="block";carElement.style.opacity="0.60";carElement.appendChild(imageArray[4]);carElement.attachEvent("onmousedown",Cb);carElement.attachEvent("onmouseup",Eb);carElement.attachEvent("onmousemove",Db);carElement.attachEvent("ondblclick",q);document.body.appendChild(carElement);map.AttachEvent("onresize",Fb);map.AttachEvent("onmappan",gb);map.AttachEvent("onendcontinuouspan",gb);keyboard=document.getElementById("wl_ve_mapInput");keyboard.attachEvent("onkeydown",o);keyboard.attachEvent("onkeyup",p);keyboard.focus();this.CenterCarInMap();ob();};this.Detect=function(){ob();};this.CenterCarInMap=function(){carElement.style.top=316+map.GetMapSource().offsetHeight/2-carElement.offsetHeight/2+"px";carElement.style.left=map.GetMapSource().offsetWidth/2-carElement.offsetWidth/2+"px";h();};this.ResetPosition=function(){carcompass.CenterCarInMap();h();};this.Destroy=function(){carElement.detachEvent("onmousedown",Cb);carElement.detachEvent("onmouseup",Eb);carElement.detachEvent("onmousemove",Db);carElement=null;};this.TurnLeft=function(){var tempDirection=currentDirection;if(tempDirection<0)tempDirection+=360;currentAngle=tempDirection;currentAngle+=22.5;if(currentAngle>360)currentAngle-=360;else{if(currentAngle<0)currentAngle+=360;}if(detectedImages){var newAngle=__streetviewer.SnapTo90RelativeToRoad(currentAngle);r(currentAngle);}else r(currentAngle);if(keyPanning)this.MoveMapForward();};this.TurnRight=function(){var tempDirection=currentDirection;if(tempDirection<0)tempDirection+=360;currentAngle=tempDirection;currentAngle-=22.5;if(currentAngle>360)currentAngle-=360;else{if(currentAngle<0)currentAngle+=360;}if(detectedImages){var newAngle=__streetviewer.SnapTo90RelativeToRoad(currentAngle);r(currentAngle);}else r(currentAngle);if(keyPanning)this.MoveMapForward();};this.MoveMapLeft=function(){var x=Math.sin(currentAngle*(Math.PI/180));var y=Math.cos(currentAngle*(Math.PI/180));if(currentDirection<0)map.ContinuousPan(10*x,y*10);else map.ContinuousPan(10*-x,-(y*10));};this.MoveMapRight=function(){var x=Math.sin(currentAngle*(Math.PI/180));var y=Math.cos(currentAngle*(Math.PI/180));if(currentDirection<0)map.ContinuousPan(10*-x,-(y*10));else map.ContinuousPan(10*x,y*10);};this.MoveMapForward=function(){var x=Math.sin(currentAngle*(Math.PI/180));var y=Math.cos(currentAngle*(Math.PI/180));map.ContinuousPan(carDriveSpeed*y,-(x*carDriveSpeed));};this.MoveMapBackward=function(){var x=Math.sin(currentAngle*(Math.PI/180));var y=Math.cos(currentAngle*(Math.PI/180));map.ContinuousPan(-carDriveSpeed*y,x*carDriveSpeed);};function r(s){if(s<0)currentAngle=s+360;else currentAngle=s;if(s>=180)s=s-360;if(s>-11.5&&s<11.5){if(currentDirection==0)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[0]);currentImageIndex=0;currentDirection=0;return;}else{if(s>-33.75&&s<-11.5){if(currentDirection==-22.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[9]);currentImageIndex=9;currentDirection=-22.5;return;}else{if(s>-56.25&&s<-33.75){if(currentDirection==-45)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[10]);currentImageIndex=10;currentDirection=-45;return;}else{if(s>-78.75&&s<-56.25){if(currentDirection==-67.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[11]);currentImageIndex=11;currentDirection=-67.5;return;}else{if(s>-101.25&&s<-78.75){if(currentDirection==-90)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[12]);currentImageIndex=12;currentDirection=-90;return;}else{if(s>-123.75&&s<-101.25){if(currentDirection==-112.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[13]);currentImageIndex=13;currentDirection=-112.5;return;}else{if(s>-146.25&&s<-123.75){if(currentDirection==-135)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[14]);currentImageIndex=14;currentDirection=-135;return;}else{if(s>-168.75&&s<-146.25){if(currentDirection==-157.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[15]);currentImageIndex=15;currentDirection=-157.5;return;}else{if(s<33.75&&s>11.5){if(currentDirection==22.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[1]);currentImageIndex=1;currentDirection=22.5;return;}else{if(s<56.25&&s>33.75){if(currentDirection==45)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[2]);currentImageIndex=2;currentDirection=45;return;}else{if(s<78.75&&s>56.25){if(currentDirection==67.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[3]);currentImageIndex=3;currentDirection=67.5;return;}else{if(s<101.25&&s>78.75){if(currentDirection==90)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[4]);currentImageIndex=4;currentDirection=90;return;}else{if(s<123.75&&s>101.25){if(currentDirection==112.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[5]);currentImageIndex=5;currentDirection=112.5;return;}else{if(s<146.25&&s>123.75){if(currentDirection==135)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[6]);currentImageIndex=6;currentDirection=135;return;}else{if(s<168.75&&s>146.25){if(currentDirection==157.5)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[7]);currentImageIndex=7;currentDirection=157.5;return;}else{if(s<=-180&&s<-168.75||s<=180&&s<168.75){if(currentDirection==-180)return;carElement.removeChild(imageArray[currentImageIndex]);carElement.appendChild(imageArray[8]);currentImageIndex=8;currentDirection=-180;return;}}}}}}}}}}}}}}}}}function t(u,v){var angle=Math.atan2(-v,u)*(180/Math.PI);r(angle);}function w(x,y,z,A){if(Math.abs(x-z)<5E-05&&Math.abs(y-A)<5E-05)return true;else return false;}function B(C,D,E,F){if(Math.abs(C-E)<0.00022&&Math.abs(D-F)<0.00022)return true;else return false;}function G(H){var mouseX=H.x;var mouseY=H.y;var mapLeft=GetLeftPosition(map.GetMapSource());var mapRight=mapLeft+map.GetMapSource().offsetWidth;var mapTop=GetTopPosition(map.GetMapSource());var mapBot=mapTop+map.GetMapSource().offsetHeight;var mapDeltaX=0;var mapDeltaY=0;if(mouseX<mapLeft+map.GetMapSource().offsetWidth/4){mapDeltaX=-5;mouseX=mapLeft+map.GetMapSource().offsetWidth/4;}else{if(mouseX>mapLeft+map.GetMapSource().offsetWidth/4*3){mapDeltaX=5;mouseX=mapLeft+map.GetMapSource().offsetWidth/4*3;}}if(mouseY<mapTop+map.GetMapSource().offsetHeight/4){mapDeltaY=-5;mouseY=mapTop+map.GetMapSource().offsetHeight/4;}else{if(mouseY>mapTop+map.GetMapSource().offsetHeight/4*3){mapDeltaY=5;mouseY=mapTop+map.GetMapSource().offsetHeight/4*3;}}}function I(J,K,L){if(J>=L.HotSpotX1&&J<=L.HotSpotX2&&K>=L.HotSpotY1&&K<=L.HotSpotY2)return true;return false;}this.MoveToNextFrame=function(){if(currentStrip==null)return;if(currentStrip.NextLat!=0&&currentStrip.NextLat!=0)S(currentStrip.NextLat,currentStrip.NextLong);};function M(N,O,P){var xd=N.longitude-P;var yd=N.latitude-O;var dist=xd*xd+yd*yd;return dist;}function Q(R){var centerX=GetLeftPosition(carElement)+carElement.offsetWidth/2-GetLeftPosition(map.GetMapSource());var centerY=GetTopPosition(carElement)+carElement.offsetHeight/2-GetTopPosition(map.GetMapSource());var carLatLong=map.PixelToLatLong(new Msn.VE.Pixel(centerX,centerY));var minDistance=99999999999999999;var minIndex=-1;for(var i=0;i<R.length;i++){var entry=R[i];var distance=M(carLatLong,entry.Latitude,entry.Longitude);if(distance<minDistance){minDistance=distance;minIndex=i;}}return minIndex;}function S(T,U){var latlong=new Msn.VE.LatLong(T,U);var mapPixel=map.LatLongToPixel(latlong,map.GetZoomLevel());mapPixel.x=mapPixel.x+GetLeftPosition(map.GetMapSource());mapPixel.y=mapPixel.y+GetTopPosition(map.GetMapSource());var carPixel=new Msn.VE.Pixel(GetLeftPosition(carElement)+carElement.offsetWidth/2,GetTopPosition(carElement)+carElement.offsetHeight/2);var deltaPixel=new Msn.VE.Pixel(mapPixel.x-carPixel.x,mapPixel.y-carPixel.y);map.SetAnimationEnabled(false);map.PanMap(deltaPixel.x,deltaPixel.y);map.SetAnimationEnabled(false);}function V(W,X){var latlong=new Msn.VE.LatLong(W,X);var mapPixel=map.LatLongToPixel(latlong,map.GetZoomLevel());mapPixel.x=mapPixel.x+GetLeftPosition(map.GetMapSource());mapPixel.y=mapPixel.y+GetTopPosition(map.GetMapSource());carElement.style.top=mapPixel.x-carElement.offsetWidth/2;carElement.style.left=mapPixel.y-carElement.offsetHeight/2;}function Y(Z,ab){var quadArray=stripDB[ab];if(quadArray==null||quadArray[0]==null){carElement.style.opacity="0.60";carElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=75)";m(iconBaseNoSpot);__streetviewer.ShowInfoImage();detectedImages=false;currentStrip=null;return null;}var closeStripIndex=new Array();var closeStrips=new Array();for(index=0;index<quadArray.length;index++){if(B(Z.latitude,Z.longitude,quadArray[index].Latitude,quadArray[index].Longitude)){closeStrips.push(quadArray[index]);closeStripIndex.push(index);}}var closeIndex=Q(closeStrips);if(closeIndex==-1){__streetviewer.ShowInfoImage();carElement.style.opacity="0.60";carElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=75)";m(iconBaseNoSpot);detectedImages=false;currentStrip=null;return;}if(__streetviewer!=null){PrintInfo("");__streetviewer.HideInfoImage();detectedImages=true;carElement.style.opacity="1.0";carElement.style.filter=null;m(iconBaseSpot);__streetviewer.ShowImage(ab,closeStripIndex[closeIndex]);var newAngle=__streetviewer.SnapTo90RelativeToRoad(currentAngle);r(newAngle);currentStrip=quadArray[closeStripIndex[closeIndex]];if(ab!=currentQuadKey)currentQuadKey=ab;}return index;}function bb(cb,eb){var quadArray=stripDB[eb];if(quadArray==null||quadArray[0]==null){carElement.style.opacity="0.60";carElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=75)";__streetviewer.ShowInfoImage();detectedImages=false;return null;}for(index=0;index<quadArray.length;index++){if(w(cb.latitude,cb.longitude,quadArray[index].Latitude,quadArray[index].Longitude)){if(__streetviewer!=null){PrintInfo("");__streetviewer.HideInfoImage();detectedImages=true;carElement.style.opacity="1.0";carElement.style.filter=null;__streetviewer.ShowImage(eb,index);var newAngle=__streetviewer.SnapTo90RelativeToRoad(currentAngle);r(newAngle);if(eb!=currentQuadKey)currentQuadKey=eb;}return index;}}__streetviewer.ShowInfoImage();carElement.style.opacity="0.60";carElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=75)";detectedImages=false;return null;}function gb(hb){ob();}function jb(kb,lb){this.Quadkey=kb;this.Latlong=lb;}function mb(nb){if(nb==null){alert("Quadpack is null");return;}Y(nb.Latlong,nb.Quadkey);}function ob(){var centerX=GetLeftPosition(carElement)+carElement.offsetWidth/2-GetLeftPosition(map.GetMapSource());var centerY=GetTopPosition(carElement)+carElement.offsetHeight/2-GetTopPosition(map.GetMapSource());var latlong=map.PixelToLatLong(new Msn.VE.Pixel(centerX,centerY));var quadkey=map.LatLongToQuadKey(latlong,19);if(__stripdbmanager.LoadQuad(quadkey,mb,new jb(quadkey,latlong)))Y(latlong,quadkey);}this.DetectClosestStrip=ob;var lastMouseX=0;var lastMouseY=0;var carBeingDragged=false;function pb(qb,rb){if(qb>GetLeftPosition(carElement)+carElement.offsetWidth/4+25&&qb<GetLeftPosition(carElement)+carElement.offsetWidth/4*3-25&&rb>GetTopPosition(carElement)+carElement.offsetHeight/4+25&&rb<GetTopPosition(carElement)+carElement.offsetHeight/4*3-25)return true;else return false;}function sb(tb,ub){if(tb>GetLeftPosition(carElement)+carElement.offsetWidth/6&&tb<GetLeftPosition(carElement)+carElement.offsetWidth/6*5&&ub>GetTopPosition(carElement)+carElement.offsetHeight/6&&ub<GetTopPosition(carElement)+carElement.offsetHeight/6*5)return true;else return false;}function vb(wb,xb){lastMouseX=wb;lastMouseY=xb;if(pb(lastMouseX,lastMouseY))carBeingDragged=true;}function yb(zb,Ab){if(!carBeingDragged&&!rotatingCar){if(pb(zb,Ab))carElement.style.cursor="move";else carElement.style.cursor="url(i/cursors/rotate.cur),auto";}if(carBeingDragged){var mapLeft=GetLeftPosition(map.GetMapSource());var mapRight=mapLeft+map.GetMapSource().offsetWidth;var mapTop=GetTopPosition(map.GetMapSource());var mapBot=mapTop+map.GetMapSource().offsetHeight;var mapDeltaX=0;var mapDeltaY=0;if(zb<mapLeft+map.GetMapSource().offsetWidth/6){mapDeltaX=-10;zb=mapLeft+map.GetMapSource().offsetWidth/6;}else{if(zb>mapLeft+map.GetMapSource().offsetWidth/6*5){mapDeltaX=10;zb=mapLeft+map.GetMapSource().offsetWidth/6*5;}}if(Ab<mapTop+map.GetMapSource().offsetHeight/4){mapDeltaY=-10;Ab=mapTop+map.GetMapSource().offsetHeight/4;}else{if(Ab>mapTop+map.GetMapSource().offsetHeight/4*3){mapDeltaY=10;Ab=mapTop+map.GetMapSource().offsetHeight/4*3;}}var deltaX=lastMouseX-zb;var deltaY=lastMouseY-Ab;carElement.style.top=GetTopPosition(carElement)-deltaY+"px";carElement.style.left=GetLeftPosition(carElement)-deltaX+"px";if(mapDeltaY!=0||mapDeltaX!=0){var dx=mapDeltaX;var dy=mapDeltaY;map.ContinuousPan(dx,dy);cPanning=true;}else{if(cPanning==true){map.StopContinuousPan();cPanning=false;}}lastMouseX=zb;lastMouseY=Ab;h();ob();}}function Bb(e){if(carBeingDragged)VE_Analytics.Log("Home Page","Car Drag","Mouse");carBeingDragged=false;if(carElement.releaseCapture)carElement.releaseCapture();}function Cb(e){e=GetEvent(e);var mouseX=GetMouseX(e);var mouseY=GetMouseY(e);if(carElement.setCapture)carElement.setCapture();vb(mouseX,mouseY);CancelEvent(e);if(!carBeingDragged){x=GetLeftPosition(carElement);y=GetTopPosition(carElement);var dx=mouseX-x-carElement.offsetWidth/2;var dy=mouseY-y-carElement.offsetHeight/2;t(dx,dy);dx=Math.min(Math.max(dx,-maxScrollSpeed),maxScrollSpeed);dy=Math.min(Math.max(dy,-maxScrollSpeed),maxScrollSpeed);rotatingCar=true;}ob();return false;}function Db(e){e=GetEvent(e);var mouseX=GetMouseX(e);var mouseY=GetMouseY(e);yb(mouseX,mouseY);CancelEvent(e);if(!carBeingDragged){if(rotatingCar){var dx=GetMouseX(e)-x-carElement.offsetWidth/2;var dy=GetMouseY(e)-y-carElement.offsetHeight/2;t(dx,dy);dx=Math.min(Math.max(dx,-maxScrollSpeed),maxScrollSpeed);dy=Math.min(Math.max(dy,-maxScrollSpeed),maxScrollSpeed);ob();}}return false;}function Eb(e){e=GetEvent(e);CancelEvent(e);if(carElement.releaseCapture)carElement.releaseCapture();map.StopContinuousPan();if(rotatingCar)VE_Analytics.Log("Home Page","Car Rotate","Mouse");rotatingCar=false;carBeingDragged=false;keyboard.focus();return false;}function Fb(){carcompass.CenterCarInMap();h();}function Gb(){carElement.style.display="none";}function Hb(){carElement.style.display="block";}this.Hide=Gb;this.Show=Hb;function Ib(Jb){var currentDir=Jb;for(var j=0;j<16;j++){var tImage=new Image();tImage.src="i/cars/"+currentDir+"/"+imageNameArray[j];imageCache.push(tImage);}}this.PreCacheCarImagesDirectory=Ib;function Kb(){for(var i=0;i<imageDirsToCache.length;i++){var currentDir=imageDirsToCache[i];for(var j=0;j<16;j++){var tImage=new Image();tImage.src="i/cars/"+currentDir+"/"+imageNameArray[j];imageCache.push(tImage);}}}}