function DisplayMapList(){var m=document.getElementById("mapstylelist");m.style.left=GetElementLeftPosition('mapStyle_h');if(m.style.visibility=="visible"){m.style.visibility="hidden";if(m.releaseCapture){m.releaseCapture();}}else{window.attachEvent("onclick",HideMapStyleList);m.style.visibility="visible";m.setCapture(false);m.focus();document.getElementById("toolslist").style.visibility="hidden";}}
function DisplayToolsList(){var t=document.getElementById("toolslist");t.style.left=GetElementLeftPosition('toolslink');if(t.style.visibility=="visible"){t.style.visibility="hidden";if(t.releaseCapture){t.releaseCapture();}}else{window.attachEvent("onclick",HideToolsList);t.style.visibility="visible";t.setCapture(false);t.focus();document.getElementById("mapstylelist").style.visibility="hidden";}}
function HideToolsList(){var t=document.getElementById("toolslist");t.style.visibility="hidden";if(t.releaseCapture){t.releaseCapture();}}
function HideMapStyleList(){var m=document.getElementById("mapstylelist");m.style.visibility="hidden";if(m.releaseCapture){m.releaseCapture();}}
function HideAmbiguousList(){var m=document.getElementById("whereambiglist");m.style.visibility="hidden";if(m.releaseCapture){m.releaseCapture();}document.body.onclick=null;}
function keydown_Go(list){if(!list)list=GetTarget();var d=document.getElementById(list.id);d.style.visibility="visible";var options=d.childNodes;var newOption=-1;var tabOption=-1;for(var i=0;i<options.length;i++){if(options.item(i).className=='item_on'){if(event.keyCode==40){if(i==options.length-1)newOption=0;else newOption=i+1;}else if(event.keyCode==38){if(i==0)newOption=options.length-1;else newOption=i-1;}else if(event.keyCode==9){if(list.id=='whereambiglist')tabOption=i;newOption=-1;d.style.visibility="hidden";}else if(event.keyCode==13){if(list.id=='whereambiglist')document.f.where.value=options.item(i).innerText;newOption=-1;d.style.visibility="hidden";options.item(i).onclick();}else{newOption=i;}options.item(i).className='item';}}if(newOption==-1)newOption=0;if(newOption>=0&&newOption<options.length){options.item(newOption).className='item_on';}if(list.id=='whereambiglist'&&event.keyCode==9){document.f.where.value=options.item(tabOption).innerText;document.getElementById('where').focus();}else if(list.id=='whereambiglist'&&event.keyCode!=13)document.f.where.value=options.item(newOption).innerText;if(event.preventDefault)event.preventDefault();return false;}
function item_MouseOver(e){var el=GetTarget(e);var d=document.getElementById(el.parentNode.id);d.style.visibility="visible";var options=d.childNodes;newOption=-1;for(i=0;i<options.length;i++){options.item(i).className='item';}el.className="item_on";if(d.id=='whereambiglist')document.f.where.value=el.innerHTML;}
function item_MouseOut(e){var el=GetTarget(e);el.className="item";}
function PositionHelperLinks(){var h=document.getElementById('helperLinks');if(windowWidth-h.offsetWidth>250)h.style.left=windowWidth-h.offsetWidth;else h.style.left=250;h.style.visibility="visible";}
function VE_Panel(id,x,y,width,height,color,zIndex,title,body,footer,mouseovertitle){this.index=0;this.x=x;this.y=y;this.width=width;this.height=height;this.color=color;this.toolbarHeight=20;this.footerHeight=20;this.min=false;this.visible=true;this.onTitleClick=null;this.onCloseClick=null;var el=VE_Panel._CreateElement("div",id,"VE_Panel_el",zIndex);this.el=el;this.title=VE_Panel._CreateElement("a",id+"_title","VE_Panel_title VE_Panel_title_"+color+(mouseovertitle?" VE_Panel_title_mouseover":""),zIndex+1);this.title.innerHTML=IOSec.EncodeHtml(title);this.title.onclick=VE_Panel._OnTitleClick;this.title.unselectable="on";el.appendChild(this.title);this.cb=VE_Panel._CreateElement("a",id+"_cb","VE_Panel_cb VE_Panel_cb_"+color,zIndex+1);this.cb.innerHTML="X";this.cb.onclick=VE_Panel._OnCloseClick;this.cb.unselectable="on";el.appendChild(this.cb);this.tb=VE_Panel._CreateElement("div",id+"_tb","VE_Panel_tb VE_Panel_tb_"+color,zIndex+1);this.tb.unselectable="on";el.appendChild(this.tb);this.body=VE_Panel._CreateElement("div",id+"_body","VE_Panel_body",zIndex+1);this.body.innerHTML=body;el.appendChild(this.body);this.foot=VE_Panel._CreateElement("div",id+"_foot","VE_Panel_foot VE_Panel_foot_"+color,zIndex+1);this.foot.innerHTML=footer;this.foot.unselectable="on";el.appendChild(this.foot);this.Resize();this.SetOpacity(90);VE_Panel.panels.push(this);}
VE_Panel.panels=new Array();
VE_Panel.shadowThickness=3;
VE_Panel._CreateElement=function(type,id,className,zIndex){var el=document.createElement(type);el.id=id;el.className=className;el.style.position="absolute";el.style.zIndex=zIndex;return el;}
VE_Panel._PositionElement=function(el,x,y,w,h){el.style.top=y+"px";el.style.left=x+"px";el.style.width=w+"px";el.style.height=h+"px";}
VE_Panel.prototype.SetPosition=function(x,y,w,h){this.x=x;this.y=y;this.w=w;this.h=h;}
VE_Panel.prototype.SetToolbarSize=function(toolbarHeight){this.toolbarHeight=toolbarHeight;var d=eval(toolbarHeight)>0?"block":"none";this.tb.style.display=d;this.Resize();}
VE_Panel.prototype.SetFooterSize=function(footerHeight){this.footerHeight=footerHeight;var d=eval(footerHeight)>0?"block":"none";this.foot.style.display=d;this.Resize();}
VE_Panel.prototype.Resize=function(){var x=eval(this.x);var y=eval(this.y);var w=Math.max(eval(this.width),100);var h=Math.max(eval(this.height),18);var th=eval(this.toolbarHeight);var fh=eval(this.footerHeight);var st=VE_Panel.shadowThickness;var by=21+th;var bh=h-27-th-fh;if(this.min){h=21;}else{if(th>0){VE_Panel._PositionElement(this.tb,1,19,w-4,th);}else{by-=2;bh+=2;}if(fh>0){VE_Panel._PositionElement(this.foot,1,h-fh-3,w-4,fh);}else{bh+=2;}if(bh>0){VE_Panel._PositionElement(this.body,1,by,w-4,bh);}}VE_Panel._PositionElement(this.el,x,y,w,h);VE_Panel._PositionElement(this.title,1,1,w-19,17);VE_Panel._PositionElement(this.cb,w-19,1,16,17);}
VE_Panel.prototype.SetTitle=function(c){this.title.innerHTML=IOSec.EncodeHtml(c);}
VE_Panel.prototype.SetToolbar=function(c){this.tb.innerHTML=c;}
VE_Panel.prototype.SetBody=function(c){this.body.innerHTML=c;}
VE_Panel.prototype.SetFooter=function(c){this.foot.innerHTML=c;}
VE_Panel.prototype.SetOpacity=function(o){if(o>=100)o=99.99;with(this.el.style){filter="alpha(opacity:"+o+")";o*=0.01;KHTMLOpacity=o;MozOpacity=o;opacity=o;}}
VE_Panel.prototype.SetColor=function(c){this.color=c;this.title.className="VE_Panel_title VE_Panel_title_"+c;this.foot.className="VE_Panel_foot VE_Panel_foot_"+c;this.cb.className="VE_Panel_cb VE_Panel_cb_"+c;}
VE_Panel.prototype.Minimize=function(){this.min=true;this.tb.style.display="none";this.body.style.display="none";this.foot.style.display="none";this.Resize();}
VE_Panel.prototype.Maximize=function(){this.min=false;if(eval(this.toolbarHeight)>0){this.tb.style.display="block";}if(eval(this.footerHeight)>0){this.foot.style.display="block";}this.body.style.display="block";this.Resize();}
VE_Panel.prototype.Show=function(){this.el.style.display="block";this.visible=true;}
VE_Panel.prototype.Hide=function(){this.el.style.display="none";this.visible=false;}
VE_Panel.prototype.Toggle=function(){if(this.min){this.Maximize();}else{this.Minimize();}}
VE_Panel.prototype.Destroy=function(){if(this.el.parentNode){this.el.parentNode.removeChild(this.el);}var p=VE_Panel.panels;for(var i=0;i<p.length;i++){if(p[i]==this){p.splice(i,1);return;}}}
VE_Panel.ResizeAllPanels=function(){VE_Scratchpad._ResizePanel();var p=VE_Panel.panels;for(var i=0;i<p.length;i++){p[i].Resize();}}
function VE_PanelEvent(srcPanel){this.srcPanel=srcPanel;}
VE_Panel.prototype._CreateEvent=function(){return new VE_PanelEvent(this);}
VE_Panel._OnTitleClick=function(e){if(!e)e=window.event;var t=GetTarget(e);var p=VE_Panel.panels;for(var i=0;i<p.length;i++){if(p[i].title==t){if(p[i].onTitleClick){p[i].onTitleClick(p[i]._CreateEvent());}return;}}}
VE_Panel._OnCloseClick=function(e){if(!e)e=window.event;var c=GetTarget(e);var p=VE_Panel.panels;for(var i=0;i<p.length;i++){if(p[i].cb==c){if(p[i].onCloseClick){p[i].onCloseClick(p[i]._CreateEvent());}return;}}}
function VE_SearchManager(){}
VE_SearchManager.searches=new Array();
VE_SearchManager.searchIndex=0;
VE_SearchManager.searching=false;
VE_SearchManager.queue=new Array();
VE_SearchManager.xmlHttp=null;
VE_SearchManager.displayCount=10;
VE_SearchManager.requestCount=10;
VE_SearchManager.onPageResults=null;
VE_SearchManager.maxSearches=1;
VE_SearchManager.colors=new Array("green","red","purple");
VE_SearchManager.searchPage="search.ashx";
VE_SearchManager.adsPage="ads.ashx";
VE_SearchManager.popup=null;
VE_SearchManager.timerID=-1;
VE_SearchManager.mapControl=null;
VE_SearchManager.panelParentElement=document.body;
VE_SearchManager.panelParentWidth;
VE_SearchManager.panelParentHeight;
VE_SearchManager.panelOffsetHeight=110;
VE_SearchManager.autoRefreshDelay=500;
VE_SearchManager.Search=function(what,where){var s=false;if(what){what=what.replace(/\|/g,' ').replace(/\^/g,' ').replace(/^\s+/g,"").replace(/\s+$/g,"");if(what!=""){var i=VE_SearchManager.IndexOf(what);if(i==-1){VE_SearchManager._AddSearch(what,"WHAT");s=true;}else{VE_SearchManager._MoveToFront(i,true);VE_SearchManager.ResizePanels();}}}if(where){VE_SearchManager._ResetPaging();VE_SearchManager._CancelAllRequests();s=true;}if(s){VE_SearchManager._DoSearch(where,where);}}
VE_SearchManager.RefreshAll=function(){if(VE_SearchManager.searches.length>0){VE_SearchManager._ResetPaging();VE_SearchManager._CancelAllRequests();VE_SearchManager._DoSearch("",true,VE_SearchManager.autoRefreshDelay);}}
VE_SearchManager.FindByIndex=function(index){var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){if(s[i].index==index)return s[i];}return null;}
VE_SearchManager.IndexOf=function(phrase){phrase=phrase.toLowerCase();var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){if(s[i].phrase.toLowerCase()==phrase)return s[i].index;}return-1;}
VE_SearchManager._AddSearch=function(what,type){var a=VE_SearchManager.searches;if(a.length==1){VE_SearchManager._RemoveSearch(a[a.length-1].index);}var s=new VE_Search(what,type);a.unshift(s);VE_SearchManager.ResizePanels();if(this.onAddSearch){this.onAddSearch();}}
VE_SearchManager._MoveToFront=function(index,maximize){var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){if(s[i].index==index){var t=s[i];s.splice(i,1);s.unshift(t);if(maximize){t.panel.Maximize();}if(!t.panel.min&&(t.ads==null||t.ads.length==0)){VE_SearchManager._RefreshAds(t);}return;}}}
VE_SearchManager._RemoveSearch=function(index){var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){if(s[i].index==index){if(VE_SearchManager.popup&&s[i].index==VE_SearchManager.popupID){VE_SearchManager.CloseSearchPopup();}VE_SearchManager.colors.push(s[i].color);s[i].Destroy();s.splice(i,1);if(this.onRemoveSearch){this.onRemoveSearch();}return;}}}
VE_SearchManager._ResetPaging=function(){var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){s[i].startIndex=0;s[i].displayIndex=0;}}
VE_SearchManager._DoSearch=function(where,all,delay){var m=VE_SearchManager.mapControl;var s=VE_SearchManager.searches;var a="";var b=escape(where);var c=m.GetLatitude(0);var d=m.GetLongitude(m.width);var e=m.GetLatitude(m.height);var f=m.GetLongitude(0);var g="";var i="";var r="false";if(!where||where==""){if(s.length>0){a=escape(s[0].phrase);g=s[0].startIndex;i=s[0].index;r++;}if(all){for(var j=1;j<s.length;j++){a+="|"+escape(s[j].phrase);i+="|"+s[j].index;r++;}r="true";}b="";}var url=VE_SearchManager.searchPage+"?a="+a+"&b="+b+"&c="+c+"&d="+d+"&e="+e+"&f="+f+"&g="+g+"&i="+i+"&r="+r;VE_SearchManager._AddRequest(url,delay);}
VE_SearchManager._RefreshAds=function(s)
{
if(s==null)return;
var m=VE_SearchManager.mapControl;
var url=VE_SearchManager.adsPage+
	"?a="+escape(s.phrase)+
	"&b="+s.index+
	"&c="+m.GetCenterLatitude().toFixed(6)+
	"&d="+m.GetCenterLongitude().toFixed(6);
	VE_SearchManager._AddRequest(url);
}

