// JavaScript Document
var googleMap = {
	drawMap : function (GmapEl, Gpoint, Gmarker) {
		// Display the wrapper block if it exists
		var Gpoint = eval('new GLatLng' + Gpoint);
		var map = new GMap2(GmapEl);
		map.addControl(new GSmallMapControl());
		map.setCenter(Gpoint, 15);
		var marker = new GMarker(Gpoint);
		map.addOverlay(marker);
		if (Gmarker)
			marker.openInfoWindowHtml(Gmarker);
	},
	testAddress : function(Gaddress){
		var geocoder = new GClientGeocoder();
		this.Gaddress = Gaddress;
		geocoder.getLatLng(Gaddress + ", New Zealand",this.testAddressCallback);
	},
	testAddressCallback : function(Gpoint){
		if (!Gpoint){
			d('map').innerHTML = "<div class='infoBox boxWarning'><div class='boxHeading'>Address not found</div><div class='boxContents'>Sorry, your address ("+ googleMap.Gaddress +") could not be located on a map.</div></div>"
			
		}else{
			d('map_geocode').value = Gpoint;
			d('map').className = 'listingMapDiv';
			googleMap.drawMap(d('map'), Gpoint);
		}
	}
};
