	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="";
	var directionspanel="";
	var map;
	var directionsPanel;
	var directions;
	
	//address and phone number
	var nameplace=0;
	var addressplace=1;
	
	
	var Location=new Array()
		Location[0]=["Dr. Steve Byrd","9101 N. Central Expressway<BR>Suite 600<br>Dallas, TX 75231"];
		

		
		//lat/longs from http://geocoder.us/
	var myLatLong=new Array()
		myLatLong[0]=["32.872854","-96.770478"];
		
	
	//set custom icons by location
	var myIcon=new Array()
		myIcon[0]=["",""];
		
		
		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]);
  			});
 			 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(47.610022, -122.323492), 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]), 15);
				}
				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 mylocationref = window.location.href.replace(/#mapjump/g,'');
				var mylocation = mylocationref+ '?fromdirections=' +  place.address + '&todirections=' + vtodirections;
				myerror="We were unable to find that address. Is this the address you are looking for?<br><a onclick=\"javascript:window.location.href='" +  mylocation +"#mapjump'\">" + place.address + "</a>"  ;
				//alert(myerror);
				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.directionsForm.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';
		}
	}
	
    //]]>