VE_SearchManager._AddRequest=function(url,delay){VE_SearchManager.queue.unshift(url);if(delay){VE_SearchManager.timerID=window.setTimeout("VE_SearchManager._SendNextRequest()",delay);}else{VE_SearchManager._SendNextRequest();VE_SearchManager.timerID=-1;}}
VE_SearchManager._CancelTimerRequest=function(){if(VE_SearchManager.timerID!=-1){try{window.clearTimeout(VE_SearchManager.timerID);}catch(ex){}VE_SearchManager.timerID=-1;}}
VE_SearchManager._CancelAllRequests=function(){if(VE_SearchManager.searching){VE_SearchManager.searching=false;VE_SearchManager.xmlHttp.abort();}VE_SearchManager._CancelTimerRequest();var q=VE_SearchManager.queue;while(q.length){q.pop();}}
VE_SearchManager._SendNextRequest=function(){if(VE_SearchManager.searching){return;}VE_SearchManager._CancelTimerRequest();var q=VE_SearchManager.queue;if(!q||q.length==0){return;}var url=q.pop();VE_SearchManager.xmlHttp=GetXmlHttp();var x=VE_SearchManager.xmlHttp;if(x){x.open("POST",url,true);x.onreadystatechange=VE_SearchManager._ResponseHandler;VE_SearchManager.searching=true;x.send("");}}
VE_SearchManager._ResponseHandler=function(){var x=VE_SearchManager.xmlHttp;if(x.readyState==4){VE_SearchManager.searching=false;var code=x.responseText;try{eval(code);}catch(ex){if(x.status!=200){ShowMessage('Virtual Earth could not process your search request due to a communication error. Errors of this type can be caused by an incorrectly configured control or by network connection issues. Contact the site owner if this problem persists.');map.RemoveSearch();}}VE_SearchManager._SendNextRequest();}}
VE_SearchManager._HandleFailedWhereSearch=function(message){if(message){ShowMessage("No results were found. Try another search");}var s=VE_SearchManager.searches;for(var i=0;i<s.length;i++){if(s[i].results==null){VE_SearchManager._DoSearch("",true);break;}}}
VE_SearchManager._ApplyAds=function(index,ads){var s=VE_SearchManager.FindByIndex(index);if(!s){return;}s.ads=ads;s._UpdateAds();}
VE_SearchManager._ApplyResults=function(index,results,ads,hasMore,message){var s=VE_SearchManager.FindByIndex(index);if(!s){return;}s._ClearPins();s.results=results;s.ads=ads;s.hasMore=hasMore;s.message=message;s._UpdatePins();s._UpdatePanel();}
VE_SearchManager.ApplySuggestion=function(index,suggestion){VE_SearchManager._RemoveSearch(index);VE_SearchManager.Search(suggestion);document.f.what.value=suggestion;}
VE_Search.zIndex=31;
function VE_Search(phrase,type){this.index=VE_SearchManager.searchIndex++;this.type=type;this.phrase=this.IsWhereAdsSearch()?"^":phrase;this.startIndex=0;this.displayIndex=0;this.color=VE_SearchManager.colors.pop();this.pinZIndex=VE_MapPushpin.baseZIndex;this.results=null;this.ads=null;this.hasMore=false;this.message="";this.panel=new VE_Panel("search_"+this.index,5,80,180,400,this.color,VE_Search.zIndex,phrase,"Loading...","",true);VE_SearchManager.panelParentElement.appendChild(this.panel.el);this.panel.index=this.index;if(this.IsWhereAdsSearch()){this.panel.SetFooterSize("eval(this.height) - 20");}else{this.panel.SetFooterSize(VE_Search.FooterSize);}this.panel.onTitleClick=function(e){var p=e.srcPanel;p.Toggle();VE_SearchManager._MoveToFront(p.index);VE_SearchManager.ResizePanels();};this.panel.onCloseClick=function(e){var p=e.srcPanel;VE_SearchManager._RemoveSearch(p.index);VE_SearchManager.ResizePanels();};}
VE_Search.FooterSize=120;
VE_Search.prototype.SetResults=function(results){this._ClearPins();this.results=results;this._UpdatePins();}
VE_Search.prototype._SetPinZIndex=function(pinZIndex){if(this.pinZIndex==pinZIndex){return;}this.pinZIndex=pinZIndex;var r=this.results;if(!r||r.length==0){return;}for(var i=0;i<r.length;i++){if(r[i]==null||r[i].pushPin==null){continue;}r[i].pushPin.style.zIndex=this.pinZIndex;}}
VE_Search.prototype._ClearPins=function(){var r=this.results;if(!r||r.length==0){return;}for(var i=0;i<r.length;i++){if(r[i].pushPin){VE_SearchManager.mapControl.RemovePushpin(r[i].pushPin.id);r[i].pushPin=null;}}}
VE_Search.prototype._UpdatePins=function(){var r=this.results;if(!r||r.length==0){return;}var a=this.displayIndex;var b=Math.min(r.length,a+VE_SearchManager.displayCount);for(var i=a;i<b;i++){r[i].pushPin=VE_SearchManager.mapControl.AddPushpin("pin_"+this.index+"_"+r[i].id,r[i].latitude,r[i].longitude,23,17,"VE_Pushpin VE_Pushpin_"+this.color,(i+1+this.startIndex)+'',this.pinZIndex);r[i].pushPin.onmouseover=VE_SearchManager._ShowSearchPopup;}}
VE_Search.prototype._UpdatePanel=function(){var r=this.results;var n=r.length;if(!r||n==0){if(this.message=="No results were found. Try another search, or if entering an address, enter it in the <b>Where</b> box. Click <a href=\"javascript:VE_Help.Open('Help','Help/Find.html')\" oncontextmenu=\"return false;\">help</a> to learn more.<br><br>"){this.message="No results were found. Try another search, or if entering an address, enter it in the <b>Where</b> box.<br><br>";}this.panel.SetBody(this.message);this.panel.SetToolbar("");}else{var a=this.displayIndex;var b=Math.min(n,a+VE_SearchManager.displayCount);var body="";if(this.startIndex==0&&a==0&&this.message){body=this.message;}body+="<table>";for(var i=a;i<b;i++){body+="<tr><td valign=\"top\"><a href=\"javascript:VE_SearchManager._ShowSearchPopup("+null+", "+this.index+", "+r[i].id+")\" oncontextmenu=\"return false;\">";body+="<div class=\"VE_Pushpin VE_Pushpin_"+this.color+"\">"+(this.startIndex+i+1)+"</div></a></td>";body+="<td valign=\"top\">";body+="<a href=\"javascript:VE_SearchManager._ShowSearchPopup("+null+", "+this.index+", "+r[i].id+")\" oncontextmenu=\"return false;\">";body+=r[i].name+"</a><br/>"+r[i].description+"<br/>";if(r[i].rating>=0&&r[i].rating<=10){body+="<div class=\"stars"+Math.round(r[i].rating/2)+"\"></div>";}body+="</td></tr>";}body+="</table>";this.panel.SetBody(body);var toolbar="<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr>";if(this.startIndex+a>0){toolbar+="<td align=\"left\">&nbsp;<a href=\"javascript:VE_SearchManager.PageBackward("+this.index+")\" oncontextmenu=\"return false;\">Previous "+VE_SearchManager.displayCount+"</a></td> ";}if(b<n||this.hasMore){toolbar+="<td align=\"right\"><a href=\"javascript:VE_SearchManager.PageForward("+this.index+")\" oncontextmenu=\"return false;\">Next "+VE_SearchManager.displayCount+"</a>&nbsp;</td> ";}toolbar+="</tr></table>";this.panel.SetToolbar(toolbar);}this._UpdateAds();}
VE_Search.prototype._UpdateAds=function(){if(!this.IsWhereAdsSearch()&&(!this.ads||this.ads.length==0)){this.panel.SetFooter("");this.panel.SetFooterSize(0);}else{var ads="<span style=\"color:gray\">SPONSORED LINKS</span><br>";for(var i=0;i<this.ads.length;i++){ads+=this.ads[i].ToHtml()+"<br><br>";}this.panel.SetFooter(ads);if(!this.IsWhereAdsSearch()){this.panel.SetFooterSize(VE_Search.FooterSize);}}}
VE_Search.prototype.Destroy=function(){this._ClearPins();this.panel.Destroy();}
VE_Search.prototype.GetEntity=function(id){var r=this.results;if(!r||r.length==0){return null;}for(var i=0;i<r.length;i++){if(r[i].id==id){return r[i];}}return null;}
VE_Search.prototype.IsWhereAdsSearch=function(){return this.type=="WHERE";}
VE_SearchManager.PageForward=function(index){if(VE_SearchManager.searching){return;}VE_SearchManager.CloseSearchPopup();var s=VE_SearchManager.FindByIndex(index);if(s.displayIndex+VE_SearchManager.displayCount>=VE_SearchManager.requestCount){s.startIndex+=VE_SearchManager.requestCount;s.displayIndex=0;VE_SearchManager._DoSearch("",false);}else{s._ClearPins();s.displayIndex+=VE_SearchManager.displayCount;s._UpdatePins();s._UpdatePanel();}}
VE_SearchManager.PageBackward=function(index){if(VE_SearchManager.searching){return;}VE_SearchManager.CloseSearchPopup();var s=VE_SearchManager.FindByIndex(index);if(s.displayIndex==0){if(s.startIndex>0){s.startIndex-=VE_SearchManager.requestCount;s.displayIndex=VE_SearchManager.requestCount-VE_SearchManager.displayCount;VE_SearchManager._DoSearch("",false);}}else{s._ClearPins();s.displayIndex-=VE_SearchManager.displayCount;s._UpdatePins();s._UpdatePanel();}}
VE_SearchManager.ResizePanels=function(displayIntro){var s=VE_SearchManager.searches;if(s.length==0)return;var index=1;var p=s[0].panel;var y=(s.length*30);if(!displayIntro){VE_Help.CloseIntro();}else{VE_Help.introPanel.y=VE_SearchManager.panelOffsetHeight;VE_Help.introPanel.height="VE_SearchManager.panelParentHeight-"+(y+90+30);VE_Help.introPanel.Resize();index=0;p.Minimize();}if(p.min){p.y="VE_SearchManager.panelParentHeight-"+(y+45);p.Resize();}else{p.y=VE_SearchManager.panelOffsetHeight;p.height="VE_SearchManager.panelParentHeight-"+(y+90+30);p.Resize();}for(var i=index;i<s.length;i++){p=s[i].panel;p.y="VE_SearchManager.panelParentHeight-"+(y-i*30+60);p.Minimize();p.Resize();}for(var i=0;i<s.length;i++){s[i]._SetPinZIndex(VE_MapPushpin.baseZIndex+s.length-i);}}
VE_SearchManager.popup=null;
VE_SearchManager.popupEntity=null;
VE_SearchManager.popupPushpin=null;
VE_SearchManager.popupPushpinOrigZIndex;
VE_SearchManager.popupZIndex=41;
VE_SearchManager.popupID;
VE_SearchManager._GetEntityReference=function(e){var returnValues=new Array();if(!e){e=window.event;}var t=GetTarget(e);if(!t){return;}var id=t.id;var a=id.indexOf('_');var b=id.lastIndexOf('_');returnValues[0]=id.substr(a+1,b-a-1);returnValues[1]=id.substr(b+1,id.length-b);return(returnValues);}
VE_SearchManager._ShowSearchPopup=function(e,searchIndex,entityID){if(!searchIndex&&!entityID){var returnArray=VE_SearchManager._GetEntityReference(e);if(!returnArray){return;}searchIndex=returnArray[0];entityID=returnArray[1];}var s=VE_SearchManager.FindByIndex(searchIndex);var r=s.GetEntity(entityID);if(!r||r==VE_SearchManager.popupEntity){return;}VE_SearchManager._RestorePushpinZIndex();VE_SearchManager.popupPushpin=r.pushPin;VE_SearchManager.popupPushpinOrigZIndex=s.pinZIndex;var content=VE_SearchManager.CreatePopupContent(r,true,searchIndex);VE_SearchManager.popupID=searchIndex;VE_SearchManager.ShowPopup(r,s.color,content);}
VE_SearchManager._ShowScratchpadPopup=function(entityID,type,e){if(!VE_SearchManager.mapControl.panning&&!VE_SearchManager.mapControl.zooming){if(!entityID){var returnArray=VE_SearchManager._GetEntityReference(e);if(!returnArray){return;}entityID=returnArray[0];type=returnArray[1];}var r=VE_Scratchpad.GetEntity(entityID,type);if(!r||r==VE_SearchManager.popupEntity){return;}VE_SearchManager._RestorePushpinZIndex();VE_SearchManager.popupPushpin=document.getElementById(VE_Scratchpad.GeneratePinId(r));VE_SearchManager.popupPushpinOrigZIndex=VE_Scratchpad.pinZIndex;var content=VE_SearchManager.CreatePopupContent(r,false);VE_SearchManager.popupID=entityID+type;VE_SearchManager.ShowPopup(r,VE_Scratchpad.GetColorForEntity(r),content);}}
VE_SearchManager.CreatePopupContent=function(r,scratchpadLink,searchIndex){var tb="";var name="";var description="";var text="<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td>";var escapedID=escape(r.GetSerializedId());text+=((r.name)?r.name+"<br>":"");text+=((r.description)?r.description+"<br>":"");text+=((r.phone)?r.phone+"<br>":"");if(r.type=="yp"){var windowW=(GetWindowWidth()-400<775?775:GetWindowWidth()-400);tb+="<br><a href=\"javascript:OpenNewWindow('http://virtualearth.msn.com/Details.aspx?dt=yp."+r.id+"&style=' + VE_SearchManager.mapControl.GetMapStyle(), 'Detail"+r.id+"', 'all', "+windowW+", 500, 200, 200);\" class=\"VE_Panel_sublink\" oncontextmenu=\"return false;\">Details</a>";}name=escape(r.name);description=escape(r.description);var body=escape(r.name+"\n"+r.description+"\nhttp://virtualearth.msn.com/?sp="+escapedID+"\n\n");if(r.type!="al"){tb+="<br><a href=\""+VE_SearchManager._GenerateDrivingDirectionsUrl(2,name,description,r.latitude,r.longitude)+"\" class=\"VE_Panel_sublink\" target=\"_blank\">Drive To</a>";tb+=" or <a href=\""+VE_SearchManager._GenerateDrivingDirectionsUrl(1,name,description,r.latitude,r.longitude)+"\" class=\"VE_Panel_sublink\" target=\"_blank\">Drive From</a>";}if(escapedID){tb+="<br><a href=\"mailto:?subject="+name+"%20at%20Virtual%20Earth&body="+body+"\" class=\"VE_Panel_sublink\" target=\"_blank\" oncontextmenu=\"return false;\">E-mail a Friend</a>";}text+=tb;text+="</td></tr></table>";return text;}
VE_SearchManager.ShowPopup=function(entity,color,tb){if(VE_SearchManager.popupEntity==entity){return;}VE_SearchManager.popupEntity=entity;VE_SearchManager.popupPushpin.style.zIndex=VE_MapPushpin.topZIndex;if(!color){color="black";}if(!VE_SearchManager.popup){VE_SearchManager.popup=new VE_Panel("searchPopup",5,80,200,0,color,VE_SearchManager.popupZIndex,"","","");VE_SearchManager.panelParentElement.appendChild(VE_SearchManager.popup.el);var p=VE_SearchManager.popup;p.SetFooterSize(0);p.SetToolbarSize(0);p.onCloseClick=VE_SearchManager.CloseSearchPopup;}var w=VE_SearchManager.panelParentWidth;if(VE_Scratchpad.panel&&VE_Scratchpad.panel.visible){w-=200;}var x=VE_SearchManager.mapControl.GetX(entity.longitude)+8;if(x>w-200){x-=217;}var p=VE_SearchManager.popup;p.SetColor(color);p.SetTitle(entity.name);p.SetBody(tb);p.Show();p.height=VE_SearchManager.GetPopupBodyHeight()+p.toolbarHeight+p.footerHeight+34;var y=VE_SearchManager.mapControl.GetY(entity.latitude)-11;if(y>VE_SearchManager.panelParentHeight-p.height-10){y-=p.height-20;}p.SetPosition(x,y,180,80);p.Resize();}
VE_SearchManager.GetPopupBodyHeight=function(){var e=document.getElementById("searchPopup_body").getElementsByTagName("table");var bh=0;if(e!=null&&e.length>0){for(var i=0;i<e.length;i++){bh+=e[i].offsetHeight;}}return bh;}
VE_SearchManager.CloseSearchPopup=function(){var p=VE_SearchManager.popup;if(p){p.Hide();}VE_SearchManager._RestorePushpinZIndex();VE_SearchManager.popupPushpin=null;VE_SearchManager.popupEntity=null;}
VE_SearchManager._RestorePushpinZIndex=function(){if(!VE_SearchManager.popupPushpin){return;}VE_SearchManager.popupPushpin.style.zIndex=VE_SearchManager.popupPushpinOrigZIndex;}
VE_SearchManager._GenerateDrivingDirectionsUrl=function(paramNum,name,description,lat,lon){var separator=description?"%20-%20":"";return directionsUrl.replace(/\{0\}/g,directionsDomain).replace(/\{1\}/g,paramNum).replace(/\{2\}/,name+separator+description).replace(/\{3\}/,lat).replace(/\{4\}/,lon);}
function VE_SearchResult(id,name,description,phone,rating,type,latitude,longitude){this.id=id;this.name=name;this.description=description;this.phone=phone;this.rating=rating;this.type=type;this.latitude=latitude;this.longitude=longitude;this.pushPin=null;}
VE_SearchResult.prototype.GetSerializedId=function(){switch(this.type){case"al":return"";case"adr":return"adr"+"."+this.name;default:return this.type+"."+this.id.toString();}}
var map;
function VE_MapSearchControl(latitude,longitude,zoomLevel,mapStyle,
	position,x,y,width,height,searchPage,adsPage)
{
	if(height<410)height=410;
	if(width<500)width=500;
	this.index=VE_MapSearchControl.controlList.length;
	this.latitude=latitude;
	this.longitude=longitude;
	this.preferredLatitude=latitude;
	this.preferredLongitude=longitude;this.offsetLeft=0;this.offsetTop=0;
	this.zoomLevel=this._ValidateZoomLevel(latitude,longitude,zoomLevel);
	this.prevZoomLevel=this.zoomLevel;
	this.mapStyle=this._ValidateMapStyle(mapStyle);
	this.x=x;this.y=y;this.width=width;this.height=height;
	this.tileWidth=0;this.tileHeight=0;this.dragging=false;
	this.dragPan=false;this.panLatitude=null;this.panLongitude=null;
	this.keyboardPan=false;this.tiles=new Array();this.oldTiles=null;
	this.unusedTiles=new Array();this.lastMouseX=0;this.lastMouseY=0;
	this.originX=0;this.originY=0;this.zoomCounter=0;this.zooming=false;
	this.panning=false;this.panCounter=0;this.panningX=0;this.panningY=0;
	this.debug=false;this.onMouseClick=null;this.onMouseDown=null;
	this.onMouseUp=null;this.onStartContinuousPan=null;
	this.onEndContinuousPan=null;this.onStartZoom=null;
	this.onEndZoom=null;this.pushpins=new Array();
	this.unusedPushpins=new Array();this.lastWhere="";
	this.element=document.createElement("div");
	this.element.style.padding="0px";this.element.style.margin="0px";
	this.element.style.position=position;this.element.style.left=x+"px";
	this.element.style.top=y+"px";this.element.style.width=width;
	this.element.style.height=height;
	this.mapElement=document.createElement("div");
	this.mapElement.id="veMapControl";
	this.mapElement.style.overflow="hidden";
	this.mapElement.style.padding="0px";
	this.mapElement.style.margin="0px";
	this.mapElement.style.position="absolute";
	this.mapElement.style.left="0px";this.mapElement.style.top="0px";
	this.mapElement.style.width=width;this.mapElement.style.height=height;
	this.mapElement.style.zIndex=VE_MapSearchControl.containerZIndex;
	this.element.appendChild(this.mapElement);
	this.map=document.createElement("div");
	this.map.style.position="absolute";this.map.style.top="0px";
	this.map.style.left="0px";this.map.style.padding="0";
	this.map.style.margin="0";
	this.map.style.zIndex=VE_MapSearchControl.mapZIndex;
	this.mapElement.appendChild(this.map);
	this.keyboard=document.createElement("input");
	this.keyboard.style.position="absolute";this.keyboard.style.top="0px";
	this.keyboard.style.left="0px";this.keyboard.style.width="1px";
	this.keyboard.style.height="1px";this.keyboard.style.padding="0";
	this.keyboard.style.margin="0";this.keyboard.style.zIndex=VE_MapSearchControl.kbInputZIndex;this.keyboard.onkeydown=VE_MapSearchControl._KeyDown;this.keyboard.onkeyup=VE_MapSearchControl._KeyUp;this.mapElement.appendChild(this.keyboard);var header=document.createElement("div");header.id="search_bg";header.style.position="absolute";header.style.top="0px";header.style.left="0px";header.style.width=width+"px";header.style.height="40px";header.style.padding="5px";this.header=header;header.innerHTML='<form id="f" name="f" action="about:blank" method="get" target="hiddenframe" onsubmit="map.Search();return false;"><label class="helperTxt" for="what" size="25">What</label> <input type="text" id="what" maxlength="100"> <label class="helperTxt" for="where">Where</label> <input type="text" id="where" size="25" maxlength="100" style="color:#333333" onFocus="if(this.value==useCurrentViewText){this.value=\'\';this.style.color=\'black\';SelectText(this,0,0);}" onBlur="if(this.value==\'\'){this.value=useCurrentViewText;this.style.color=\'#333333\';}" onDrop="this.value=\'\';this.style.color=\'black\';SelectText(this,0,0);"> <input type="submit" id="searchbttn" name="submit" style="width:60px" value="Search"></form>';this.element.appendChild(header);var hiddenFrame=document.createElement("iframe");hiddenFrame.id="hiddenframe";hiddenFrame.setAttribute("name","hiddenframe");hiddenFrame.style.width="1px";hiddenFrame.style.height="1px";hiddenFrame.style.zIndex=0;this.element.appendChild(hiddenFrame);var whereAmbigList=document.createElement("div");whereAmbigList.id="whereambiglist";whereAmbigList.onlosecapture=HideAmbiguousList;whereAmbigList.onkeydown=keydown_Go;this.element.appendChild(whereAmbigList);var c=new VE_MessageControl();VE_MessageControl._Reposition(220,50,width-220-5);this.element.appendChild(c);var zoomBarElement=VE_ZoomControl.Create(5,50,zoomLevel,"absolute",this);this.element.appendChild(zoomBarElement);this.onStartContinuousPan=function(e){VE_SearchManager._CancelAllRequests();VE_SearchManager.CloseSearchPopup();};this.onEndContinuousPan=function(e){var where=document.f.where;if(where.value!=useCurrentViewText){where.value=useCurrentViewText;where.style.color="#333333";lastWhere="";}VE_SearchManager.RefreshAll();};this.onStartZoom=function(e){VE_SearchManager._CancelAllRequests();VE_SearchManager.CloseSearchPopup();};this.onEndZoom=function(e){VE_SearchManager.RefreshAll();};var msControl=VE_SimpleMapStyleControl.Create(this,62,50);this.element.appendChild(msControl.element);var siteLink=new VE_SiteLink();this.element.appendChild(siteLink.siteLinkElement);siteLink._RepositionSiteLink(height);this.siteLink=siteLink;this._CreateTermsOfUse();var hiddenFrame=document.createElement("iframe");hiddenFrame.id="hiddensearchframe";hiddenFrame.setAttribute("name","hiddensearchframe");hiddenFrame.style.width="1px";hiddenFrame.style.height="1px";hiddenFrame.style.zIndex=0;this.element.appendChild(hiddenFrame);VE_SearchManager.mapControl=this;VE_SearchManager.panelOffsetHeight=90;VE_SearchManager.panelParentElement=this.element;VE_SearchManager.panelParentWidth=width;VE_SearchManager.panelParentHeight=height;VE_SearchManager.whatElementId="what"+this.index;
	VE_SearchManager.searchPage=searchPage;
	VE_SearchManager.adsPage=adsPage;
	this._CreateScaleBar();
	this._CreateCopyright();this._SetBackgroundColor();
	this.SetCenterAndZoom(latitude,longitude,zoomLevel);
	VE_MapSearchControl.controlList.push(this);
}
VE_MapSearchControl.CleanupOnExit=function(){if(map){map.Destroy();}}
VE_MapSearchControl.Create=function(latitude,longitude,zoomLevel,mapStyle,position,x,y,width,height,searchPage,adsPage)
{
	if(map){map.Destroy();}
	map=new VE_MapSearchControl(latitude,longitude,zoomLevel,mapStyle,position,x,y,width,height,searchPage,adsPage);
	return map;
}

