function d(i) {
	return document.getElementById(i);
}

// Create and centre the map

//var map = new GMap2(document.getElementById("map"));
//map.setCenter(new GLatLng(55, -95), 3);

// Add contorls
/*
var extLargeMapControl = new GSmallMapControl();
map.addControl(extLargeMapControl);
map.enableScrollWheelZoom();

// Finds which points are inside the map boundaries.

var smallIcon = new GIcon();
smallIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
smallIcon.shadow = "http://assets.filemobile.com/138/transparent.gif";
smallIcon.iconSize = new GSize(12, 20);
smallIcon.shadowSize = new GSize(1, 1);
smallIcon.iconAnchor = new GPoint(6, 20);
smallIcon.infoWindowAnchor = new GPoint(5, 1);   		
*/
// Create the ability to click on a marker and reveal a bubble

function createInfoMarker(point, info) {
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click",
		function() {
			marker.openInfoWindowHtml(info);
		}
	);
	return marker;
}

function selectLocation(map,latlng, center) {
	alert(latlng);
	var marker = new GMarker(latlng);
	map.addOverlay(marker);
}

function centreMap(map,latlng, center) {
	if (center) map.setCenter(latlng, 15);
}

function getLatLang(lat,lng,title,img,id) {
	var marker = new GMarker(new GLatLng(lat,lng));
	map.addOverlay(marker);
	GEvent.addListener(marker, "click",
		function() {
			marker.openInfoWindowHtml('<img src="'+img+'" alt="'+title+'" /><a href="http://www.google.com/search?q='+id+'">'+title+'</a>');
		}
	);
}

function searchAddress(searchString) {
	var geocoder = new GClientGeocoder();
	geocoder.getLatLng(searchString, function(point) {
		if (point) {
			centreMap(map, point, true);
		} else if (searchString == "" || !searchString) {
			alert("Please enter something into the text field before hitting search.");
		} else {
			alert("Google Maps can't find '"+searchString+"'. Please try another search term..");
		}
	});
}