var NoSearchResultsText="Sorry, no results were found.  Please try zooming out or entering a street name and searching again.";var searchType=null;var __citybounds=new Array();var map=null;var carcompass=null;var __x=null;var __timer=null;var pinurl="i/pins/poi.gif";var currentLat=null;var currentLon=null;var plink=null;var __streetViewer=null;var __stripdbmanager=null;var __searchurl="Search.aspx?qs=a|%1~b|%2~c|%3~d|%4~e|%5~f|%6~g|1~i|1~r|1";var pushpinpopup=null;var seaMinLat=47.60054;var seaMaxLat=47.63014;var seaMinLon=-122.34819;var seaMaxLon=-122.30416;var seaMinLatLong=new Msn.VE.LatLong(seaMinLat,seaMinLon);var seaMaxLatLong=new Msn.VE.LatLong(seaMaxLat,seaMaxLon);var sfoMinLat=37.79242;var sfoMaxLat=37.80158;var sfoMinLon=-122.4257;var sfoMaxLon=-122.38863;var sfoMinLatLong=new Msn.VE.LatLong(sfoMinLat,sfoMinLon);var sfoMaxLatLong=new Msn.VE.LatLong(sfoMaxLat,sfoMaxLon);var seaMinTileXY=null;var seaMaxTileXY=null;var sfoMinTileXY=null;var sfoMaxTileXY=null;var extMinLat=0;var extMaxLat=0;var extMinLon=0;var extMaxLon=0;function ExtSetViewport(b,c,e,g){extMinLat=b;extMaxLat=e;extMinLon=g;extMaxLon=c;}var doSearch=false;function OnMapPan(){if(doSearch){doSearch=false;ExecuteResponse();doSearch=true;}}function OnZoom(){carcompass.Detect();}function onReadyStateChange(){return;}function PrintInfo(h){var infobox=document.getElementById("infobox");infobox.innerHTML=h;}function VE_Scratchpad(){}VE_Scratchpad.AddLocation=function(a,b,c){return;};function GetXmlHttpRequestObject(){__x=null;try{__x=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{__x=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){__x=null;}}if(!__x&&typeof XMLHttpRequest!="undefined")__x=new XMLHttpRequest();}function Main(){document.title="Windows Live Local - Virtual Earth Technology Preview";__citybounds.push([]);__citybounds.push([]);var elm=document.getElementById("what");elm.onpaste=HandleOnPaste;RegisterNamespaces("Msn.VE");var el=document.getElementById("mapcontainer");el.style.height=GetWindowHeight()-316+"px";el.style.overflow="hidden";el.style.position="absolute";el.style.left="0px";el.style.top="316px";var params=new Object();params.latitude=41.9;params.longitude=-69.52;params.zoomlevel=2;params.mapstyle="h";params.showDashboard=false;params.dashboardSize=Msn.VE.DashboardSize.Normal;params.dashboardX=3;params.dashboardY=3;params.showScaleBar=true;params.obliqueEnabled=false;params.obliqueUrl="imagery.ashx";map=new Msn.VE.MapControl(el,params);map.Init();map.AttachEvent("onendzoom",OnZoom);seaMinTileXY=map.LatLongToTileXY(new Msn.VE.LatLong(seaMaxLat,seaMinLon),19);seaMaxTileXY=map.LatLongToTileXY(new Msn.VE.LatLong(seaMinLat,seaMaxLon),19);sfoMinTileXY=map.LatLongToTileXY(new Msn.VE.LatLong(sfoMaxLat,sfoMinLon),19);sfoMaxTileXY=map.LatLongToTileXY(new Msn.VE.LatLong(sfoMinLat,sfoMaxLon),19);__stripdbmanager=new StripDBManager();__streetviewer=new StreetViewer();__streetviewer.Init(60,0,1024,256);carcompass=new CarCompass(document.body,map,"sporty");carcompass.Init();carcompass.Show();ChangeCity();window.setTimeout("carcompass.Detect()",10);window.onresize=function(e){map.Resize(1024,GetWindowHeight()-316);carcompass.ResetPosition();};}function ExecuteResponse(){VE_Analytics.Log("Home Page","Search");carcompass.SetFocus();if(doSearch==false)doSearch=true;searchType="";if(!(document.getElementById("address").value==""||document.getElementById("address").value=="[Type street address...]"))searchType="where";if(!(document.getElementById("what").value==null||document.getElementById("what").value=="undefined"||document.getElementById("what").value==""||document.getElementById("what").value=="[Business category or name...]"))searchType+="what";if(document.getElementById("what").value==null||document.getElementById("what").value==""||document.getElementById("what").value=="undefined")document.getElementById("what").value="[Business category or name...]";if(document.getElementById("address").value==null||document.getElementById("address").value==""||document.getElementById("address").value=="undefined")document.getElementById("address").value="[Type street address...]";if(searchType=="")return;PushpinHide();map.ClearPushpins();GetXmlHttpRequestObject();function j(k){alert(k);}this.ShowMessage=j;if(__x){var topLeft=map.PixelToLatLong(new Msn.VE.Pixel(0,0));var bottomRight=map.PixelToLatLong(new Msn.VE.Pixel(1024,map.GetMapSource().offsetHeight));var url=__searchurl.replace("%1",document.getElementById("what").value);var where="";var city=document.getElementById("where").value;switch(city){case "2":where="San Francisco, CA";break;case "1":where="Seattle, WA";break;}if(document.getElementById("address").value!=""&&document.getElementById("address").value!="[Type street address...]")where=document.getElementById("address").value+", "+where;if(searchType=="what"){if(topLeft==null||bottomRight==null)return;c=minSSCityLatLong.latitude;d=minSSCityLatLong.longitude;e=maxSSCityLatLong.latitude;f=maxSSCityLatLong.longitude;if(c<e){var t=c;c=e;e=t;}if(d<f){var t=d;d=f;f=t;}url=url.replace("%2"," ");url=url.replace("%3",c);url=url.replace("%4",d);url=url.replace("%5",e);url=url.replace("%6",f);}else{url=url.replace("%2",where);url=url.replace("%3",0);url=url.replace("%4",0);url=url.replace("%5",0);url=url.replace("%6",0);}__x.open("GET",url,true);__x.onreadystatechange=function(){if(__x.readyState==4){var code=__x.responseText;if(code!=null&&code.length>0)try{if(code.substring(0,11)!="SetViewport"&&searchType=="what"){eval(code);return;}var setViewCommand=code.substring(0,code.indexOf(";")+1);var restCode=code.substring(code.indexOf(";")+1,code.length);eval("Ext"+setViewCommand);var centerLat=(extMinLat+extMaxLat)/2;var centerLon=(extMinLon+extMaxLon)/2;if(CheckSSCityLatLongBox(centerLat,centerLon)){if(searchType=="where"){carcompass.CenterCarInMap();map.SetAnimationEnabled(false);eval("map."+code);map.SetAnimationEnabled(true);map.SetZoom(19);carcompass.DetectClosestStrip();}else{if(searchType=="wherewhat"){carcompass.CenterCarInMap();eval(restCode);carcompass.DetectClosestStrip();}}}else alert("Sorry but we do not yet have street side imagery at this location");}catch(ex){alert(NoSearchResultsText);}else alert(NoSearchResultsText);}};__x.send("");}carcompass.SetFocus();return;}function DisplayError(l){if(l!=null)alert(l);else alert("Invalid input for search.");}function SelectAmbiguousList(m,n,o,p,q){var el=document.getElementById("locationselect");el.style.display="none";map.SetViewport(n,o,p,q);document.getElementById("what").value=m;SetCenterAndAddPin(null);}function UpdateAmbiguousList(r){var el=document.getElementById("locationselect");el.innerHTML="";if(r!=null&&r!="undefined")for(var i=0;i<r.length;i++){var d=document.createElement("a");d.id=i;d.className="placelistitem";d.onmouseover=function(){this.className="placelistitemDark";};d.onmouseout=function(){this.className="placelistitem";};var code="SelectAmbiguousList(\""+r[i][0]+"\","+r[i][1]+","+r[i][2]+","+r[i][3]+","+r[i][4]+");";d.href="javascript:"+code;d.innerHTML=r[i][0]+"<br>";el.appendChild(d);}el.style.display="block";}function Search(e){var evt=e?e:window.event;if(evt&&evt.keyCode==13)ExecuteResponse();}function HandleOnPaste(){if(window.clipboardData){var before=window.clipboardData.getData("Text","");var after=before.replace(/[\n\r]+/g,", ");window.clipboardData.setData("Text",after);}}function Dispose(){if(map)map.Destroy();}function GetWindowWidth(){var width=0;if(typeof window.innerWidth=="number")width=window.innerWidth;else{if(document.documentElement&&document.documentElement.clientWidth)width=document.documentElement.clientWidth;else{if(document.body&&document.body.clientWidth)width=document.body.clientWidth;}}if(!width||width<100)width=100;return width;}function GetWindowHeight(){var height=0;if(typeof window.innerHeight=="number")height=window.innerHeight;else{if(document.documentElement&&document.documentElement.clientHeight)height=document.documentElement.clientHeight;else{if(document.body&&document.body.clientHeight)height=document.body.clientHeight;}}if(!height||height<100)height=100;return height;}function ShowMessage(s){var el=document.getElementById("VE_MessageControl");if(el!=null){el.innerHTML=s;el.style.display="block";}}function ChangeSkinAuto(t){var el=document.getElementById("skin");el.value=t;ChangeSkin();}function ChangeSkin(){carcompass.SetFocus();var el=document.getElementById("skin");var car=document.getElementById("carcompassicon");var skin=document.getElementById("carskin");var veHeader=document.getElementById("wl_ve_headerLinks");switch(el.value){case "0":skin.className="blueVanSkin";carcompass.SetIconClasses("blueCarSmall","blueSpottySmall",200);break;case "1":skin.className="yellowVanSkin";carcompass.SetIconClasses("yellowCarSmall","yellowSpottySmall",200);break;case "2":skin.className="blueCarSkin";carcompass.SetIconClasses("blueCarBig","blueSpottyBig",300);break;case "3":skin.className="yellowCarSkin";carcompass.SetIconClasses("yellowCarBig","yellowSpottyBig",300);break;case "99":skin.className="emptySkin";carcompass.SetIconClasses("spotty","spotty",200);break;}veHeader.style.top=60+skin.offsetHeight+"px";VE_Analytics.Log("Home Page","Change View");}function ChangeCity(){carcompass.SetFocus();var el=document.getElementById("where");switch(el.value){case "2":minSSCityTileXY=sfoMinTileXY;maxSSCityTileXY=sfoMaxTileXY;minSSCityLatLong=sfoMinLatLong;maxSSCityLatLong=sfoMaxLatLong;map.SetCenterAndZoom(37.79619,-122.40533,19);carcompass.CenterCarInMap();carcompass.Detect();break;case "1":minSSCityTileXY=seaMinTileXY;maxSSCityTileXY=seaMaxTileXY;minSSCityLatLong=seaMinLatLong;maxSSCityLatLong=seaMaxLatLong;map.SetCenterAndZoom(47.611418,-122.3421125,19);carcompass.CenterCarInMap();carcompass.Detect();break;}carcompass.SetFocus();VE_Analytics.Log("Home Page","Change City");}function VE_SearchManager(){}VE_SearchManager._HandleFailedWhereSearch=function(u){};VE_SearchManager._ApplyResults=function(a,b,c,d,e){carcompass.SetFocus();if(map){if(b!=null){if(b.length<=0){if(!(document.getElementById("what").value==null||document.getElementById("what").value=="undefined"||document.getElementById("what").value==""||document.getElementById("what").value=="[Business category or name...]"))alert(NoSearchResultsText);carcompass.SetFocus();return;}var maxLat=0;var maxLon=-999;var minLat=999;var minLon=999;var numResultsInside=0;for(var i=0;i<b.length;i++){var findResult=new Object();findResult.Id=b[i].id;findResult.Name=b[i].name;findResult.Description=b[i].description;findResult.Latitude=b[i].latitude;findResult.Longitude=b[i].longitude;try{if(CheckSSCityLatLongBox(b[i].latitude,b[i].longitude)){numResultsInside++;if(b[i].latitude<minLat)minLat=b[i].latitude;if(b[i].latitude>maxLat)maxLat=b[i].latitude;if(b[i].longitude<minLon)minLon=b[i].longitude;if(b[i].longitude>maxLon)maxLon=b[i].longitude;map.AddPushpin(b[i].id,b[i].latitude,b[i].longitude,25,25,"bluepin","<img src='"+pinurl+"' onmouseover='ShowPushpin("+b[i].id+","+b[i].latitude+","+b[i].longitude+", \""+escape(b[i].name)+"\", \""+escape(b[i].description)+"\");'>",39);}}catch(err){alert(NoSearchResultsText);carcompass.SetFocus();}}if(numResultsInside>0){if(searchType!=""){map.SetBestMapView(new Array(new Msn.VE.LatLong(minLat,minLon),new Msn.VE.LatLong(maxLat,maxLon)));carcompass.CenterCarInMap();carcompass.Detect();}}else{alert(NoSearchResultsText);carcompass.SetFocus();}}else{alert(NoSearchResultsText);carcompass.SetFocus();}carcompass.SetFocus();}carcompass.SetFocus();};VE_SearchManager.ApplySuggestion=function(v,w){ShowMessage(w);};function UpdateAmbiguousList(a){return;}Msn.VE.Search=new Object();Msn.VE.Search.strLastWhere="";function VE_SearchResultCategory(a,b){this.a = a;this.b = b;}function VE_SearchResult(x,y,z,A,B,C,D,E){this.id=x;this.name=y;this.description=z;this.phone=A;this.rating=B;this.type=C;this.latitude=D;this.longitude=E;this.pushPin=null;this.pinId=null;}function Ad(F,G,H,I,J){this.title=F;this.url=G;this.description=H;this.latitude=I;this.longitude=J;}function ShowPushpin(K,L,M,N,O){var currentX=GetLeft()+map.GetX(M);var currentY=GetTop()+map.GetY(L);if(pushpinpopup==null||pushpinpopup=="undefined"){pushpinpopup=document.createElement("div");pushpinpopup.id="vepushpinpanel";pushpinpopup.style.zIndex=999;pushpinpopup.className="VE_Pushpin_Popup";pushpinpopup.style.left=currentX+10+"px";pushpinpopup.style.top=currentY+"px";var container=document.createElement("div");container.className="VE_Pushpin_Popup_Container";container.id="pushpincon";pushpinpopup.appendChild(container);var beak=document.createElement("div");beak.className="VE_Pushpin_Popup_Edge";beak.style.zIndex=900;pushpinpopup.appendChild(beak);var edge=document.createElement("div");edge.className="VE_Pushpin_Popup_Beak";edge.style.zIndex=900;pushpinpopup.appendChild(edge);var titleel=document.createElement("div");titleel.className="VE_Pushpin_Popup_Title";titleel.id="vepushpinpaneltitle";titleel.style.zIndex=900;titleel.unselectable="on";pushpinpopup.appendChild(titleel);var cb=document.createElement("a");cb.className="VE_Pushpin_Popup_Close";cb.style.zIndex=901;cb.onclick=PushpinHide;cb.unselectable="on";cb.innerHTML="Close";pushpinpopup.appendChild(cb);body=document.createElement("div");body.id="vepushpinpanelbody";body.className="VE_Pushpin_Popup_Body";pushpinpopup.appendChild(body);body.style.zIndex=902;foot=document.createElement("div");foot.id="vepushpinpanelfooter";foot.className="VE_Pushpin_Popup_Footer";pushpinpopup.appendChild(foot);foot.style.zIndex=902;document.body.appendChild(pushpinpopup);map.AttachEvent("onclick",PushpinHide);map.AttachEvent("onendcontinuouspan",PushpinHide);map.DetachEvent("onchangeview",PushpinHide);}document.getElementById("vepushpinpanelfooter").innerHTML="<a href='javascript:PushpinHide();map.SetCenterAndZoom("+L+","+M+", 19);carcompass.CenterCarInMap();carcompass.Detect();carcompass.SetFocus();VE_Analytics.Log(\"Home Page\",\"Zoom to Street\",\"Mouse\");'>Zoom to Street</a>";document.getElementById("vepushpinpaneltitle").innerHTML=unescape(N);document.getElementById("vepushpinpanelbody").innerHTML=unescape(O);if(navigator.userAgent.indexOf("IE")>=0){pushpinpopup.style.left=currentX+5+"px";pushpinpopup.style.top=currentY-155+"px";}else{pushpinpopup.style.left=currentX-70+"px";pushpinpopup.style.top=currentY-10+"px";}pushpinpopup.style.display="block";var iMagic=document.getElementById("magic");var con=document.getElementById("pushpincon");iMagic.style.position="absolute";iMagic.style.top=pushpinpopup.style.top;iMagic.style.left=GetLeft(pushpinpopup)+70+"px";iMagic.style.width="330px";iMagic.style.height="175px";iMagic.style.display="block";}function PushpinHide(){if(pushpinpopup!=null)pushpinpopup.style.display="none";var iMagic=document.getElementById("magic");iMagic.style.top="0px";iMagic.style.left="0px";iMagic.style.width="0px";iMagic.style.height="0px";iMagic.style.display="none";}function GetLeft(P){if(P==null)P=document.getElementById("mapcontainer");var curleft=0;if(P.offsetLeft)curleft=P.offsetLeft;else{if(P.offsetParent)while(P.offsetParent){curleft+=P.offsetLeft;P=P.offsetParent;}else{if(P.x)curleft+=P.x;}}return curleft;}function GetTop(Q){if(Q==null)Q=document.getElementById("mapcontainer");var curtop=0;if(Q.offsetTop)curtop=Q.offsetTop;else{if(Q.offsetParent)while(Q.offsetParent){curtop+=Q.offsetTop;Q=Q.offsetParent;}else{if(Q.y)curtop+=Q.y;}}return curtop;}function TogglePanel(R,S){var el=document.getElementById(R);if(el!=null){if(S)el.style.display="none";else{var main=document.getElementById("main3");main.style.height=GetWindowHeight()-450+"px";el.style.display="block";}}}