//<![CDATA[
document.write ('<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>');

var map;
var geocoder;
var search_result;
var first_search;

function initialize()
{
	geocoder = new google.maps.Geocoder();
	var coverage_poly;
	
	var focus = new google.maps.LatLng(-31.956153,115.86471);
	var myOptions = {
		zoom: 15,
		center: focus,
		mapTypeId: google.maps.MapTypeId.TERRAIN,
		scrollwheel: false
	};
	map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);

	var coverage_boundry = [
		new google.maps.LatLng(-31.95474210519948,115.8508106107264),
		new google.maps.LatLng(-31.96298889320836,115.8784961848324),
		new google.maps.LatLng(-31.9608250895976, 115.8805227473533),
		new google.maps.LatLng(-31.95567917835447,115.8645867966356),
		new google.maps.LatLng(-31.95374033450185,115.8654722075548),
		new google.maps.LatLng(-31.94878505994987,115.8504033505886),
		new google.maps.LatLng(-31.95110237304087,115.8492473577502),
		new google.maps.LatLng(-31.95474210519948,115.8508106107264)
	];
	
	coverage_poly = new google.maps.Polygon({
		paths: coverage_boundry,
	    strokeColor: "#FFFFFF",
	    strokeOpacity: 0.8,
	    strokeWeight: 2,
	    fillColor: "#00FF00",
	    fillOpacity: 0.30
	});
	
	coverage_poly.setMap(map);
	
	first_search = true;
	document.getElementById("address").disabled = "";
	document.getElementById("geocode_button").disabled = "";
}

function geocodeAddress()
{
	var address = document.getElementById("address").value;
	if (geocoder)
	{
		geocoder.geocode( { 'address': address },
			function(results, status)
			{
				if (status == google.maps.GeocoderStatus.OK)
				{
					if (!first_search)
						searchresult.setMap(null);

					map.setCenter(results[0].geometry.location);
					searchresult = new google.maps.Marker({
						map: map, 
						position: results[0].geometry.location,
						clickable: false
					});

					first_search = false;
				} else {
					alert("Unable to locate the address: " + status);
				}
			}
		);
	}
}

document.observe("dom:loaded", function() {	initialize(); });
//]]>


