var GoogleMaps = {
	
	geocoder : null,
	addresses : null,
	current_address : 0,
	
	init : function(addresses) {
		
		GoogleMaps.geocoder = new GClientGeocoder();
		GoogleMaps.addresses = addresses;
		GoogleMaps.geocodeAddress();
	},
	
	geocodeAddress : function() {
		
		var address = GoogleMaps.addresses[(GoogleMaps.current_address)];
		GoogleMaps.current_address++;
		
		if (GoogleMaps.current_address > GoogleMaps.addresses.length) {
			
			$("#listing-map").remove();
			return false;
			
		} else {
		
			if (address) {
			
				if (GoogleMaps.geocoder) {
				
					GoogleMaps.geocoder.getLatLng(address, function(point) {
				
						if (!point) {
							GoogleMaps.geocodeAddress();
						} else {
							GoogleMaps.showAddress(point);
						}
					});
				}
			}
		}
	},

	showAddress : function(point) {
		
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.setCenter(point, 13);
		var marker = new GMarker(point);
		map.addOverlay(marker);
	}
}
$(window).unload(GUnload());