var geocoder;
var map;
var theaddress;
var address;
var title;
var viewAddress;

function setAddress(theaddress, theTitle, theViewAddress) {
	title = theTitle;
	viewAddress = theViewAddress;
	address = theaddress;
	load(address);
};

function load(address) {
	
	// Create new map object
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	
	map.addControl(new GMenuMapTypeControl());
	
	map.enableScrollWheelZoom();
	
	// Create new geocoding object
	geocoder = new GClientGeocoder();
	
	// Retrieve location information, pass it to addToMap()
	geocoder.getLocations(address, addToMap);
}

// 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, 13);
	
	// Create a marker
	marker = new GMarker(point);
	
	// Add the marker to map
	map.addOverlay(marker);
	
	/*tohere = '<div class="get-directions">Start address:<form action="http://maps.google.com/maps" method="get">' +
	   '<input type="text" name="saddr" id="saddr" value="" /><br />' +
	   '<input value="Get Directions" type="submit" id="submit" class="submit" />' +
	   '<input type="hidden" name="daddr" class="hidden" value="' + address + '"/></form></div>';*/
	
	// Add address information to marker
	//myAddressSplit = viewAddress.split(",");
	//marker.openInfoWindowHtml('<p><strong>' + title + '</strong><br />' + myAddressSplit[0] + '<br />' + myAddressSplit[1] + '</p>' + tohere);
	
	/*GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml('<p><strong>' + title + '</strong><br />' +  viewAddress + '</p>' + tohere);
	});*/
}