	function isUndefined(a) {
	    return typeof a == 'undefined';
	} 


	// class location 
	function FLocation(name) { 
		this.name = name;
	}
	
	//class methods
	
	//get methods
	FLocation.prototype.getName = function () { return this.name; };  
	FLocation.prototype.getLng = function () { return this.lng; };  
	FLocation.prototype.getLat = function () { return this.lat; };
	FLocation.prototype.getType = function () { return this.fax; };
	FLocation.prototype.getStreet = function () { return this.street; };
	FLocation.prototype.getCity = function () { return this.city; };
	FLocation.prototype.getState = function () { return this.state; };
	FLocation.prototype.getZip = function () { return this.zip; };
	FLocation.prototype.getPhone = function () { return this.phone; };
	FLocation.prototype.getFax = function () { return this.fax; };
	FLocation.prototype.getHours = function () { return this.hours; };
	//readonly 
	FLocation.prototype.getHTML = function () {  
		html =  "<div class='marker' >";
		html +=  "   <h5>"+this.city+"</h5>";
		html += "    <p>"+this.street+"<br />"+this.city+", "+this.state+" "+this.zip+"</p>";
		html += "    <p> Phone: "+this.phone;
		if ( "" != this.fax) {
			html += "<br />Fax: "+this.fax;
		}
		html += "</p>";
		html += this.hours;
		html += "    <p class='link'><a href='products/"+this.type+"'>"+this.type+" page</a></p>";
		html += "    <p style='text-align:right;' class='link'><a href='locations/"+this.name+"'>more info on this location</a></p>";
 		html += "</div>";
 		return html;
	};
	
	//set methhods			
	FLocation.prototype.setName = function ( name ) { this.name = parseFloat(name); };  
	FLocation.prototype.setLng = function ( lng ) { this.lng = parseFloat(lng); };  
	FLocation.prototype.setLat = function ( lat ) { this.lat = parseFloat(lat); };
	FLocation.prototype.setType = function ( type ) {this.type = type; };
	FLocation.prototype.setStreet = function ( street ) { this.street = street; };
	FLocation.prototype.setCity = function ( city ) { this.city = city; };
	FLocation.prototype.setState = function ( state ) { this.state = state; };
	FLocation.prototype.setZip = function ( zip ) { this.zip = zip; };
	FLocation.prototype.setPhone = function ( phone ) { this.phone = phone; };
	FLocation.prototype.setFax = function ( fax ) { this.fax = fax; };
	FLocation.prototype.setHours = function ( hours ) { this.hours = hours; };
		
	
	// Creates a marker whose info window displays the given number
	function createMarker(point, html) {
	
		var baseIcon = new GIcon();
		baseIcon.iconSize = new GSize(24, 25);
		baseIcon.shadow = "/themes/big-creek/images/marker_icon_shadow.png";
		baseIcon.shadowSize = new GSize(42, 25);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(10, 1);
		baseIcon.infoShadowAnchor = new GPoint(42, 0);
		
		// Show this marker's index in the info window when it is clicked
		if ( isUndefined(html) ) {
			html = "POINT <b> (" + point.x + ", "  + point.y + ") </b>";
			var marker = new GMarker(point);
		}
		else {
			var icon = new GIcon(baseIcon);
	 		icon.image = "/themes/big-creek/images/marker_icon.png";
			var marker = new GMarker(point, icon);
		}
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
		});
		
		return marker;
	}
	
	var aLocations = new Array();

	// Creates a marker whose info window displays the given number
	function loadLocations(map) {

		for (var i in aLocations ) {
	  		var point = new GPoint( aLocations[i].getLng(), aLocations[i].getLat() );
			var marker = createMarker(point, aLocations[i].getHTML());
	      	map.addOverlay(marker);
	    }
	    
	} //end loadLocations()

	var map = new Object();


	function loadMap() {
	
	   	if ( GBrowserIsCompatible()) {
	 	
	 		map = new GMap(document.getElementById("map"));
			//map.addControl(new GSmallMapControl());
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.centerAndZoom(new GPoint(-121.600, 36.635), 9);
/*	
			//adds point to get x, y on map, work out locations
			GEvent.addListener(map, 'click', 
				function(overlay,point) {
					if (point) {
						map.addOverlay(createMarker(point));
					}
				}
			);
*/	  
			try { 
				loadLocations(map);
			}
			catch (error) {
				alert("Error : " + error );
			}
			
		} else {
			//TODO do nothing and show static map 
			alert("Your browser is not compatable with Google Maps"); 
		}
		
	} //end loadMap()
  

	function centerOn(location) {
		map.centerAndZoom(new GPoint(aLocations[location].getLng(),aLocations[location].getLat()),2);

	}
