    // A function to create the marker and set up the event window
    function createMarker(point,html) {
    	var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html,{maxWidth:150});
        });

        return marker;
    }

	// A function to create a tabbed marker and set up the event window
	// This version accepts a variable number of tabs, passed in the arrays htmls[] and labels[]
	function createTabbedMarker(point,htmls,labels) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
		
			// adjust the width so that the info window is large enough for this many tabs
			if (htmls.length > 2) {
				htmls[0] = '<div style="width:'+htmls.length*88+'px">' + htmls[0] + '</div>';
			}
		
			var tabs = [];
		
			for (var i=0; i<htmls.length; i++) {
				tabs.push(new GInfoWindowTab(labels[i],htmls[i]));
			}
		
			marker.openInfoWindowTabsHtml(tabs);
		});
		
		return marker;
	}
      
      // This function picks up the click and opens the corresponding info window
    function getMarker(m) {
    	gmarkers[m].openInfoWindowHtml(htmls[m],{maxWidth:150});
    }
	  	
    function load() {
      if (GBrowserIsCompatible()) {
  		  
        var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GScaleControl());	

		//check to see if staticMap is defined, if not set default value (false)
		staticMap = typeof(staticMap) != 'undefined' ? staticMap : false;
	
		//site/locales array key: 0 = title, 1 = latitude, 2 = longitude, 3 = street address 1, 4 = street address 2, 5 = city, 6 = state, 7 = zip code, 8 = distance		
		if (staticMap) {	
			site = explodeArray(locales[0], ','); //will always be 0
			var point = new GLatLng(zipLat, zipLong);
			map.setCenter(point, 15);

			var mHTML = "<div class='infoWindow'><b>" + trim(site[0]) + "</b><br>" + trim(site[3]) + "<br>" + trim(site[5]) + ", " + 
						trim(site[6]) + " " + trim(site[7]) + "</div>";		
						
			var gDirectionsHTML = "<input type=\"text\" name=\"sAddress\" id=\"sAddress\" />&nbsp;<input type=\"button\" value=\"Go\" />";
			
			var marker = createMarker(point,mHTML);					
			//var marker = createTabbedMarker(point, [mHTML,gDirectionsHTML],["Address", "Directions"]);
			map.addOverlay(marker);			
		} else {
			for (i = 0; i < locales.length; i++){
				site = explodeArray(locales[i], ',');
				if (site[1] != '  '){
					//add address to map
					//alert(site[1]);
					showAddress(site, map, i);			
				} //if (site[1] != ' ')
			} // for (i=0; i < locales.length; i++)					
		}//if (staticMap)			
	  } //if (GBrowserIsCompatible())
    } //function load()
	
	function showAddress(site, map, index){
		var point = new GLatLng(site[1], site[2]);
		var Zippoint = new GLatLng(zipLong, zipLat);

		//determine zoom level based on tolerance
		if (tolerance == 25) {
			map.setCenter(Zippoint, 9);
		} else if (tolerance == 50) {
			map.setCenter(Zippoint, 7);
		} else if (tolerance == 100) {
			map.setCenter(Zippoint, 6);
		}
			
		var mHTML = '<div class="infoWindow"><b>' + trim(site[0]) + '</b><br>' + trim(site[3]) + '<br>' + trim(site[5]) + ', ' + 
					trim(site[6]) + ' ' + trim(site[7]) + '<br>' + trim(site[8]) + ' mile' + ((site[8] > 1 || site[8] == 0) ? 's' : '') + 
					' &bull; <a href="http://maps.google.com/maps?saddr=' + zip + '&daddr=' + trim(site[3].replace(/\s/g,"+")) + 
					trim(site[5].replace(/\s/g,"+")) + trim(site[6].replace(/\s/g,"+")) + trim(site[7].replace(/\s/g,"+")) + 
					'" target="_blank">Get Directions</a></div>';
		
		var marker = createMarker(point,mHTML);					
		map.addOverlay(marker);

   	    // save the info we need to use later for our location list links	
		gmarkers[g] = marker;
		htmls[g] = mHTML;
				
		//increment our counter variable g
		g++; 
	}
	
	//this function validates our search required fields
	function validateSearch(theForm) {
		
		var allValid = true;
		//the possible combinations are as follow
		//1. Zip code only
		//2. City & State
		if ((theForm.zip.value.length < 5 || trim(theForm.zip.value) == '' || !IsNumeric(trim(theForm.zip.value))) && (theForm.city.value.length == 0 && theForm.state.selectedIndex == 0)) {
			alert("Please enter a valid zip code OR a valid city and state.");
			allValid = false;
		} else {
			if (theForm.zip.value.length == 0) {
				if (theForm.city.value.length == 0 && theForm.state.selectedIndex == 0
					|| theForm.city.value.length > 0 && theForm.state.selectedIndex == 0
					|| theForm.state.selectedIndex > 0 && theForm.city.value.length == 0) {
					alert("Please enter the City and State or search by Zip code.");
					allValid = false;
				} //if (theForm.city.value.length == 0 && theForm.state.selectedIndex == 0 || theForm.city.value.length > 0 && theForm.state.selectedIndex == 0 || theForm.state.selectedIndex > 0 && theForm.city.value.length == 0)
			} //if (theForm.zip.value.length == 0)
		} //if ((theForm.zip.value.length == 0 || theForm.zip.value == '') && (theForm.city.value.length == 0 && theForm.state.selectedIndex == 0))
		
		return allValid;
	}