	var Locations = {
		map:null,
		cache:null,
		geocoder:null,
		markers:null,
		search:null,
		timer:null,
		handlers:{},
		init:function(map_id){		
	      	//init map
			if (map_id && GBrowserIsCompatible()) {	
				Locations.map = new GMap2(document.getElementById(map_id));
	        	Locations.map.setCenter(new GLatLng(44.40, -73.2), 9);
	      		var keys = new GKeyboardHandler(Locations.map);

			}else if(map_id){
				document.getElementById(map_id).innerHTML = "<p>Please upgrade your browser to make use of this map.</p>";
			}
			
			Locations.map.addControl(new GSmallMapControl());	
			Locations.cache = new GGeocodeCache();
			Locations.geocoder = new GClientGeocoder(Locations.cache); 

			//set up custom controls?

		},
		//display a point from the locations 
		display:function(lat, lng){	
				
				var point = new GLatLng(lat, lng);
				var marker = new GMarker(point);
					marker.show();

				 Locations.map.addOverlay(marker);	
				 //var addy = location.address == "" ? "" : location.address + ", ";
				 //marker.openInfoWindowHtml("<p>" + addy + location.city + ", " + location.state + ", " + location.zip + "</p>");

				Locations.map.setCenter(point);	
				Locations.map.setZoom(14);
		},
		lookup:function(form_obj, address){
			//construct address to lookup from form. 
			if(!address){ 
			 	address = "";
				for(var e = 2; e < 8; e++)
					address += form_obj.elements[e].value + " "; 
			}
			document.getElementById("status").innerHTML = "Looking up location " + address;
			
			 if(Locations.handlers.onLoading) Locations.handlers.onLoading();
			 Locations.geocoder.getLocations( address ,
				function(location) {
					if(location.Placemark){
						var lat 		= location.Placemark[0].Point.coordinates[1];
						var lng 		= location.Placemark[0].Point.coordinates[0];
						if(document.getElementById("dealer_lat")){
							document.getElementById("dealer_lat").value = lat;
							document.getElementById("dealer_lng").value = lng;
							document.getElementById("save_btn").className = "submit";							
							Locations.display(lat, lng);		
						}
						document.getElementById("status").innerHTML = "Location found.";
						//Batch.cool({"lat":lat,"lng":lng});
					}else{
						document.getElementById("status").innerHTML = "Location NOT found! Please enter a location manually";
						//Batch.fail({"lat":false});
					}
				});
		}	
	}