	var dc_map;
	var dc_map_address_unprocessed = new Array();
	var dc_map_address_unprocessed_counter = 0;
	var dc_map_address_array = new Array();
	var dc_map_name_array = new Array();
	var dc_map_marker_array = new Array();
	var dc_map_icon_array = new Array();	
	var dc_map_start_location = false;
	var dc_map_start_lat;
	var dc_map_start_lng;
	var dc_map_start_zoom;
	var dc_map_current_marker;
	var geocoder = new GClientGeocoder();
	
	function dc_map_get_geocode() {
		var array_index = dc_map_address_unprocessed[dc_map_address_unprocessed_counter++];
		var address = dc_map_address_array[array_index];		
		geocoder.getLatLng(address,    
			function(point) {      
			  if (!point) {
				if(!dc_map_silence_error_message) {
				    alert(address + " not found");      
				}
				xmlhttp_request('/mp','mp=html&html=xmlhttp_dc_map&mapnd='+dc_map_nd+'&mapaddress='+address+'&mapx=fail&mapy=fail');
			  } else {        
			  	dc_map_geocode[address] = point;
				dc_show_address(array_index);
				// save this via ajax
				xmlhttp_request('/mp','mp=html&html=xmlhttp_dc_map&mapnd='+dc_map_nd+'&mapaddress='+address+'&mapx='+point.x+'&mapy='+point.y);
			  }    
		    }  
	    );
		// we are putting in a delay otherwise google will shutdown our geocoding
		if(dc_map_address_unprocessed_counter<dc_map_address_unprocessed.length) {
			setTimeout("dc_map_get_geocode()", 2000);
		}
	}	
		
	function dc_map_address(address,name,icon) {
		var array_loc = dc_map_address_array.length;
		dc_map_address_array[array_loc] = address;
		if(name!=null) {
			dc_map_name_array[array_loc] = name;
		}
		if(icon!=null) {
			dc_map_icon_array[array_loc] = icon;			
		}
	}

	function dc_show_address(array_index,showinfo) {	
		var address = dc_map_address_array[array_index];
		var name = dc_map_name_array[array_index];
		var icon = dc_map_icon_array[array_index];
		
        var point = dc_map_geocode[address];
	
		if(!point) {
			// now we need to fetch this via the google geocoding
			dc_map_address_unprocessed[dc_map_address_unprocessed.length] = array_index;
		} else if (point=="fail") {
			// fail silently
	    } else {
			var marker = new GMarker(point,icon);
			var addressinfo = get_dc_address_info(name,address);
		    dc_map.addOverlay(marker);
			GEvent.addListener(marker, "click", function() {  marker.openInfoWindowHtml(addressinfo);  });
			if(showinfo) {
			    marker.openInfoWindowHtml(addressinfo);
				dc_map.setCenter(point,13);
			}		
			dc_map_marker_array[array_index] = marker;
		}
	}	
	
	function dc_maps_start_location(lat,lng,zoom) {
		dc_map_start_location = true;
		dc_map_start_lat = lat;
		dc_map_start_lng = lng;
		dc_map_start_zoom = zoom;
	}
	
	function get_dc_address_info(name,address) {
		var addressinfo = '';
		if(name!=null) {
			addressinfo = '<b>' + name + '</b><br>';
		}
		addressinfo += address;
		return addressinfo;
	}
	
	function dc_maps_go(location) {
		dc_map_current_marker = location;
	    dc_map.setCenter(dc_map_marker_array[location].getPoint(), 13);
		dc_map_marker_array[location].openInfoWindowHtml(get_dc_address_info(dc_map_name_array[location],dc_map_address_array[location]));
	}
	
	if (window.onload != null) {	
		var previous_onload = window.onload;
		window.onload = function(e) {
			previous_onload(e);
			dc_load_maps();
		}
	} else {
		window.onload = dc_load_maps;
	}
	
	function dc_maps_go_center() {
		if(dc_map_start_location) {
			dc_map.setCenter(new GLatLng(dc_map_start_lat,dc_map_start_lng), dc_map_start_zoom);
		}
		if(dc_map_current_marker) {
			dc_map_marker_array[dc_map_current_marker].closeInfoWindow();
			dc_map_current_marker = null;
		}
	}
	
	function dc_load_maps() {
	
		if (GBrowserIsCompatible()) {	
			// create the map in the 'map' div
			dc_map = new GMap2(document.getElementById("dc_map"));
		    dc_map.setCenter(new GLatLng(0, 0), 13);
			dc_map.addControl(new GSmallMapControl());
	        dc_map.addControl(new GMapTypeControl());
						
			var showinfo=false;
			for(var j=0;j < dc_map_address_array.length;j++) {
				if(dc_map_start_location==false && j==dc_map_address_array.length-1) { 
					showinfo = true;
				}
				dc_show_address(j,showinfo);
			}
			if(dc_map_start_location) {
				dc_map.setCenter(new GLatLng(dc_map_start_lat,dc_map_start_lng), dc_map_start_zoom);
			}
			if(dc_map_address_unprocessed.length > 0) {
				dc_map_get_geocode();
			}
		}
	}	
