
function AjaxRequest(Url,Callback)
{var xmlHttp=null;var callback=null;if(Callback!=null)
{callback=Callback;}
function CreateRequest(){try
{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{try
{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(E){xmlHttp=false;}}
if(!xmlHttp&&typeof XMLHttpRequest!='undefined')
{xmlHttp=new XMLHttpRequest();}}
function StartRequest()
{CreateRequest();xmlHttp.onreadystatechange=OnStateChange;xmlHttp.open("GET",Url,true);xmlHttp.setRequestHeader('Pragma','no-cache');xmlHttp.send(null);}
function OnStateChange(){if(xmlHttp.readyState==4&&xmlHttp.status==200&&callback!=null){callback(xmlHttp.responseText);}}
this.Execute=StartRequest;}
function RestoreState()
{var searchType=getQueryVariable("stype");var searchHistory=new Array();if(searchType!=null){ClientCache.Save('style',getQueryVariable("style"));ClientCache.Save('zoom',getQueryVariable("zoom"));ClientCache.Save('traffic',getQueryVariable("traffic"));var activePois=getQueryVariable("pois");if(activePois!=null){var activePoisArray=activePois.split('|');for(var i=0;i<activePoisArray.length;i++){ClientCache.Save('poi_'+activePois[i],'active');}}
ClientCache.Save('pane_0_type',searchType);switch(searchType)
{case'fm':ClientCache.Save('pane_0_FindInput',decodeURI(getQueryVariable("FindInput")));break;case'bus':ClientCache.Save('pane_0_location',decodeURI(getQueryVariable("location")));ClientCache.Save('pane_0_keyword',decodeURI(getQueryVariable("keyword")));break;case'per':ClientCache.Save('pane_0_location',decodeURI(getQueryVariable("location")));ClientCache.Save('pane_0_keyword',decodeURI(getQueryVariable("keyword")));break;case'dd':var locationArray=decodeURI(getQueryVariable("waypoints")).split("|");var from=locationArray[0].split(';')[0]+'@'+eval(decodeURI(locationArray[0].split(';')[1]));ClientCache.Save(('pane_0_FromInput'),from);searchHistory.push(from);var to=locationArray[1].split(';')[0]+'@'+eval(decodeURI(locationArray[1].split(';')[1]));ClientCache.Save(('pane_0_ToInput'),to);break;}
var url=document.location.href;document.location.href=url.split('?')[0];return;}
else{var paneNumber=(ClientCache.Retrieve('firstPaneNumber')!=undefined?ClientCache.Retrieve('firstPaneNumber'):0);var numPanes=-1;searchType=ClientCache.Retrieve('pane_'+paneNumber+'_type');while(searchType!=null){numPanes++;searchHistory.push(searchType);switch(searchType)
{case'fm':searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_FindInput'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_Find'));break;case'bus':searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_location'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_keyword'));break;case'per':searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_location'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_keyword'));break;case'dd':searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_FromInput'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_ToInput'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_From'));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_To'));var numWaypoints=ClientCache.Retrieve('pane_'+paneNumber+'_NumWaypoints');searchHistory.push(numWaypoints);for(var j=0;j<numWaypoints;j++){searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_WaypointInput'+j));searchHistory.push(ClientCache.Retrieve('pane_'+paneNumber+'_Waypoint'+(j+2)));}
break;}
paneNumber++;searchType=ClientCache.Retrieve('pane_'+paneNumber+'_type');}
if(ClientCache.Retrieve("style")!=null)
mapManager.Map.SetMapStyle(ClientCache.Retrieve("style"));var mapZoom=ClientCache.Retrieve("zoom");if(mapZoom!=null){if(mapManager.Map.GetZoomLevel()!=mapZoom)
mapManager.Map.SetZoomLevel(mapZoom);}
if(ClientCache.Retrieve("traffic")=='true')
ToggleTraffic();ClientCache.Save('firstPaneNumber',0);}
var i=0;var paneNumber=0;var lastSearch=false;while(i<searchHistory.length){lastSearch=(numPanes==paneNumber);searchType=searchHistory[i];i++;switch(searchType)
{case'fm':document.getElementById('txtFind').value=searchHistory[i];ClientCache.Save('pane_'+paneNumber+'_FindInput',searchHistory[i]);ClientCache.Save('pane_'+paneNumber+'_Find',searchHistory[i+1]);if(lastSearch){if(ClientCache.Retrieve('lastSearchFailed')!='true')
mapManager.NewFindLookup(searchHistory[i]);}
else{mapManager.PrepareForNewFindLookup(searchHistory[i]);}
i=i+2;break;case'bus':document.getElementById('txtBusLocation').value=searchHistory[i];document.getElementById('txtBusName').value=searchHistory[i+1];if(lastSearch){if(ClientCache.Retrieve('lastSearchFailed')!='true')
mapManager.NewFindBusiness('false','false',searchHistory[i+1],searchHistory[i]);}
else{mapManager.PrepareForNewFindBusiness(searchHistory[i],searchHistory[i+1]);}
i=i+2;break;case'per':document.getElementById('txtPersonLocation').value=searchHistory[i];document.getElementById('txtPersonName').value=searchHistory[i+1];if(lastSearch){if(ClientCache.Retrieve('lastSearchFailed')!='true')
mapManager.NewFindPerson('false','false',searchHistory[i+1],searchHistory[i]);}
else{mapManager.PrepareForNewFindPerson(searchHistory[i],searchHistory[i+1]);}
i=i+2;break;case'dd':document.getElementById('txtFrom').value=searchHistory[i];document.getElementById('txtTo').value=searchHistory[i+1];ClientCache.Save('pane_'+paneNumber+'_FromInput',searchHistory[i]);ClientCache.Save('pane_'+paneNumber+'_ToInput',searchHistory[i+1]);ClientCache.Save('pane_'+paneNumber+'_From',searchHistory[i+2]);ClientCache.Save('pane_'+paneNumber+'_To',searchHistory[i+3]);var numWaypoints=searchHistory[i+4];ClientCache.Save('pane_'+paneNumber+'_NumWaypoints',numWaypoints);var j=0;while(j<numWaypoints){ClientCache.Save('pane_'+paneNumber+'_WaypointInput'+j,searchHistory[i+5+j]);j++;ClientCache.Save('pane_'+paneNumber+'_Waypoint'+(j+2),searchHistory[i+5+j]);j++;}
if(lastSearch){if(ClientCache.Retrieve('lastSearchFailed')!='true')
mapManager.GetNewDirections();}
else{mapManager.PrepareForGetNewDirections(searchHistory[i],searchHistory[i+1]);}
i=i+5+numWaypoints;break;}
paneNumber++;}
ClientCache.Save('lastSearchFailed','false');switch(searchType)
{case'fm':TopNav('FindMap');break;case'bus':TopNav('FindBusiness');break;case'per':TopNav('FindPerson');break;case'dd':TopNav('DrivingDirections');break;}}