VE_MapSearchControl.prototype.Destroy=function(){this.control=null;this.header=null;this.onStartContinuousPan=null;this.onEndContinuousPan=null;this.onStartZoom=null;this.onEndZoom=null;this.siteLink=null;VE_SearchManager.mapControl=null;VE_SearchManager.panelParentElement=null;this.mapElement=null;this.map=null;this.keyboard=null;if(this.element.parentNode){this.element.parentNode.removeChild(this.element);}this.element=null;}
VE_MapSearchControl.prototype.SetCenter=function(latitude,longitude){this.SetCenterAndZoom(latitude,longitude,this.zoomLevel);}
VE_MapSearchControl.prototype.SetMapStyle=function(mapStyle){if(this.panning||this.zooming){return;}mapStyle=this._ValidateMapStyle(mapStyle);if(this.mapStyle!=mapStyle){this.mapStyle=mapStyle;this._SetBackgroundColor();this.latitude=this.GetCenterLatitude();this.longitude=this.GetCenterLongitude();this._StartMap();this._RepositionPushpins();this._UpdateCopyright();}}
VE_MapSearchControl.prototype._ValidateMapStyle=function(s){if(s=='a'||s=='h')return s;else return'r';}
VE_MapSearchControl.prototype._SetBackgroundColor=function(){var bg="#f2ede4";if(this.mapStyle=='a'||this.mapStyle=='h')bg="#404040";this.mapElement.style.background=bg;}
VE_MapSearchControl.prototype.GetCenterLatitude=function(){return this.latitude;}
VE_MapSearchControl.prototype.GetCenterLongitude=function(){return this.longitude;}
VE_MapSearchControl.prototype._ComputeCenterPoint=function(capture){this.latitude=this.GetLatitude(this.height/2);this.longitude=this.GetLongitude(this.width/2);if(capture){this.preferredLatitude=this.latitude;this.preferredLongitude=this.longitude;}}
VE_MapSearchControl.prototype.GetLatitude=function(y){return this._YToLat(this.originY+this.offsetY+y);}
VE_MapSearchControl.prototype.GetLongitude=function(x){return this._XToLon(this.originX+this.offsetX+x);}
VE_MapSearchControl.prototype.GetY=function(latitude){return this._LatToY(latitude)-this.originY-this.offsetY;}
VE_MapSearchControl.prototype.GetX=function(longitude){return this._LonToX(longitude)-this.originX-this.offsetX;}
VE_MapSearchControl.prototype.GetZoomLevel=function(){return this.zoomLevel;}
VE_MapSearchControl.prototype.GetMapStyle=function(){return this.mapStyle;}
VE_MapSearchControl.prototype.GetMetersPerPixel=function(latitude,zoomLevel){if(!latitude){latitude=this.latitude;}if(!zoomLevel){zoomLevel=this.zoomLevel;}return Math.cos(DegToRad(latitude))*this._MetersPerPixel(zoomLevel);}
VE_MapSearchControl.prototype.Resize=function(width,height){if(!width||!height||width<=0||height<=0){return;}if(height<410)height=410;if(width<500)width=500;this.header.style.width=width+"px";this.width=width;this.height=height;this.element.style.width=width;this.element.style.height=height;this.mapElement.style.width=width;this.mapElement.style.height=height;this.PanToLatLong(this.latitude,this.longitude);this._RepositionScaleBar();this._RepositionCopyright();VE_SearchManager.panelParentWidth=width;VE_SearchManager.panelParentHeight=height;VE_SearchManager.ResizePanels();this.siteLink._RepositionSiteLink(height);this._RepositionTermsOfUse();VE_MessageControl._Reposition(220,50,width-220-5);}
VE_MapSearchControl.prototype._ClearTiles=function(){var t=this.tiles;var u=this.unusedTiles;var m=this.map;if(!t||t.length==0)return;while(t.length>0){var tile=t.pop();tile.RemoveFromMap();tile.img.src=VE_MapSearchControl.emptyTile;u.push(tile);}}
VE_MapSearchControl.prototype._TileSize=function(){return 256;}
VE_MapSearchControl.prototype._StartMap=function(){this._ClearTiles();var m=this.map;m.style.top="0px";m.style.left="0px";this.originX=Math.round(this._LonToXAtZ(this.longitude,this.zoomLevel)-this.width/2);this.originY=Math.round(this._LatToYAtZ(this.latitude,this.zoomLevel)-this.height/2);this.offsetX=0;this.offsetY=0;var s=this._TileSize();var ox=this.originX;var oy=this.originY;var b=VE_MapSearchControl.buffer;var w=this.width;var h=this.height;var x1=Math.floor((ox-b)/s);var y1=Math.floor((oy-b)/s);var x2=Math.floor((ox+w+b)/s);var y2=Math.floor((oy+h+b)/s);x1=Math.max(0,x1);y1=Math.max(0,y1);for(var x=x1;x<=x2;x++)for(var y=y1;y<=y2;y++){this._RequestTile(x,y,this.zoomLevel,s,this.mapStyle);}}
VE_MapSearchControl.prototype._UpdateMap=function(){var m=this.map;var s=this._TileSize();var ox=this.originX+this.offsetX;var oy=this.originY+this.offsetY;var w=this.width;var h=this.height;var b=VE_MapSearchControl.buffer;var t=this.tiles;var x1=Math.floor((ox-b)/s);var y1=Math.floor((oy-b)/s);var x2=Math.floor((ox+w+b)/s);var y2=Math.floor((oy+h+b)/s);var oldx1=0;var oldy1=0;var oldx2=0;var oldy2=0;var first=true;var newTiles=new Array();for(var i=0;i<t.length;i++){var tile=t[i];var x=tile.tx;var y=tile.ty;if(x<x1||x>x2||y<y1||y>y2){tile.RemoveFromMap();}else{if(first){oldx1=x;oldy1=y;oldx2=x;oldy2=y;first=false;}else{oldx1=Math.min(oldx1,x);oldy1=Math.min(oldy1,y);oldx2=Math.max(oldx2,x);oldy2=Math.max(oldy2,y);}newTiles.push(tile);}}this.tiles=newTiles;x1=Math.max(0,x1);y1=Math.max(0,y1);for(var x=x1;x<=x2;x++)for(var y=y1;y<=y2;y++){if(x<oldx1||x>oldx2||y<oldy1||y>oldy2)this._RequestTile(x,y,this.zoomLevel,s,this.mapStyle);}}
VE_MapSearchControl.prototype.Search=function(what,where){if(what==null){what=document.f.what.value;}if(where==null){where=document.f.where.value;}if(where==useCurrentViewText||where==this.lastWhere){where="";}else{if(where){this.lastWhere=where;}}if(what==""&&where==""){return;}HideAmbiguousList();VE_SearchManager.CloseSearchPopup();VE_SearchManager.Search(what,where);}
;
VE_MapSearchControl.prototype.RemoveSearch=function(){if(VE_SearchManager.searches.length==0){return;}VE_SearchManager._RemoveSearch(VE_SearchManager.searches[0].index);}
;
VE_MapSearchControl.worldBounds={z:1,x1:0,y1:0,x2:2,y2:2}
;
VE_MapSearchControl.usaBounds={z:10,x1:172,y1:356,x2:332,y2:444}
;
VE_MapSearchControl.prototype._GetBounds=function(zoom){if(zoom>=VE_MapSearchControl.usaBounds.z)return VE_MapSearchControl.usaBounds;return VE_MapSearchControl.worldBounds;}
VE_MapSearchControl.prototype._ClipDeltaX=function(deltaX){var b=this._GetBounds(this.zoomLevel);return this._ClipDelta(deltaX,this.width,this.originX+this.offsetX,b.z,b.x1,b.x2);}
VE_MapSearchControl.prototype._ClipDeltaY=function(deltaY){var b=this._GetBounds(this.zoomLevel);return this._ClipDelta(deltaY,this.height,this.originY+this.offsetY,b.z,b.y1,b.y2);}
VE_MapSearchControl.prototype._ClipDelta=function(delta,size,offset,bz,b1,b2){var z=this.zoomLevel;var s=this._TileSize();var min=s*(b1<<(z-bz));var max=s*(b2<<(z-bz));if(size>(max-min)){return((max-min-size)/2)-offset+min;}else if(offset+delta<min){return min-offset;}else if(offset+size+delta>max){return max-offset-size;}return delta;}
VE_MapSearchControl.prototype._ClipLatitude=function(latitude,zoom){var y=this._LatToYAtZ(latitude,zoom);var b=this._GetBounds(zoom);y=this._ClipAbsolute(y,zoom,this.height,b.z,b.y1,b.y2);return this._YToLatAtZ(y,zoom);}
VE_MapSearchControl.prototype._ClipLongitude=function(longitude,zoom){var x=this._LonToXAtZ(longitude,zoom);var b=this._GetBounds(zoom);x=this._ClipAbsolute(x,zoom,this.width,b.z,b.x1,b.x2);return this._XToLonAtZ(x,zoom);}
VE_MapSearchControl.prototype._ClipAbsolute=function(abs,z,size,bz,b1,b2){var s=this._TileSize();var min=s*(b1<<(z-bz));var max=s*(b2<<(z-bz));var half=size/2;if(size>max-min){return(max-min)/2;}else if(abs<min+half){return min+half;}else if(abs+half>max){return max-half;}return abs;}
VE_MapSearchControl.prototype._ValidateZoomLevel=function(latitude,longitude,z){if(z<VE_MapSearchControl.minZoom){return VE_MapSearchControl.minZoom;}if(z<VE_MapSearchControl.usaBounds.z){return z;}var y=this._LatToYAtZ(latitude,z);var x=this._LonToXAtZ(longitude,z);var b=VE_MapSearchControl.usaBounds;var s=this._TileSize();var minX=s*(b.x1<<(z-b.z));var maxX=s*(b.x2<<(z-b.z));var minY=s*(b.y1<<(z-b.z));var maxY=s*(b.y2<<(z-b.z));if(minX<x&&x<maxX&&minY<y&&y<maxY){return Math.min(VE_MapSearchControl.maxZoom,z);}else{return Math.min(VE_MapSearchControl.usaBounds.z-1,z);}}
VE_MapSearchControl.GetMouseX=function(e){var posX=0;if(e.pageX){posX=e.pageX;}else if(e.clientX){posX=e.clientX+document.body.scrollLeft;}return posX;}
VE_MapSearchControl.GetMouseY=function(e){var posY=0;if(e.pageY){posY=e.pageY;}else if(e.clientY){posY=e.clientY+document.body.scrollTop;}return posY;}
VE_MapSearchControl.GetMouseScrollDelta=function(e){if(e.wheelDelta){return e.wheelDelta;}else if(e.detail){return-e.detail;}return 0;}
VE_MapSearchControl.GetTarget=function(e){if(!e)e=window.event;var t=null;if(e.srcElement)t=e.srcElement;else if(e.target)t=e.target;if(t.nodeType==3)t=targ.parentNode;return t;}
VE_MapSearchControl.GetElementX=function(e){var x=0;while(e){x+=e.offsetLeft;e=e.offsetParent;}if(navigator.userAgent.indexOf("Mac")!=-1&&typeof(document.body.leftMargin)!="undefined"){x+=document.body.leftMargin;}return x;}
VE_MapSearchControl.GetElementY=function(e){var y=0;while(e){y+=e.offsetTop;e=e.offsetParent;}if(navigator.userAgent.indexOf("Mac")!=-1&&typeof(document.body.topMargin)!="undefined"){y+=document.body.topMargin;}return y;}
VE_MapSearchControl.prototype._CreateCopyright=function(){var bg=document.createElement("div");bg.unselectable="on";with(bg.style){position="absolute";width="230px";height="28px";top="1px";left="1px";zIndex=30;color="Black";display="none";font="7pt Verdana";textAlign="right";cursor="pointer";}var fg=document.createElement("div");fg.unselectable="on";with(fg.style){position="absolute";width="230px";height="28px";top="0px";left="0px";zIndex=31;color="White";display="none";font="7pt Verdana";textAlign="right";cursor="pointer";}this.copyrightBg=bg;this.copyrightFg=fg;this._RepositionCopyright();this.element.appendChild(bg);this.element.appendChild(fg);}
VE_MapSearchControl.prototype._RepositionCopyright=function(){with(this.copyrightBg.style){top=(this.height-28)+"px";left=(this.width-240)+"px";display="block";}with(this.copyrightFg.style){top=(this.height-29)+"px";left=(this.width-241)+"px";display="block";}}
VE_MapSearchControl.prototype._UpdateCopyright=function(){var z=this.zoomLevel;var s=this.mapStyle;var c="&copy; 2005 Microsoft Corp";if(z>=5&&(s=="r"||s=="h")){c+=" &nbsp; &copy; 2004 NAVTEQ";}if(s=="h"||s=="a"){c+="<br>Image courtesy of ";if(z<=9){c+="NASA";}else{c+="USGS";}}this.copyrightBg.innerHTML=c;this.copyrightFg.innerHTML=c;this._RepositionCopyright();}
VE_MapSearchControl.prototype._MetersPerPixel=function(zl){return VE_MapSearchControl.baseMetersPerPixel/(1<<zl);}
VE_MapSearchControl.prototype._XToLonAtZ=function(x,zl){var metersPerPixel=this._MetersPerPixel(zl);var metersX=x*metersPerPixel-VE_MapSearchControl.offsetMeters;return RadToDeg(metersX/VE_MapSearchControl.earthRadius);}
VE_MapSearchControl.prototype._LonToXAtZ=function(longitude,zl){var metersX=VE_MapSearchControl.earthRadius*DegToRad(longitude);var metersPerPixel=this._MetersPerPixel(zl);return Math.round((metersX+VE_MapSearchControl.offsetMeters)/metersPerPixel);}
VE_MapSearchControl.prototype._YToLatAtZ=function(y,zl){var metersPerPixel=this._MetersPerPixel(zl);var metersY=VE_MapSearchControl.offsetMeters-y*metersPerPixel;return RadToDeg(Math.PI/2-2*Math.atan(Math.exp(-metersY/VE_MapSearchControl.earthRadius)));}
VE_MapSearchControl.prototype._LatToYAtZ=function(latitude,zl){var sinLat=Math.sin(DegToRad(latitude));var metersY=VE_MapSearchControl.earthRadius/2*Math.log((1+sinLat)/(1-sinLat));var metersPerPixel=this._MetersPerPixel(zl);return Math.round((VE_MapSearchControl.offsetMeters-metersY)/metersPerPixel);}
VE_MapSearchControl.prototype._XToLon=function(x){return this._XToLonAtZ(x,this.zoomLevel);}
VE_MapSearchControl.prototype._LonToX=function(longitude){return this._LonToXAtZ(longitude,this.zoomLevel);}
VE_MapSearchControl.prototype._YToLat=function(y){return this._YToLatAtZ(y,this.zoomLevel);}
VE_MapSearchControl.prototype._LatToY=function(latitude){return this._LatToYAtZ(latitude,this.zoomLevel);}
VE_MapSearchControl.prototype._XToXAtZ=function(x,z1,z2){var lon=this._XToLonAtZ(x,z1);return this._LonToXAtZ(lon,z2);}
VE_MapSearchControl.prototype._YToYAtZ=function(y,z1,z2){var lat=this._YToLatAtZ(y,z1);return this._LatToYAtZ(lat,z2);}
function DegToRad(d){return d*Math.PI/180.0;}
function RadToDeg(r){return r*180.0/Math.PI;}
VE_MapSearchControl.prototype.Debug=function(enabled){var t=this.tiles;for(var i=0;i<t.length;i++){t[i].img.style.border=enabled?"1px dashed red":"0";if(enabled){this.map.appendChild(t[i].overlay);}else{if(t[i].overlay.parentNode==this.map){this.map.removeChild(t[i].overlay);}}}var u=this.unusedTiles;for(var i=0;i<u.length;i++){u[i].img.style.border=enabled?"1px dashed red":"0";}this.debug=enabled;}
function VE_MapEvent(srcMapControl,latitude,longitude,zoomLevel){this.srcMapControl=srcMapControl;this.latitude=latitude;this.longitude=longitude;this.zoomLevel=zoomLevel;}
VE_MapSearchControl.prototype._CreateEvent=function(latitude,longitude,zoomLevel){if(!latitude)latitude=this.GetCenterLatitude();if(!longitude)longitude=this.GetCenterLongitude();if(!zoomLevel)zoomLevel=this.zoomLevel;return new VE_MapEvent(this,latitude,longitude,this.zoomLevel);}
VE_MapSearchControl.prototype._CallMouseDown=function(e){if(!e)e=this._CreateEvent();if(this.onMouseDown)this.onMouseDown(e);}
VE_MapSearchControl.prototype._CallMouseUp=function(e){if(!e)e=this._CreateEvent();if(this.onMouseUp)this.onMouseUp(e);}
VE_MapSearchControl.prototype._CallMouseClick=function(e){if(!e)e=this._CreateEvent();if(this.onMouseClick)this.onMouseClick(e);}
VE_MapSearchControl.prototype._CallStartContinuousPan=function(e){if(!e)e=this._CreateEvent();if(this.onStartContinuousPan)this.onStartContinuousPan(e);}
VE_MapSearchControl.prototype._CallEndContinuousPan=function(e){if(!e)e=this._CreateEvent();if(this.onEndContinuousPan)this.onEndContinuousPan(e);}
VE_MapSearchControl.prototype._CallStartZoom=function(e){if(!e)e=this._CreateEvent();if(this.onStartZoom)this.onStartZoom(e);}
VE_MapSearchControl.prototype._CallEndZoom=function(e){if(!e)e=this._CreateEvent();if(this.onEndZoom)this.onEndZoom(e);}
VE_MapSearchControl.controlList=new Array();
VE_MapSearchControl.altitudes=[2000,500,150,50,25,12,6,3,1];
VE_MapSearchControl.scaledRadius=5429123.84;
VE_MapSearchControl.buffer=100;
VE_MapSearchControl.dragElement=null;
VE_MapSearchControl.dragControl=null;
VE_MapSearchControl.animatedMovementEnabled=1;
VE_MapSearchControl.zoomTotalSteps=5;
VE_MapSearchControl.tileUrlPrefixes=["http://tiles0.virtualearth.msn.com/tiles/","http://tiles1.virtualearth.msn.com/tiles/","http://tiles2.virtualearth.msn.com/tiles/","http://tiles3.virtualearth.msn.com/tiles/"];
VE_MapSearchControl.tileVersion=1;
VE_MapSearchControl.keyboardPanSpeed=15;
VE_MapSearchControl.panToLatLongSpeed=15;
VE_MapSearchControl.earthRadius=6378137;
VE_MapSearchControl.minZoom=1;
VE_MapSearchControl.maxZoom=19;
VE_MapSearchControl.requests=new Array();
VE_MapSearchControl.offsetMeters=20971520;
VE_MapSearchControl.baseMetersPerPixel=163840;
VE_MapSearchControl.emptyTile="i/spacer.gif";
VE_MapSearchControl.minLatitude=-85;
VE_MapSearchControl.maxLatitude=85;
VE_MapSearchControl.minLongitude=-180;
VE_MapSearchControl.maxLongitude=180;
VE_MapSearchControl.kbInputZIndex=0;
VE_MapSearchControl.containerZIndex=0;
VE_MapSearchControl.mapZIndex=1;
VE_MapTile.baseZIndex=2;
VE_MapTile.swapZIndex=1;
VE_MapTile.debugZIndex=3;
VE_MapPushpin.baseZIndex=11;
VE_MapPushpin.topZIndex=20;
VE_MapSearchControl.FindControlByInput=function(input){var c=VE_MapSearchControl.controlList;for(var i=0;i<c.length;i++){if(c[i].keyboard==input)return c[i];}return null;}
VE_MapSearchControl._KeyDown=function(e){if(!e)var e=window.event;var t=VE_MapSearchControl.GetTarget(e);var c=VE_MapSearchControl.FindControlByInput(t);var s=VE_MapSearchControl.keyboardPanSpeed;var x=c.panningX;var y=c.panningY;switch(e.keyCode){case 9:if(c.panning&&c.keyboardPan){c.StopContinuousPan();}return true;case 37:x=-s;break;case 38:y=-s;break;case 39:x=s;break;case 40:y=s;break;case 107:case 187:case 61:case 43:x=0;y=0;c.ZoomIn();break;case 109:case 189:x=0;y=0;c.ZoomOut();break;default:return false;}if(x||y)c.ContinuousPan(x,y,null,true);return false;}
VE_MapSearchControl._KeyUp=function(e){if(!e)var e=window.event;var t=VE_MapSearchControl.GetTarget(e);var c=VE_MapSearchControl.FindControlByInput(t);var s=VE_MapSearchControl.keyboardPanSpeed;var x=c.panningX;var y=c.panningY;switch(e.keyCode){case 37:x=0;break;case 38:y=0;break;case 39:x=0;break;case 40:y=0;break;default:return false;}c.ContinuousPan(x,y,null,true);return false;}
VE_MapSearchControl.prototype._CreateTermsOfUse=function(){var tosUrl="http://go.microsoft.com/fwlink/?LinkID=52388";var privacyUrl="http://go.microsoft.com/fwlink/?LinkID=52395";var bg=document.createElement("div");bg.unselectable="on";bg.innerHTML='<a href="javascript:OpenNewWindow(\''+tosUrl+'\', \'veTOS\', \'all\')">Terms of Use</a>&nbsp;<a href="javascript:OpenNewWindow(\''+privacyUrl+'\', \'vePrivacy\', \'all\')">Privacy Statement</a>';bg.className="VE_Legal VE_Legal_BG";with(bg.style){position="absolute";top="1px";left="1px";zIndex=30;color="Black";display="none";font="7pt Verdana";textAlign="right";}var fg=document.createElement("div");fg.unselectable="on";fg.innerHTML='<a href="javascript:OpenNewWindow(\''+tosUrl+'\', \'veTOS\', \'all\')">Terms of Use</a>&nbsp;<a href="javascript:OpenNewWindow(\''+privacyUrl+'\', \'vePrivacy\', \'all\')">Privacy Statement</a>';fg.className="VE_Legal VE_Legal_FG";with(fg.style){position="absolute";top="0px";left="0px";zIndex=31;color="White";display="none";font="7pt Verdana";textAlign="right";}this.legalBg=bg;this.legalFg=fg;this._RepositionTermsOfUse();this.element.appendChild(bg);this.element.appendChild(fg);}
VE_MapSearchControl.prototype._RepositionTermsOfUse=function(){with(this.legalBg.style){top=(this.height-18)+"px";left="10px";display="block";}with(this.legalFg.style){top=(this.height-19)+"px";left="9px";display="block";}}
function VE_SimpleMapStyleControl(x,y){var container=document.createElement("table");container.style.position="absolute";container.style.left=x+"px";container.style.top=y+"px";container.style.zIndex=31;container.cellSpacing=1;container.cellPadding=0;container.id="VE_MapStyleSelector";var contentRow=container.insertRow(0);var contentCell=contentRow.insertCell(0);contentCell.id="VE_MapStyleContent";var road=document.createElement("a");road.href="javascript:VE_SimpleMapStyleControl.SetMapStyleToRoad()";road.className="VE_MapStyleLink";road.oncontextmenu=function(){return false;};road.innerHTML="Road";contentCell.appendChild(road);contentCell.appendChild(document.createTextNode(" | "));var aerial=document.createElement("a");aerial.href="javascript:VE_SimpleMapStyleControl.SetMapStyleToAerial()";aerial.className="VE_MapStyleLink";aerial.oncontextmenu=function(){return false;};aerial.innerHTML="Aerial";contentCell.appendChild(aerial);contentCell.appendChild(document.createTextNode(" | "));var hybrid=document.createElement("a");hybrid.href="javascript:VE_SimpleMapStyleControl.SetMapStyleToHybrid()";hybrid.className="VE_MapStyleLink";hybrid.oncontextmenu=function(){return false;};hybrid.innerHTML="Hybrid";contentCell.appendChild(hybrid);this.road=road;this.hybrid=hybrid;this.aerial=aerial;this.element=container;}
VE_SimpleMapStyleControl.Create=function(mapControl,x,y){VE_SimpleMapStyleControl.mapControl=mapControl;VE_SimpleMapStyleControl.control=new VE_SimpleMapStyleControl(x,y);switch(mapControl.GetMapStyle()){case"h":VE_SimpleMapStyleControl.SetMapStyleToHybrid();break;case"a":VE_SimpleMapStyleControl.SetMapStyleToAerial();break;case"r":default:VE_SimpleMapStyleControl.SetMapStyleToRoad();break;}return VE_SimpleMapStyleControl.control;}
VE_SimpleMapStyleControl.SetElementToSelected=function(element){element.className="VE_MapStyleLinkSel";}
;
VE_SimpleMapStyleControl.SetElementToUnselected=function(element){element.className="VE_MapStyleLink";}
;
VE_SimpleMapStyleControl.SetMapStyleToRoad=function(){VE_SimpleMapStyleControl.mapControl.SetMapStyle("r");VE_SimpleMapStyleControl.SetElementToSelected(VE_SimpleMapStyleControl.control.road);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.hybrid);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.aerial);}
;
VE_SimpleMapStyleControl.SetMapStyleToAerial=function(){VE_SimpleMapStyleControl.mapControl.SetMapStyle("a");VE_SimpleMapStyleControl.SetElementToSelected(VE_SimpleMapStyleControl.control.aerial);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.hybrid);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.road);}
;
VE_SimpleMapStyleControl.SetMapStyleToHybrid=function(){VE_SimpleMapStyleControl.mapControl.SetMapStyle("h");VE_SimpleMapStyleControl.SetElementToSelected(VE_SimpleMapStyleControl.control.hybrid);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.road);VE_SimpleMapStyleControl.SetElementToUnselected(VE_SimpleMapStyleControl.control.aerial);}
;
VE_MapSearchControl._MouseDown=function(e){if(!e)e=window.event;e.cancelBubble=true;var t=VE_MapSearchControl.GetTarget(e);var c=VE_MapSearchControl.FindControlByTileImage(t);if(!c||c.zooming){return false;}c.offsetLeft=VE_MapSearchControl.GetElementX(c.element);c.offsetTop=VE_MapSearchControl.GetElementY(c.element);if(c.panning){c.StopContinuousPan();}c.keyboard.focus();c.dragging=true;c.dragPan=false;c.lastMouseX=VE_MapSearchControl.GetMouseX(e);c.lastMouseY=VE_MapSearchControl.GetMouseY(e);t.style.cursor="move";if(t.setCapture)t.setCapture();VE_MapSearchControl.dragElement=t;VE_MapSearchControl.dragControl=c;c._CallStartContinuousPan();return false;}
VE_MapSearchControl._MouseUp=function(e){if(!e)e=window.event;if(VE_MapSearchControl.dragElement){var c=VE_MapSearchControl.dragControl;if(!c){return false;}c.dragging=false;c._ComputeCenterPoint(true);VE_MapSearchControl.dragElement.style.cursor="pointer";if(VE_MapSearchControl.dragElement.releaseCapture)VE_MapSearchControl.dragElement.releaseCapture();if(c.dragPan)c._CallEndContinuousPan();c.dragPan=false;var x=VE_MapSearchControl.GetMouseX(e)-c.offsetLeft;var y=VE_MapSearchControl.GetMouseY(e)-c.offsetTop;c._CallMouseClick(c._CreateEvent(c.GetLatitude(y),c.GetLongitude(x)));}return false;}
VE_MapSearchControl._MouseDoubleClick=function(e){if(!e)e=window.event;var c=VE_MapSearchControl.dragControl;if(!c||c.panning||c.zooming){return false;}var lat=c.GetLatitude(VE_MapSearchControl.GetMouseY(e)-c.offsetTop);var lon=c.GetLongitude(VE_MapSearchControl.GetMouseX(e)-c.offsetLeft);if(e.altKey){if(c.zoomLevel==VE_MapSearchControl.minZoom)c.PanToLatLong(lat,lon);else c.SetCenterAndZoom(lat,lon,c.zoomLevel-1);}else{if(c.zoomLevel+1!=c._ValidateZoomLevel(lat,lon,c.zoomLevel+1))c.PanToLatLong(lat,lon);else c.SetCenterAndZoom(lat,lon,c.zoomLevel+1);}return false;}
VE_MapSearchControl._MouseMove=function(e){if(!e)e=window.event;if(VE_MapSearchControl.dragElement){var c=VE_MapSearchControl.dragControl;if(!c){return false;}if(c.dragging){var x=VE_MapSearchControl.GetMouseX(e);var y=VE_MapSearchControl.GetMouseY(e);c.PanMap(c.lastMouseX-x,c.lastMouseY-y);c.lastMouseX=x;c.lastMouseY=y;c.dragPan=true;if(e.cancelBubble)e.cancelBubble=true;}}return false;}
VE_MapSearchControl._MouseWheel=function(e){if(!e)e=window.event;var t=VE_MapSearchControl.GetTarget(e);var c=VE_MapSearchControl.FindControlByTileImage(t);if(!c||c.panning||c.zooming){return false;}var delta=VE_MapSearchControl.GetMouseScrollDelta(e);if(delta>0){c.ZoomIn();}else if(delta<0){c.ZoomOut();}e.cancelBubble=true;return false;}
VE_MapSearchControl._ContextMenu=function(e){if(!e)e=window.event;e.cancelBubble=true;var t=VE_MapSearchControl.GetTarget(e);var c=VE_MapSearchControl.FindControlByTileImage(t);if(!c||c.debug){return true;}return false;}
VE_MapSearchControl.prototype.PanMap=function(deltaX,deltaY){if(deltaX==0&&deltaY==0){return;}deltaX=this._ClipDeltaX(deltaX);deltaY=this._ClipDeltaY(deltaY);this.offsetX+=deltaX;this.offsetY+=deltaY;this.map.style.top=-this.offsetY+"px";this.map.style.left=-this.offsetX+"px";this._UpdateMap(deltaX,deltaY);this._UpdateCopyright();}
VE_MapSearchControl.prototype.ContinuousPan=function(deltaX,deltaY,count,keyboardPan){if(this.zooming){return;}if(!count){count=-1;}this.panningX=deltaX;this.panningY=deltaY;this.panCounter=count;if(!deltaX&&!deltaY){this.StopContinuousPan();return;}this.keyboardPan=keyboardPan;if(!this.panning){this.panning=true;VE_MapSearchControl._StepPan(this.index);this._CallStartContinuousPan();}}
VE_MapSearchControl._StepPan=function(controlIndex){var c=VE_MapSearchControl.controlList[controlIndex];if(c.panning){c.PanMap(c.panningX,c.panningY);if(c.panCounter>0)c.panCounter--;if(c.panCounter!=0)window.setTimeout("VE_MapSearchControl._StepPan("+controlIndex+")",10);else c.StopContinuousPan();}}
VE_MapSearchControl.prototype.StopContinuousPan=function(){this.panningX=0;this.panningY=0;this.panning=false;this.keyboardPanning=false;if(this.panLatitude!=null&&this.panLongitude!=null){var dx=this._LonToX(this.panLongitude)-(this.originX+this.offsetX+this.width/2);var dy=this._LatToY(this.panLatitude)-(this.originY+this.offsetY+this.height/2);this.PanMap(dx,dy);this.latitude=this.panLatitude;this.longitude=this.panLongitude;this.preferredLatitude=this.latitude;this.preferredLongitude=this.longitude;this.panLatitude=null;this.panLongitude=null;}else{this._ComputeCenterPoint(true);}this._UpdateScaleBar();this._CallEndContinuousPan();}
VE_MapSearchControl.prototype.PanToLatLong=function(latitude,longitude){this.panLatitude=latitude;this.panLongitude=longitude;var x=this._LonToX(longitude);var y=this._LatToY(latitude);var dx=x-(this.originX+this.offsetX+this.width/2);var dy=y-(this.originY+this.offsetY+this.height/2);var d=Math.sqrt(dx*dx+dy*dy);if(!VE_MapSearchControl.animatedMovementEnabled||Math.abs(dx)>2*this.width||Math.abs(dy)>2*this.height||d>1.5*Math.sqrt(this.width*this.width+this.height*this.height)){this.SetCenter(latitude,longitude);return;}var a=Math.atan2(dy,dx);var s=VE_MapSearchControl.panToLatLongSpeed;var c=Math.ceil(d/s);s=Math.round(d/c);dx=Math.cos(a)*s;dy=Math.sin(a)*s;this.ContinuousPan(dx,dy,c);}
VE_MapSearchControl.prototype.AddPushpin=function(id,lat,lon,width,height,className,innerHtml,zIndex){var x=Math.round(this._LonToX(lon)-this.originX);var y=Math.round(this._LatToY(lat)-this.originY);var pin=null;if(this.unusedPushpins.length>0){pin=this.unusedPushpins.pop();pin.Recycle(id,lat,lon,x,y,width,height,className,innerHtml,zIndex);}else{pin=new VE_MapPushpin(this,id,lat,lon,x,y,width,height,className,innerHtml,zIndex);}this.pushpins.push(pin);this.map.appendChild(pin.el);return pin.el;}
VE_MapSearchControl.prototype.RemovePushpin=function(id){for(var i=0;i<this.pushpins.length;i++){var p=this.pushpins[i];if(p.id==id){this.pushpins.splice(i,1);this.map.removeChild(p.el);this.unusedPushpins.push(p);p.el.vePushpin=null;return;}}}
VE_MapSearchControl.prototype.ClearPushpins=function(){var p=this.pushpins;while(p.length>0)this.map.removeChild(p.pop().el);}
VE_MapSearchControl.prototype._RepositionPushpins=function(){for(var i=0;i<this.pushpins.length;i++){var p=this.pushpins[i];var x=Math.round(this._LonToX(p.lon)-this.originX);var y=Math.round(this._LatToY(p.lat)-this.originY);p.SetCurrentState(x,y);p.PrecomputeSteps();p.SetFactor(0);}}
function VE_MapPushpin(c,id,lat,lon,x,y,w,h,className,innerHtml,zIndex){this.c=c;this.id=id;this.lat=lat;this.lon=lon;this.w=w;this.h=h;var n=VE_MapSearchControl.zoomTotalSteps+1;this.xs=new Array(n);this.ys=new Array(n);var el=document.createElement("div");el.id=id;el.vePushpin=this;el.className=className;el.style.position="absolute";el.style.zIndex=zIndex;el.innerHTML=innerHtml;el.ondblclick=VE_MapPushpin._MouseDoubleClick;el.onmousewheel=VE_MapPushpin._MouseWheel;el.unselectable="on";this.el=el;this.SetCurrentState(x,y);this.SetNextState(x,y);this.PrecomputeSteps();this.SetFactor(0);}
VE_MapPushpin.prototype.Recycle=function(id,lat,lon,x,y,w,h,className,innerHtml,zIndex){this.id=id;this.lat=lat;this.lon=lon;this.w=w;this.h=h;this.el.id=id;this.el.className=className;this.el.style.zIndex=zIndex;this.el.innerHTML=innerHtml;this.el.vePushpin=this;this.SetCurrentState(x,y);this.SetNextState(x,y);this.PrecomputeSteps();this.SetFactor(0);}
VE_MapPushpin.prototype.SetCurrentState=function(x,y){this.x=x;this.y=y;}
VE_MapPushpin.prototype.SetNextState=function(x,y){this._x=x;this._y=y;}
VE_MapPushpin.prototype.ClearSteps=function(){var n=VE_MapSearchControl.zoomTotalSteps;for(var i=0;i<=n;i++){this.xs[i]=this.x;this.ys[i]=this.y;}}
VE_MapPushpin.prototype.PrecomputeSteps=function(){var n=VE_MapSearchControl.zoomTotalSteps;for(var i=0;i<=n;i++){var a=i/n;var b=1.0-a;this.xs[i]=Math.floor(b*this.x+a*this._x-this.w/2);this.ys[i]=Math.floor(b*this.y+a*this._y-this.h/2);}}
VE_MapPushpin.prototype.SetFactor=function(i){with(this.el.style){left=this.xs[i];top=this.ys[i];}}
VE_MapPushpin.prototype.SwapStates=function(){var t=0;t=this.x;this.x=this._x;this._x=t;t=this.y;this.y=this._y;this._y=t;}
VE_MapPushpin._MouseDoubleClick=function(e){if(!e){e=window.event;}var t=VE_MapSearchControl.GetTarget(e);if(!t){return false;}var p=t.vePushpin;if(!p){return false;}var c=p.c;if(!c||c.panning||c.zooming){return false;}if(e.altKey){if(c.zoomLevel==VE_MapSearchControl.minZoom)c.PanToLatLong(p.lat,p.lon);else c.SetCenterAndZoom(p.lat,p.lon,c.zoomLevel-1);}else{if(c.zoomLevel==VE_MapSearchControl.maxZoom)c.PanToLatLong(p.lat,p.lon);else c.SetCenterAndZoom(p.lat,p.lon,c.zoomLevel+1);}return false;}
VE_MapPushpin._MouseWheel=function(e){if(!e){e=window.event;}var t=VE_MapSearchControl.GetTarget(e);if(!t){return false;}var p=t.vePushpin;if(!p){return false;}var c=p.c;if(!c||c.panning||c.zooming){return false;}var delta=VE_MapSearchControl.GetMouseScrollDelta(e);if(delta>0){c.ZoomIn();}else if(delta<0){c.ZoomOut();}e.cancelBubble=true;return false;}
VE_MapSearchControl.scaleBarWidth=150;
VE_MapSearchControl.prototype._CreateScaleBar=function(){var sbw=VE_MapSearchControl.scaleBarWidth+"px";this.scaleBar=document.createElement("table");this.scaleBar.cellpadding=0;this.scaleBar.cellspacing=0;this.scaleBar.unselectable="on";with(this.scaleBar.style){position="absolute";width=sbw;height="18px";padding=0;margin=0;zIndex=31;display="none";}this.element.appendChild(this.scaleBar);var labelRow=this.scaleBar.insertRow(0);var labelCell=labelRow.insertCell(0);this.scaleBarLabelBg=document.createElement("div");this.scaleBarLabelBg.unselectable="on";with(this.scaleBarLabelBg.style){position="absolute";top="1px";left="1px";height="12px";fontFamily="Verdana";fontSize="8pt";color="#FFFFFF";overflow="hidden";}labelCell.appendChild(this.scaleBarLabelBg);this.scaleBarLabelFg=document.createElement("div");this.scaleBarLabelFg.unselectable="on";with(this.scaleBarLabelFg.style){position="absolute";top="0px";left="0px";height="12px";fontFamily="Verdana";fontSize="8pt";color="#255C94";overflow="hidden";}labelCell.appendChild(this.scaleBarLabelFg);var barRow=this.scaleBar.insertRow(1);var barCell=barRow.insertCell(0);this.scaleBarLineBg=document.createElement("div");this.scaleBarLineBg.unselectable="on";with(this.scaleBarLineBg.style){position="absolute";top="15px";left="1px";width=sbw;height="5px";background="#FFFFFF";overflow="hidden";}barCell.appendChild(this.scaleBarLineBg);this.scaleBarLineFg=document.createElement("div");this.scaleBarLineFg.unselectable="on";with(this.scaleBarLineFg.style){position="absolute";top="14px";left="0px";width=sbw;height="5px";background="#255C94";overflow="hidden";}barCell.appendChild(this.scaleBarLineFg);this._UpdateScaleBar();this.ShowScaleBar();}
VE_MapSearchControl.prototype._RepositionScaleBar=function(){with(this.scaleBar.style){top=this.height-60;left=this.width-this.scaleBarLineWidth-10;}}
VE_MapSearchControl.prototype._UpdateScaleBar=function(){var mpp=this.GetMetersPerPixel();var maxMeters=mpp*VE_MapSearchControl.scaleBarWidth;var units="mi";var dMeasure=MetersToMiles(maxMeters);var niceValue=LargestNiceNumber(dMeasure);if(niceValue<0.5){units="yds";dMeasure=MetersToYards(maxMeters);niceValue=LargestNiceNumber(dMeasure);}if(niceValue<1)niceValue=niceValue.toFixed(1);this.scaleBarLineWidth=Math.round(niceValue/dMeasure*VE_MapSearchControl.scaleBarWidth);niceValue+=" "+units;this.scaleBarLabelFg.innerHTML=niceValue;this.scaleBarLabelBg.innerHTML=niceValue;this.scaleBarLineFg.style.width=this.scaleBarLineWidth;this.scaleBarLineBg.style.width=this.scaleBarLineWidth;this._RepositionScaleBar();}
VE_MapSearchControl.prototype.ShowScaleBar=function(){this.scaleBar.style.display="block";}
VE_MapSearchControl.prototype.HideScaleBar=function(){this.scaleBar.style.display="none";}
function MetersToKilometers(meters){return meters*0.001;}
function MetersToMiles(meters){return meters*0.000621371192;}
function MetersToYards(meters){return meters*1.0936133;}
function LargestNiceNumber(dIn){var dLog10=Math.log(dIn)/Math.log(10);var dExponent=Math.floor(dLog10);var dExponentValue=Math.pow(10,dExponent);var dRoot=dIn/dExponentValue;var dIntegerRoot=Math.floor(dRoot);if(dIntegerRoot>=3.0){return dIntegerRoot*dExponentValue;}var dNiceRoot=Math.floor(dRoot*2.0)*0.5;return dNiceRoot*dExponentValue;}
var directionsDomain="maps.msn.com";
var directionsUrl="http://{0}/DirectionsFind.aspx?name{1}={2}&lats{1}={3}&lons{1}={4}";
var useCurrentViewText="[Use current map view]";
var map;
function VE_Scratchpad(){}
;
VE_Scratchpad.pinZIndex=19;
VE_Scratchpad.AddLocation=function(name,latitude,longitude,description){if(!description){description="";}var id="veGeocodeLoc";if(VE_Scratchpad.location!=null){map.RemovePushpin("veGeocodeLoc");}VE_Scratchpad.location=new VE_SearchResult(id,name,description,"","","adr",latitude,longitude);VE_Scratchpad.pin=map.AddPushpin("veGeocodeLoc",latitude,longitude,23,17,"VE_Pushpin VE_Pushpin_orange",'',VE_Scratchpad.pinZIndex);VE_Scratchpad.pin.onmouseover=VE_SearchManager._ShowScratchpadPopup;}
;
VE_Scratchpad.GetEntity=function(){return VE_Scratchpad.location;}
VE_Scratchpad.GeneratePinId=function(){return"veGeocodeLoc";}
VE_Scratchpad.GetColorForEntity=function(){return"orange";}
function VE_Help(){}
;
VE_Help.CloseIntro=function(){}
;
function SetViewport(lat1,lon1,lat2,lon2){map.SetViewport(lat1,lon1,lat2,lon2);}
;
function VE_SiteLink(){var imageUrl="http://virtualearth.msn.com/VEMS/VE_PoweredBy.png";this.siteLinkElement=document.createElement("div");this.siteLinkElement.id="VE_SiteLink";this.siteLinkElement.onclick=VE_SiteLink.OpenVEWindow;with(this.siteLinkElement.style){position="absolute";width="161px";height="34px";padding="0px";margin="0px";zIndex=30;display="none";cursor="hand";}if(GetInternetExplorerVersion()>-1){this.siteLinkElement.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+imageUrl+"', sizingMethod='scale')";}else{this.siteLinkElement.style.background="url("+imageUrl+")";}}
;
VE_SiteLink.OpenVEWindow=function(){var url="http://virtualearth.msn.com/Default.aspx?v=1&cp="+map.GetCenterLatitude()+"%7C"+map.GetCenterLongitude()+"&style="+map.GetMapStyle()+"&lvl="+map.GetZoomLevel();if(VE_SearchManager.searches.length>0){url+="&ss="+IOSec.EncodeUrl(VE_SearchManager.searches[0].phrase);}if(VE_Scratchpad.location!=null){url+="&sp="+IOSec.EncodeUrl(VE_Scratchpad.location.GetSerializedId());}OpenNewWindow(url,"veSiteLink","all");}
;
VE_SiteLink.prototype._RepositionSiteLink=function(containerHeight){with(this.siteLinkElement.style){top=(containerHeight-53)+"px";left="10px";display="block";}}
VE_MapSearchControl.prototype._RequestTile=function(x,y,zl,size,style){var t=null;var max=1<<zl;if(x<0||y<0||x>=max||y>=max){return;}if(this.unusedTiles.length>0){t=this.unusedTiles.pop();t.Recycle(x,y,zl,style,(x*size-this.originX),(y*size-this.originY),size,size);}else{t=new VE_MapTile(this,x,y,zl,style,(x*size-this.originX),(y*size-this.originY),size,size);}if(t){if(this.debug){t.img.style.border="1px dashed red";}this.tiles.push(t);}}
function PrefixNumber(n){if(n>=0)return"+"+n;return n;}
VE_MapSearchControl.FindControlByTileImage=function(tileImg){if(!tileImg.parentNode){return;}var m=tileImg.parentNode;var c=VE_MapSearchControl.controlList;for(var i=0;i<c.length;i++){if(c[i].map==m)return c[i];}return null;}
function VE_MapTile(c,tx,ty,zl,ms,x,y,w,h){this.c=c;this.tx=tx;this.ty=ty;this.zl=zl;this.ms=ms;this.key=this._TileToQuadKey(zl,tx,ty);this.f=this._BuildFilename();this.id="tile_"+this.key;this.loading=true;this.unused=false;var n=VE_MapSearchControl.zoomTotalSteps+1;this.xs=new Array(n);this.ys=new Array(n);this.ws=new Array(n);this.hs=new Array(n);var img=document.createElement("img");this.img=img;img.id=this.id;img.style.position="absolute";img.style.zIndex=VE_MapTile.baseZIndex;img.style.cursor="pointer";img.onmousedown=VE_MapSearchControl._MouseDown;img.onmouseup=VE_MapSearchControl._MouseUp;img.onmousemove=VE_MapSearchControl._MouseMove;img.onmousewheel=VE_MapSearchControl._MouseWheel;img.ondblclick=VE_MapSearchControl._MouseDoubleClick;img.oncontextmenu=VE_MapSearchControl._ContextMenu;if(window.addEventListener&&navigator.product&&navigator.product=="Gecko"){img.addEventListener("DOMMouseScroll",VE_MapSearchControl._MouseWheel,false);}img.onload=VE_MapTile._Load;img.veTile=this;var overlay=document.createElement("div");this.overlay=overlay;overlay.style.position="absolute";overlay.style.background="white";overlay.style.color="red";overlay.style.width="1px";overlay.style.height="20px";overlay.style.zIndex=VE_MapTile.debugZIndex;overlay.innerHTML=this.key+"<br>"+tx+", "+ty;this.SetCurrentState(x,y,w,h);this.SetNextState(x,y,w,h);this.PrecomputeSteps();img.src=this.f;}
VE_MapTile.prototype._TileToQuadKey=function(zl,tx,ty){var quad="";for(var i=zl;i>0;i--){var mask=1<<(i-1);var cell=0;if((tx&mask)!=0){cell++;}if((ty&mask)!=0){cell+=2;}quad+=cell+"";}return quad;}
VE_MapTile.prototype._BuildFilename=function(){var server=((this.tx&1)+((this.ty&1)<<1))%VE_MapSearchControl.tileUrlPrefixes.length;return VE_MapSearchControl.tileUrlPrefixes[server]+this.ms+this.key+(this.ms=='r'?".png":".jpeg")+"?g="+VE_MapSearchControl.tileVersion;}
VE_MapTile.prototype.Recycle=function(tx,ty,zl,ms,x,y,w,h){this.tx=tx;this.ty=ty;this.zl=zl;this.ms=ms;this.key=this._TileToQuadKey(zl,tx,ty);this.f=this._BuildFilename();this.id="tile_"+this.key;this.overlay.innerHTML=this.key+"<br>"+tx+", "+ty;var w=this.w;var h=this.h;this.SetCurrentState(x,y,w,h);this.SetNextState(x,y,w,h);this.PrecomputeSteps();this.RemoveFromMap();this.loading=true;this.unused=false;this.img.veTile=this;this.img.src=this.f;}
VE_MapTile.prototype.SetCurrentState=function(x,y,w,h){this.x=x;this.y=y;this.w=w;this.h=h;}
VE_MapTile.prototype.SetNextState=function(x,y,w,h){this._x=x;this._y=y;this._w=w;this._h=h;}
VE_MapTile.prototype.ClearSteps=function(){var n=VE_MapSearchControl.zoomTotalSteps;for(var i=0;i<=n;i++){this.xs[i]=this.x;this.ys[i]=this.y;this.ws[i]=this.w;this.hs[i]=this.h;}}
VE_MapTile.prototype.PrecomputeSteps=function(){var n=VE_MapSearchControl.zoomTotalSteps;for(var i=0;i<=n;i++){var a=i/n;var b=1.0-a;this.xs[i]=Math.floor(b*this.x+a*this._x);this.ys[i]=Math.floor(b*this.y+a*this._y);this.ws[i]=Math.ceil(b*this.w+a*this._w);this.hs[i]=Math.ceil(b*this.h+a*this._h);}}
VE_MapTile.prototype.SetFactor=function(i){if(!this.loading){if(i>=this.xs.length)i=this.xs.length-1;with(this.img.style){left=this.xs[i];top=this.ys[i];width=this.ws[i];height=this.hs[i];}with(this.overlay.style){left=this.xs[i];top=this.ys[i];}}}
VE_MapTile.prototype.SwapStates=function(){var t=0;with(this){t=x;x=_x;_x=t;t=y;y=_y;_y=t;t=w;w=_w;_w=t;t=h;h=_h;_h=t;}}
VE_MapTile.prototype.RemoveFromMap=function(){var m=this.c.map;var i=this.img;var o=this.overlay;if(i.parentNode==m){m.removeChild(i);}if(o.parentNode==m){m.removeChild(o);}this.unused=true;this.img.src=VE_MapSearchControl.emptyTile;}
VE_MapTile._Load=function(){if(!this.veTile){return;}with(this.veTile){if(!loading){return;}loading=false;if(!unused){SetFactor(c.zoomCounter);c.map.appendChild(img);if(c.debug){c.map.appendChild(overlay);}}}this.veTile=null;}
function OpenNewWindow(url,name,options,width,height,x,y){var allOptionsTrue="toolbar, location, directories, status, menubar, scrollbars, resizable";var winWidth="width="+(width>0?width:GetWindowWidth())+", ";var winHeight="height="+(height>0?height:GetWindowHeight())+", ";x=x?x:0;var winX="screenX="+x+", left="+x+", ";y=y?y:0;var winY="screenY="+y+", top="+y;var newWindow=open(url,name,(options=='all'?allOptionsTrue:options)+", "+winWidth+winHeight+winX+winY);newWindow.focus();}
function GetInternetExplorerVersion(){var rv=-1;if(navigator.appName=='Microsoft Internet Explorer'){var ua=navigator.userAgent;var re=new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");if(re.exec(ua)!=null)rv=parseFloat(RegExp.$1);}return rv;}
VE_MapSearchControl.prototype.SetViewport=function(lat1,lon1,lat2,lon2){var z=0;var w=Math.abs(this._LonToXAtZ(lon1,z)-this._LonToXAtZ(lon2,z));var h=Math.abs(this._LatToYAtZ(lat1,z)-this._LatToYAtZ(lat2,z));while(z<VE_MapSearchControl.maxZoom&&w<this.width&&h<this.height){z++;w=Math.abs(this._LonToXAtZ(lon1,z)-this._LonToXAtZ(lon2,z));h=Math.abs(this._LatToYAtZ(lat1,z)-this._LatToYAtZ(lat2,z));}z=Math.max(0,Math.min(VE_MapSearchControl.maxZoom,z-1));var lat=0.5*(lat1+lat2);var lon=0.5*(lon1+lon2);this.SetCenterAndZoom(lat,lon,z);}
VE_MapSearchControl.prototype.SetBestMapView=function(l){if(!l||l.constructor!=Array){return;}var a=l[0].latitude;var b=l[0].longitude;var c=a;var d=b;for(var i=1;i<l.length;i++){a=Math.min(a,l[i].latitude);b=Math.min(b,l[i].longitude);c=Math.max(c,l[i].latitude);d=Math.max(d,l[i].longitude);}var dLat=(c-a)*0.1;var dLon=(d-b)*0.1;a-=dLat;b-=dLon;c+=dLat;d+=dLon;this.SetViewport(VE_MapSearchControl.ClipLatitude(a),VE_MapSearchControl.ClipLongitude(b),VE_MapSearchControl.ClipLatitude(c),VE_MapSearchControl.ClipLongitude(d));}
VE_MapSearchControl.prototype.IncludePointInViewport=function(lat,lon){this.SetBestMapView(new Array(this,{latitude:lat,longitude:lon}));}
VE_MapSearchControl.ClipLatitude=function(latitude){return VE_MapSearchControl.Clip(latitude,VE_MapSearchControl.minLatitude,VE_MapSearchControl.maxLatitude);}
VE_MapSearchControl.ClipLongitude=function(longitude){return VE_MapSearchControl.Clip(longitude,VE_MapSearchControl.minLongitude,VE_MapSearchControl.maxLongitude);}
VE_MapSearchControl.Clip=function(n,minValue,maxValue){if(n<minValue){return minValue;}if(n>maxValue){return maxValue;}return n;}
VE_MapSearchControl.prototype.SetZoom=function(zoomLevel){zoomLevel=this._ValidateZoomLevel(this.preferredLatitude,this.preferredLongitude,zoomLevel);if(zoomLevel==this.zoomLevel){return;}this.SetCenterAndZoom(this.preferredLatitude,this.preferredLongitude,zoomLevel);}
VE_MapSearchControl.prototype.ZoomIn=function(){if(this.zoomLevel>=VE_MapSearchControl.maxZoom)return;this.SetZoom(this.zoomLevel+1);}
VE_MapSearchControl.prototype.ZoomOut=function(){if(this.zoomLevel<=VE_MapSearchControl.minZoom)return;this.SetZoom(this.zoomLevel-1);}
VE_MapSearchControl.prototype.SetCenterAndZoom=function(latitude,longitude,newZoom){newZoom=this._ValidateZoomLevel(latitude,longitude,newZoom);this.preferredLatitude=latitude;this.preferredLongitude=longitude;if(this.zooming||this.panning||this.dragging){return;}this.zooming=true;this.prevZoomLevel=oldZoom;if(this.zoomLevel!=newZoom)this._CallStartZoom();latitude=this._ClipLatitude(latitude,newZoom);longitude=this._ClipLongitude(longitude,newZoom);this.latitude=latitude;this.longitude=longitude;var dx=(this.width/2)-this.GetX(longitude);var dy=(this.height/2)-this.GetY(latitude);var distance=Math.sqrt(dx*dx+dy*dy);var dynamic=(distance<this.width&&distance<this.height)&&(newZoom==this.zoomLevel-1||newZoom==this.zoomLevel+1)&&VE_MapSearchControl.animatedMovementEnabled;if(dynamic){var oldOriginX=this.originX+this.offsetX;var oldOriginY=this.originY+this.offsetY;var oldZoom=this.zoomLevel;var newOriginX=Math.round(this._LonToXAtZ(longitude,newZoom)-this.width/2);var newOriginY=Math.round(this._LatToYAtZ(latitude,newZoom)-this.height/2);this.oldTiles=this.tiles;this.tiles=new Array();var ot=this.oldTiles;var nt=this.tiles;var pp=this.pushpins;for(var i=0;i<ot.length;i++){ot[i].SetCurrentState(ot[i].x-this.offsetX,ot[i].y-this.offsetY,ot[i].w,ot[i].h,ot[i].o);var x1=Math.floor(this._XToXAtZ(oldOriginX+ot[i].x,oldZoom,newZoom)-newOriginX);var y1=Math.floor(this._YToYAtZ(oldOriginY+ot[i].y,oldZoom,newZoom)-newOriginY);var x2=Math.ceil(this._XToXAtZ(oldOriginX+ot[i].x+ot[i].w,oldZoom,newZoom)-newOriginX);var y2=Math.ceil(this._YToYAtZ(oldOriginY+ot[i].y+ot[i].h,oldZoom,newZoom)-newOriginY);ot[i].SetNextState(x1,y1,x2-x1,y2-y1,100);ot[i].PrecomputeSteps();ot[i].img.style.zIndex=VE_MapTile.baseZIndex;}for(var i=0;i<pp.length;i++){pp[i].SetCurrentState(pp[i].x-this.offsetX,pp[i].y-this.offsetY);var x=Math.floor(this._LonToXAtZ(pp[i].lon,newZoom)-newOriginX);var y=Math.floor(this._LatToYAtZ(pp[i].lat,newZoom)-newOriginY);pp[i].SetNextState(x,y);pp[i].PrecomputeSteps();}this.zoomLevel=newZoom;this.latitude=latitude;this.longitude=longitude;this._StartMap();for(var i=0;i<nt.length;i++){var x1=Math.floor(this._XToXAtZ(newOriginX+nt[i].x,newZoom,oldZoom)-oldOriginX);var y1=Math.floor(this._YToYAtZ(newOriginY+nt[i].y,newZoom,oldZoom)-oldOriginY);var x2=Math.ceil(this._XToXAtZ(newOriginX+nt[i].x+nt[i].w,newZoom,oldZoom)-oldOriginX);var y2=Math.ceil(this._YToYAtZ(newOriginY+nt[i].y+nt[i].h,newZoom,oldZoom)-oldOriginY);nt[i].SetNextState(x1,y1,x2-x1,y2-y1,0);nt[i].SwapStates();nt[i].PrecomputeSteps();nt[i].img.style.zIndex=VE_MapTile.swapZIndex;}this.zoomCounter=0;VE_MapSearchControl._StepAnimatedZoom(this.index);}else{this.oldTiles=this.tiles;this.tiles=new Array();this.zoomLevel=newZoom;this.latitude=latitude;this.longitude=longitude;this._StartMap();this._FinalizeZoom();this._RepositionPushpins();}}
VE_MapSearchControl._StepAnimatedZoom=function(controlIndex){var c=VE_MapSearchControl.controlList[controlIndex];if(!c.zooming)return;if(c.zoomCounter<=VE_MapSearchControl.zoomTotalSteps){var f=c.zoomCounter++;for(var i=0;i<c.oldTiles.length;i++){c.oldTiles[i].SetFactor(f);}for(var i=0;i<c.tiles.length;i++){c.tiles[i].SetFactor(f);}for(var i=0;i<c.pushpins.length;i++){c.pushpins[i].SetFactor(f);}window.setTimeout("VE_MapSearchControl._StepAnimatedZoom("+controlIndex+")",1);}else{c._FinalizeZoom();}}
VE_MapSearchControl.prototype._FinalizeZoom=function(){var t=this.oldTiles;var u=this.unusedTiles;var m=this.map;if(t&&t.length>0){while(t.length>0){var tile=t.pop();tile.RemoveFromMap();u.push(tile);}this.oldTiles=null;}for(var i=0;i<this.tiles.length;i++){this.tiles[i].SwapStates();this.tiles[i].ClearSteps();}for(var i=0;i<this.pushpins.length;i++){this.pushpins[i].SwapStates();this.pushpins[i].ClearSteps();}this.zooming=false;this.zoomCounter=0;this._UpdateScaleBar();this._UpdateCopyright();if(this.prevZoomLevel!=this.zoomLevel)this._CallEndZoom();}
function VE_ZoomControl(x,y,zoomLevel,position){this.x=x;this.y=y;this.offsetLeft=0;this.dragging=false;this.zoomLevel=zoomLevel;var el=document.createElement("div");el.id="VE_ZoomControl";el.style.position=position;el.style.left=x;el.style.top=y;this.el=el;var minus=document.createElement("a");minus.className="VE_ZoomControl_minus";minus.style.left="0px";minus.href="javascript:void(0)";minus.onclick=VE_ZoomControl._Minus;minus.unselectable="on";this.minus=minus;el.appendChild(minus);var plus=document.createElement("a");plus.className="VE_ZoomControl_plus";plus.style.left="26px";plus.href="javascript:void(0)";plus.onclick=VE_ZoomControl._Plus;plus.unselectable="on";this.plus=plus;el.appendChild(plus);VE_ZoomControl.control=this;}
VE_ZoomControl.control=null;
VE_ZoomControl.Create=function(x,y,z,position,mapControl){VE_ZoomControl.control=new VE_ZoomControl(x,y,z,position,mapControl);VE_ZoomControl.mapControl=mapControl;return VE_ZoomControl.control.el;}
VE_ZoomControl._Plus=function(e){VE_ZoomControl.mapControl.ZoomIn();}
VE_ZoomControl._Minus=function(e){VE_ZoomControl.mapControl.ZoomOut();}
function Ad(title,url,description,latitude,longitude){this.title=title;this.url=url;this.description=description;this.latitude=latitude;this.longitude=longitude;}
Ad.prototype.ToHtml=function(){var h="<a href=\""+this.url+"\" target=\"_blank\">"+IOSec.EncodeHtml(this.title)+"</a>";if(this.description&&this.description.length>0){h+="<br/>"+IOSec.EncodeHtml(this.description);}return h;}
var ambiguousList=new Array();
function UpdateAmbiguousList(content){var el=document.getElementById('whereambiglist');if(!content||content.constructor!=Array){el.style.visibility='hidden';return;}ambiguousList=content;el.style.left=GetElementLeftPosition('where')-1-map.x;el.style.top=document.getElementById('where').offsetTop+22;var options=el.childNodes;if(options.length>1){for(var n=0;n<options.length;i++){el.removeChild(options[n]);}}for(var i=0;i<content.length;i++){var d=document.createElement('div');d.id=i;d.className=((i==0)?'item_on':'item');d.onmouseover=item_MouseOver;d.onmouseout=item_MouseOut;d.onclick=SetAmbiguousViewport;d.innerHTML=content[i][0];el.appendChild(d);}document.f.where.value=content[0][0];document.body.onclick=HideAmbiguousList;el.style.visibility="visible";if(el.setCapture){el.setCapture(false);}if(el.focus){el.focus();}else if(el.setFocus){el.setFocus();}}
function SetAmbiguousViewport(){var i=this.id;var lat1=ambiguousList[i][1];var lon1=ambiguousList[i][2];var lat2=ambiguousList[i][3];var lon2=ambiguousList[i][4];map.SetViewport(lat1,lon1,lat2,lon2);HideAmbiguousList();}
function SanitizeHtmlString(s){if(!s||typeof(s)!="string"){return s;}return IOSec.EncodeHtml(s);}
function GetMousePosX(e){var posX=0;if(e.pageX){posX=e.pageX;}else if(e.clientX){posX=e.clientX+document.body.scrollLeft;}return posX;}
function GetMousePosY(e){var posY=0;if(e.pageY){posY=e.pageY;}else if(e.clientY){posY=e.clientY+document.body.scrollTop;}return posY;}
function GetTarget(e){if(!e)var e=window.event;var eventTarget;if(e.srcElement)eventTarget=e.srcElement;else if(e.target)eventTarget=e.target;if(eventTarget.nodeType==3)eventTarget=targ.parentNode;return eventTarget;}
function SelectText(textbox,start,end){if(!textbox)return;if(textbox.createTextRange){var textRange=textbox.createTextRange();textRange.moveStart("character",start);textRange.moveEnd("character",end);textRange.select();}else if(textbox.setSelectionRange){textbox.setSelectionRange(start,end);}}
function GetElementLeftPosition(elemID){var offsetTrail=document.getElementById(elemID);var offsetLeft=0;while(offsetTrail){offsetLeft+=offsetTrail.offsetLeft;offsetTrail=offsetTrail.offsetParent;}if(navigator.userAgent.indexOf("Mac")!=-1&&typeof(document.body.leftMargin)!="undefined"){offsetLeft+=document.body.leftMargin;}return offsetLeft;}
function GetElementTopPosition(elemID){var offsetTrail=document.getElementById(elemID);var offsetTop=0;while(offsetTrail){offsetTop+=offsetTrail.offsetTop;offsetTrail=offsetTrail.offsetParent;}if(navigator.userAgent.indexOf("Mac")!=-1&&typeof(document.body.topMargin)!="undefined"){offsetTop+=document.body.topMargin;}return offsetTop;}
function CreateMessageControl(){var c=new VE_MessageControl();document.body.appendChild(VE_MessageControl.control);}
function ShowMessage(message){if(VE_MessageControl.messages.length>0){VE_MessageControl._RemoveMessage();}VE_MessageControl._AddMessage(message);}
function VE_MessageControl(){if(!VE_MessageControl.control){VE_MessageControl.control=document.createElement("div");VE_MessageControl.control.id="VE_MessageControl";}return VE_MessageControl.control;}
VE_MessageControl.control=null;
VE_MessageControl.messages=new Array();
VE_MessageControl.width=380;
VE_MessageControl.x=300;
VE_MessageControl.y=80;
VE_MessageControl._AddMessage=function(message){VE_MessageControl.messages.unshift(message);window.setTimeout("VE_MessageControl._RemoveMessage()",10000);VE_MessageControl._Update();}
VE_MessageControl._RemoveMessage=function(){VE_MessageControl.messages.pop();VE_MessageControl._Update();}
VE_MessageControl._Reposition=function(x,y,width){VE_MessageControl.width=width;var c=VE_MessageControl.control;if(c){c.style.width=width;c.style.left=x;c.style.top=y;}}
VE_MessageControl._Update=function(){var c=VE_MessageControl.control;var m=VE_MessageControl.messages;if(!m.length){c.innerHTML="";c.style.display="none";return;}var html="";for(var i=0;i<m.length;i++){html+="<div class=\"VE_MessageControl_message\" style=\"width:"+(VE_MessageControl.width-20)+"px\">"+m[i]+"</div>";}html+="<div class=\"VE_MessageControl_close\" style=\"left:"+(VE_MessageControl.width-20)+"px\" onclick=\"VE_MessageControl.Hide()\" unselectable=\"on\">X</div>";c.innerHTML=html;c.style.display="block";}
VE_MessageControl.Hide=function(){VE_MessageControl.control.style.display="none";}
function OutputEncoder_EncodeHtml(strInput){var c;var EncodeHtml='';for(var cnt=0;cnt<strInput.length;cnt++){c=strInput.charCodeAt(cnt);if(((c>96)&&(c<123))||((c>64)&&(c<91))||(c==32)||((c>47)&&(c<58))||(c==46)||(c==44)||(c==45)||(c==95)){EncodeHtml=EncodeHtml+String.fromCharCode(c);}else{EncodeHtml=EncodeHtml+'&#'+c+';';}}return EncodeHtml;}
function OutputEncoder_EncodeHtmlAttribute(strInput){var c;var EncodeHtmlAttribute='';for(var cnt=0;cnt<strInput.length;cnt++){c=strInput.charCodeAt(cnt);if(((c>96)&&(c<123))||((c>64)&&(c<91))||((c>47)&&(c<58))||(c==46)||(c==44)||(c==45)||(c==95)){EncodeHtmlAttribute=EncodeHtmlAttribute+String.fromCharCode(c);}else{EncodeHtmlAttribute=EncodeHtmlAttribute+'&#'+c+';';}}return EncodeHtmlAttribute;}
function OutputEncoder_EncodeXml(strInput){return OutputEncoder_EncodeHtml(strInput);}
function OutputEncoder_EncodeXmlAttribute(strInput){return OutputEncoder_EncodeHtmlAttribute(strInput);}
function OutputEncoder_EncodeJs(strInput){var c;var EncodeJs='';for(var cnt=0;cnt<strInput.length;cnt++){c=strInput.charCodeAt(cnt);if(((c>96)&&(c<123))||((c>64)&&(c<91))||(c==32)||((c>47)&&(c<58))||(c==46)||(c==44)||(c==45)||(c==95)){EncodeJs=EncodeJs+String.fromCharCode(c);}else if(c>127){EncodeJs=EncodeJs+'\\u'+OutputEncoder_TwoByteHex(c);}else{EncodeJs=EncodeJs+'\\x'+OutputEncoder_SingleByteHex(c);}}return'\''+EncodeJs+'\'';}
function OutputEncoder_AsNumeric(strInput){if(isNaN(parseFloat(strInput))){throw"IOSec.AsNumeric(): Error input ["+strInput+"] not a valid number.";}return strInput;}
function OutputEncoder_EncodeUrl(strInput){var c;var EncodeUrl='';for(var cnt=0;cnt<strInput.length;cnt++){c=strInput.charCodeAt(cnt);if(((c>96)&&(c<123))||((c>64)&&(c<91))||((c>47)&&(c<58))||(c==46)||(c==45)||(c==95)){EncodeUrl=EncodeUrl+String.fromCharCode(c);}else if(c>127){EncodeUrl=EncodeUrl+'%u'+OutputEncoder_TwoByteHex(c);}else{EncodeUrl=EncodeUrl+'%'+OutputEncoder_SingleByteHex(c);}}return EncodeUrl;}
function OutputEncoder_SingleByteHex(charC){var SingleByteHex=charC.toString(16);for(var cnt=SingleByteHex.length;cnt<2;cnt++){SingleByteHex="0"+SingleByteHex;}return SingleByteHex;}
function OutputEncoder_TwoByteHex(charC){var TwoByteHex=charC.toString(16);for(var cnt=TwoByteHex.length;cnt<4;cnt++){TwoByteHex="0"+TwoByteHex;}return TwoByteHex;}
function OutputEncoder(){this.EncodeHtml=OutputEncoder_EncodeHtml;this.EncodeHtmlAttribute=OutputEncoder_EncodeHtmlAttribute;this.EncodeXml=OutputEncoder_EncodeXml;this.EncodeXmlAttribute=OutputEncoder_EncodeXmlAttribute;this.EncodeJs=OutputEncoder_EncodeJs;this.AsNumeric=OutputEncoder_AsNumeric;this.EncodeUrl=OutputEncoder_EncodeUrl;this.SingleByteHex=OutputEncoder_SingleByteHex;this.TwoByteHex=OutputEncoder_TwoByteHex;}
var IOSec=new OutputEncoder();
var windowWidth=0;
var windowHeight=0;
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 GetUrlPrefix(){var lastfslash=window.location.pathname.lastIndexOf("/");var hosturl=window.location.protocol+"//"+window.location.hostname+window.location.pathname.substring(0,lastfslash+1);return hosturl;}
function GetUrlParameterString(){var urlParameterString=window.location.search;if(urlParameterString.length==0||urlParameterString.indexOf("?")==-1){return"";}return urlParameterString.substr(urlParameterString.indexOf("?")+1);}
function GetUrlParameters(){var parameters=new Array();var urlParameterString=GetUrlParameterString();if(!urlParameterString){return parameters;}var parameterStrings=urlParameterString.split("&");for(var i=0;i<parameterStrings.length;i++){var parameterParts=parameterStrings[i].split("=");if(parameterParts.length==2&&parameterParts[0]&&parameterParts[1]){parameters.push(unescape(parameterParts[0]));parameters.push(unescape(parameterParts[1]));}}return parameters;}
function GetXmlHttp(){var x=null;try{x=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{x=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){x=null}}if(!x&&typeof XMLHttpRequest!="undefined"){x=new XMLHttpRequest()}return x;}
