// JavaScript Document

var geocoder;
var map;

// This function adds the point to the map  
function addToMap(response)
{
	// Retrieve the object
	place = response.Placemark[0];

	// Retrieve the latitude and longitude
	point = new GLatLng(place.Point.coordinates[1],
					  place.Point.coordinates[0]);

	// Center the map on this point
	map.setCenter(point, 14);
  
	// Create our pretty marker icon
	var icon = new GIcon();
    icon.image = "/images/bbcanadamappin2.png";
    icon.iconSize = new GSize(22, 26);
    icon.iconAnchor = new GPoint(11, 26);
    icon.infoWindowAnchor = new GPoint(11, 26);

	// Create a marker
	marker = new GMarker(point, icon);

	// Add the marker to map
	map.addOverlay(marker);
  
	// Add address information to marker
	// marker.openInfoWindowHtml('<center><font face="verdana,Arial" size="2"><B>' + bnb + '</B><br>' + place.address + '</font></center>');
	   marker.openInfoWindowHtml('<center><font face="verdana,Arial" size="2"><B>' + bnb + '</B><br>' + address + '<br>' + gps_send + '</font></center>');
	// yeah, I don't like that at all...

	// Enable Controls
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
}

// On page load, call this function
function load()
{
	// Create new map object
	map = new GMap2(document.getElementById("map"));

	// Create new geocoding object
	geocoder = new GClientGeocoder();

	// Retrieve location information, pass it to addToMap()
	geocoder.getLocations(gps_send, addToMap);
}

