	var geocoder = null;
	var myerror="";
	var point=new Array();
	var marker=new Array();
	var myhtml=new Array();
	var CurrentName="";
	var todirections="";
	var vtodirections="";
	var fromdirections="";
	var vfromdirections="";
	
	//address and phone number
	var nameplace=0;
	var addressplace=1;
	var phoneplace=2;
	var urlplace=3;
	
	var Location=new Array()
		Location[0]=["Beach Area Family Health Center","3705 Mission Blvd., San Diego, CA 92109","619-515-2444","/locations/beach-area.cfm"];
		Location[1]=["Beach Area Family Health Center","3690 Mission Blvd., San Diego, CA 92109","619-515-2444","/locations/beach-area.cfm"];
		Location[2]=["Black Infant Health Program","12 N. Euclid Avenue, National City, CA 91950","619-266-7466","/locations/infant-health.cfm"];
		Location[3]=["Chase Avenue Family Health Center","1111 W Chase Avenue, El Cajon, CA 92020","619-515-2499","/locations/chase-ave.cfm"];
		Location[4]=["City Heights Family Health Center","5379 El Cajon Blvd, San Diego, CA 92115","619-515-2400","/locations/city-heights.cfm"];
		Location[5]=["Diamond Neighborhoods Family Health Center","220 Euclid Avenue, Suite 40, San Diego, CA 92114","619-515-2560","/locations/diamond.cfm"];
		Location[6]=["Downtown Family Health Center","1145 Broadway, San Diego, CA 92101","619-515-2525","/locations/downtown.cfm"];
		Location[7]=["Grossmont Spring Valley Family Health Center","8788 Jamacha Road, Spring Valley, CA 91977","619-515-2555","/locations/grossmont.cfm"];
		Location[8]=["KidCare Express Mobile Medical Unit Program","&nbsp;","619-515-2312","/locations/kidcare-express.cfm"];
		Location[9]=["Logan Heights Family Health Center","1809 National Avenue, San Diego, CA 92113","619-515-2300","/locations/logan-heights.cfm"];
		Location[10]=["North Park Family Health Center","3544 30th Street, San Diego, CA 92104","619-683-7570","/locations/north-park.cfm"];
		Location[11]=["Sherman Heights Family Health Center","2391 Island Avenue, San Diego, CA 92102","619-515-2435","/locations/sherman-heights.cfm"];
		Location[12]=["Teen Health Center","1643 Logan Avenue, San Diego, CA 92113","619-515-2333","/locations/teen-health.cfm"];
		Location[13]=["Health & Developmental Services Project Central Region","2114 National Avenue, San Diego, CA 92113","619-515-2406","/locations/first5-central.cfm"];
		Location[14]=["Health & Developmental Services Project East Region","1234 Broadway, El Cajon, CA 92021","619-515-2463","/locations/first5-east.cfm"];
		Location[15]=["HIV Coordinated Services Center","4040 30th Street, San Diego, CA 92104","619-515-2446,","/locations/hiv.cfm"];
		Location[16]=["Logan Heights Family Counseling Center","2204 National Avenue, San Diego, CA 92113","619-515-2355","/locations/lhfcc.cfm"];
		Location[17]=["Chula Vista Family Health Center","251 Landis Avenue, Chula Vista, CA 91910","","/locations/chula-vista.cfm"];
		Location[18]=["Health Education Department","1845 Logan Avenue, San Diego, CA 92113","619-515-2526","/locations/health-education.cfm"];
		Location[19]=["Lemon Grove Family Health Center","7592 Broadway, Lemon Grove, CA 91945","619-515-2550","/locations/lemon-grove.cfm"];
		Location[20]=["HIV Coordinated Services Center","3514 30th Street, San Diego, CA 92104","619-515-2446","/locations/north-park.cfm"];
		Location[21]=["Ciaccio Memorial Clinic","3544 30th Street, San Diego, CA 92104","619-515-2587","/locations/north-park.cfm"];
		Location[22]=["Hillcrest Dental Clinic","3544 30th Street, San Diego, CA 92104","619-515-2587","/locations/north-park.cfm"];
		Location[23]=["Minority AIDS Initiative (MAI) Integrated Services Center","3928 Illinois Street suite 101, San Diego, CA 92104","619-876-4462","/locations/north-park.cfm"];
		//Location[24]=["SEAR Center","324 N. 47th Street, San Diego, CA 92102","619-264-7351","/locations/north-park.cfm"];
		Location[24]=["Community Circle East","3845 Spring Drive, Spring Valley, CA 91977","619-515-2380","/locations/community-circle-east.cfm"];

		//lat/longs from http://geocoder.us/
	var myLatLong=new Array()
		myLatLong[0]=["32.78260","-117.252507"];
		myLatLong[1]=["32.782363","-117.252493"];
		myLatLong[2]=["32.689700","-117.085116"];
		myLatLong[3]=["32.780595","-116.974570"];
		myLatLong[4]=["32.757767","-117.079769"];
		myLatLong[5]=["32.706290","-117.085005"];
		myLatLong[6]=["32.715730","-117.154505"];
		myLatLong[7]=["32.714793","-117.009675"];
		myLatLong[8]=["32.714703","-117.113617"];
		myLatLong[9]=["32.701725","-117.146608"];
		myLatLong[10]=["32.743093","-117.130074"];
		myLatLong[11]=["32.710490","-117.142503"];
		myLatLong[12]=["32.704514","-117.148631"];
		myLatLong[13]=["32.69813","-117.141378"];
		myLatLong[14]=["32.807709","-116.938542"];
		myLatLong[15]=["32.751103","-117.130153"];
		myLatLong[16]=["32.697354","-117.139727"];
		myLatLong[17]=["32.642693","-117.081589"];
		myLatLong[18]=["32.702112","-117.145223"];
		myLatLong[19]=["32.742749","-117.03439"];
		myLatLong[20]=["32.742487","-117.130122"];
		myLatLong[21]=["32.743044","-117.130121"];
		myLatLong[22]=["32.743044","-117.130121"];
		myLatLong[23]=["32.749069","-117.12804"];
		//myLatLong[24]=["32.707984","-117.093936"];	
		myLatLong[24]=["32.749194","-117.003072"];	
	
	//set custom icons by location
	var myIcon=new Array()
		myIcon[0]=["",""];
		myIcon[1]=["",""];
		myIcon[2]=["",""];
		myIcon[3]=["",""];
		myIcon[4]=["",""];
		myIcon[5]=["",""];
		myIcon[6]=["",""];
		myIcon[7]=["",""];
		myIcon[8]=["/images/icon-bus.png","/images/icon-bus-shadow.png"];
		myIcon[9]=["",""];
		myIcon[10]=["",""];
		myIcon[11]=["",""];
		myIcon[12]=["",""];
		myIcon[13]=["",""];
		myIcon[14]=["",""];
		myIcon[15]=["",""];
		myIcon[16]=["",""];
		myIcon[17]=["",""];
		myIcon[18]=["",""];
		myIcon[19]=["",""];
		myIcon[20]=["",""];
		myIcon[21]=["",""];
		myIcon[22]=["",""];
		myIcon[23]=["",""];		
		//myIcon[24]=["",""];
		myIcon[24]=["",""];
	
		var icon = new GIcon();
	
	function createMarker(point, number, icon) {
			icon.image = myIcon[number][0];
			icon.shadow = myIcon[number][1];
			icon.iconSize = new GSize(87, 30);
			icon.shadowSize = new GSize(87, 30);
			icon.iconAnchor = new GPoint(40, 21);
			icon.infoWindowAnchor = new GPoint(40, 12);
		
			if (myIcon[number][0] ==""){
			var marker = new GMarker(point);
			}else{
  			var marker = new GMarker(point, icon);}
  			GEvent.addListener(marker, "click", function() {
  			 marker.openInfoWindowHtml("<b>" + Location[number][nameplace] + "</b><br>" + Location[number][addressplace] + "<br>" + Location[number][phoneplace] + "<br><a href=" + Location[number][urlplace] + ">More info & directions</a>");
  			});
 			 return marker;
		}
		
    function MapLoad(CurrentName,fromdirections,todirections) {
		

		vtodirections=todirections;
	  if (GBrowserIsCompatible()) {
       	 var map = new GMap2(document.getElementById("map"));
		 directionsPanel = document.getElementById("my_textual_div");
		 geocoder = new GClientGeocoder();
  		  
			map.addControl(new GSmallMapControl());
			//map.addControl(new GMapTypeControl());
			map.enableScrollWheelZoom();
			
			map.setCenter(new GLatLng(32.74, -117.1), 11);
			
			var x=0;
			for(x=0;x<Location.length;x++){
				if (Location[CurrentName]==Location[x]){
					map.setCenter(new GLatLng(myLatLong[x][0], myLatLong[x][1]), 14);
				}
				point[x] = new GPoint(myLatLong[x][1], myLatLong[x][0]);
				//show this content in the infowindow when the pointer is clicked
				myhtml[x] = "<b>" + Location[x]+ "</b>";
				// Add the marker as an overlay
			   	map.addOverlay(createMarker(point[x], x, icon));
				}
			
		
			directions = new GDirections(map, directionsPanel);
			
			if (document.forms.directionsForm.fromdirections.value != '') { 
		 		GEvent.addListener(directions, "error", handleErrors);
				directions.load(fromdirections + " to " + todirections);
			 }
				
		}
     }
	
	
	
	 	function addAddressToMap(response) {
      		//map.clearOverlays();
      		if (!response || response.Status.code != 200) {
				myerror="No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect." ;
      		  	document.getElementById("diverror").style.display ='block';
				document.getElementById("diverror").innerHTML = myerror ;
     		 } else {
			 	place = response.Placemark[0];
				var mylocation = document.referrer;
				myerror="We were unable to find that address. Is this the address you are looking for?<br><a onclick=\"javascript:window.location.href='" +  mylocation + "?fromdirections=" +  place.address + "&todirections=" + vtodirections +"#mapjump'\">" + place.address + "</a>"  ;
				document.getElementById("diverror").style.display ='block';
				document.getElementById("diverror").innerHTML = myerror ;
      		}
			if (myerror !="")  document.getElementById("my_textual_div").style.display ='none';
			
			
   		 }

	
	  function handleErrors(){
	  var address = document.forms[0].fromdirections.value;
	
	   if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS){
	   		geocoder.getLocations(address, addAddressToMap);
		}else if (directions.getStatus().code == G_GEO_SERVER_ERROR){
			document.getElementById("diverror").style.display ='block';
	    	myerror="A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known." ;
	  	}else if (directions.getStatus().code == G_GEO_MISSING_QUERY){
			document.getElementById("diverror").style.display ='block';
			myerror ="The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input." ;
	 	}else if (directions.getStatus().code == G_GEO_BAD_KEY)	{
			document.getElementById("diverror").style.display ='block';
			myerror = "The given key is either invalid or does not match the domain for which it was given." ;
	   } else if (directions.getStatus().code == G_GEO_BAD_REQUEST) {
			document.getElementById("diverror").style.display ='block';
			myerror = "A directions request could not be successfully parsed." ;
	    }else {
	   		document.getElementById("diverror").style.display ='block';
			myerror = "An unknown error occurred." 
		}
		if (myerror !=""){
			document.getElementById("diverror").innerHTML = myerror ;
			document.getElementById("my_textual_div").style.display ='none';
		}
	}
	
    //]]>


