   var map = null;
   var mapTarget = 'mapCanvas';
   
   var waiter = new Waiter($(mapTarget), {
    baseHref: '/',
    img: {
        'class': 'waiterImg',
        src: 'loadinfo.net.large.gif',
        styles: {
          width: 49,
          height: 49
        }
      }
   });
   
   function GetMap(zoom) {
      // VEMap.LoadMap(VELatLong, zoom, style, fixed, mode, showSwitch, tileBuffer, mapOptions);
      map = new VEMap(mapTarget);
      map.SetDashboardSize(VEDashboardSize.Tiny);
      map.LoadMap(home, zoom);
      map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
      map.ShowScalebar();
      map.Hide3DNavigationControl();
      
      var pinid = 0;
      var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
      shape.SetTitle(bnbName);
      //shape.SetDescription('This is shape number '+pinid);
      pinid++;
      map.AddShape(shape);
      
      var icon = "<img src='graphics/pin.png'/>";
      shape.SetCustomIcon(icon);
    }

    function onGotRoute(route) {
       // Unroll route
       var legs     = route.RouteLegs;
       var turns    = "<h4>Total driving distance: " + route.Distance.toFixed(1) + " km</h4><ol>";
       var numTurns = 0;
       var leg      = null;

       // Get intermediate legs
      for(var i = 0; i < legs.length; i++) {
         leg = legs[i];  // Leg is a VERouteLeg object
         var turn = null;  // The itinerary leg
         for(var j = 0; j < leg.Itinerary.Items.length; j ++)
         {
            turn = leg.Itinerary.Items[j];  // turn is a VERouteItineraryItem object
            numTurns++;
            turns += "<li>" + turn.Text + "(" + turn.Distance.toFixed(1) + " km)</li>";
         }
      }
      turns += "</ol>";
      
      /*
      var center = map.LatLongToPixel(map.GetCenter());
      center.x = center.x + 160;
      map.SetCenter(map.PixelToLatLong(center));
      */
      map.Pan(220, 0);
      createDivDirections("mapWrapper", turns);
      waiter.stop();
  }   
  
  function createDivDirections(parent, content) {
    var div = new Element("div", {
      id: 'mapDirections',
      'class': 'directions'
    });
    div.set('html', content);
    div.inject($(parent));
  }

  function getDirections(from) {
      var options = new VERouteOptions();
      options.RouteCallback = onGotRoute;
      options.DistanceUnit = VERouteDistanceUnit.Kilometer;
      waiter.start();
      map.GetDirections([from, home], options);
  }
  
  window.addEvent("domready", function() {
    GetMap(_zoom);
    
    $("getDirections").addEvent("submit", 
      function(event) {
        event.preventDefault();
        event.stop();
        getDirections($("from").get("value"));
      }
    );
    
    $("resetMap").addEvent("click", 
      function() {
        GetMap(_zoom);
        if($("mapDirections")) {
          $("mapDirections").dispose();
        }
      }
    );
  });
