var Geocoder;
var map;
var markersArray = [];
var infowindow;

function initialiseGoogleMap() {
	Geocoder 	= new google.maps.Geocoder();
	var latlng 	= new google.maps.LatLng(-33.8661470,151.2054850);
	var myOptions = {
		zoom: 15,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

function setMainAddress(address,markerTitle,contentString) {
	if (Geocoder) {
		Geocoder.geocode( { "address": address, "region":"au"}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				var marker = new google.maps.Marker({
					position: results[0].geometry.location
					,map: map 
					,title: markerTitle
					,icon: 'http://www.century21.com.au/c21/images/googleMapMarkerHouse.png'
					,shadow: 'http://www.century21.com.au/c21/images/googleMapMarkerHouseShadow.png'
				})
				infowindow = new google.maps.InfoWindow({
					content: "",
					position: results[0].geometry.location
				});
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.setContent(contentString)
					infowindow.open(map,marker);
				});
			} else {
				//alert("Geocode was not successful for the following reason: " + status);
			}
		})
	}
}

function addMarker(address,markerTitle,contentString) {
	if (Geocoder) {
		Geocoder.geocode( { "address": address, "region":"au"}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				var marker = new google.maps.Marker({
					position: results[0].geometry.location
					,map: map
					,title: markerTitle
					,icon: 'http://www.century21.com.au/c21/images/googleMapMarkerSmallOrange.png'
					,shadow: 'http://www.century21.com.au/c21/images/googleMapMarkerSmallShadow.png'
				});
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.setContent(contentString)
					infowindow.open(map,marker);
				});
			}
		})
	}
}

