if(self != top) top.location.href = self.location.href;

function openInfoWindow(position, content, name)
{
  if(iw) iw.close();
  iw = new g.InfoWindow();
  iw.setContent(content);
  iw.setPosition(position)
  iw.open(map);
}

function addMarker(latlng, html)
{
  var image = new g.MarkerImage("/images/bandb_sm.png", new g.Size(32, 32), new g.Point(0, 0), new g.Point(16, 32));
  var marker = new g.Marker({ map: map, position: latlng, icon: image });
}

function showDirections(pos)
{
  if(pos == null) {
    if(el = document.getElementById("mapButtons")) {
      with(el.children[0].style) {
        background = "#fff";
        color = "#000";
      }
    }
  }
  if(pos.match(/canberra city/i)) pos = pos.replace(/city/i, "civic");
  var request = { origin: pos, destination: mapCenter, travelMode: g.TravelMode.DRIVING };
  directionsService.route(request, function(result, status) {
    if(status == g.DirectionsStatus.OK) {
      document.getElementById("directionsPanel").style["display"] = "block";
      directionsDisplay.setDirections(result);
    } else {
      showDirections(prompt('Address lookup failed.  Enter your address to try again:'));
    }
  });

  if(el = document.getElementById("mapButtons")) {
    with(el.children[0].style) {
      background = "#7791d0";
      color = "#fff";
    }
  }
}

function addDirectionButton()
{
  var controlDiv = document.createElement("DIV");
  controlDiv.setAttribute("id", "mapButtons");
  controlDiv.innerHTML = '<a href="#map" onclick="showDirections(prompt(\'Enter your address to get directions:\')); return false;">Driving Directions</a>';
  map.controls[g.ControlPosition.TOP_RIGHT].push(controlDiv);

  directionsDisplay = new google.maps.DirectionsRenderer();
  directionsDisplay.setMap(map);
  directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}

