	var geocoder = null;
	var myerror="";
	var point=new Array();
	var marker=new Array();
	var myhtml=new Array();
	//var Location = new Array();
	var CurrentName="";
	var todirections="";
	var vtodirections="";
	var fromdirections="";
	var vfromdirections="";
	
	//address and phone number
	var nameplace=0;
	var doctorplace=1;
	var addressplace=2;
	var phoneplace=3;
	var urlplace=4;
	var idplace=5;
	var listiconplace=6;
		
//	alert (Location[0]);
//	alert("test " + Location.length);	
	
		
	var icon = new GIcon();
	
	function createMarker(point, number, icon) {
			icon.image = myIcon[number][0];
			icon.shadow = myIcon[number][1];
			icon.iconSize = new GSize(30, 32);
			icon.shadowSize = new GSize(30, 32);
			icon.iconAnchor = new GPoint(10, 5);
			icon.infoWindowAnchor = new GPoint(10, 5);
		//alert(Location[number].length);
			if (myIcon[number][0] ==""){
			var marker = new GMarker(point);
			}else{
  			var marker = new GMarker(point, icon);}
  			GEvent.addListener(marker, "click", function() {
			html="";
			for(x=0;x<Location[number].length;x++){
			//alert(Location[number][x][addressplace]);
				if (Location[number][x][nameplace] != "" && Location[number][x][doctorplace] != ""){
  					html=html+"<h2 class='map'>" + Location[number][x][nameplace] + Location[number][x][listiconplace] + "</h2>" + "<h3 class='map'>" + Location[number][x][doctorplace] + "</h3>" +  "<p class='map'>" + Location[number][x][addressplace] + "<br>" + Location[number][x][phoneplace] + "<br><a href=" + Location[number][x][urlplace] + ">Phone & Directions</a>" + "<br><a href=/request.cfm/locationid/" + Location[number][x][idplace] + ">Request information</a></p>"
  				} else if (Location[number][x][doctorplace] != "") {
					html=html+ "<h2 class='map'>" + Location[number][x][doctorplace] + Location[number][x][listiconplace] + "</h2>" + "<p class='map'>" + Location[number][x][addressplace] + "<br>" + Location[number][x][phoneplace] + "<br><a href=" + Location[number][x][urlplace] + ">Phone & Directions</a>" + "<br><a href=/request.cfm/locationid/" + Location[number][x][idplace] + ">Request information</a></p>"
				} else {
					html=html+ "<h2 class='map'>" + Location[number][x][nameplace] + Location[number][x][listiconplace] + "</h2>" + "<p class='map'>" + Location[number][x][addressplace] + "<br>" + Location[number][x][phoneplace] + "<br><a href=" + Location[number][x][urlplace] + ">Phone & Directions</a>" + "<br><a href=/request.cfm/locationid/" + Location[number][x][idplace] + ">Request information</a></p>"
				}
				marker.openInfoWindowHtml(html);
			}
			});
 			 return marker;
		}
		
    function MapLoad(center,myzoom,CurrentName,fromdirections,todirections) {
		vtodirections=todirections;
		//alert(center);
		//alert(Location[center]);
	  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();
			
			if (myzoom==undefined){
				var myzoom=12
			}
			
			if (z==undefined){
				var z=0
			}
			
			map.setCenter(new GLatLng(myLatLong[center][0], myLatLong[center][1]), myzoom);
		//	map.setCenter(new GLatLng(mycenter[0][0], mycenter[0][1]), myzoom);
			//alert("test " + Location[0].length);	
			var x=0;
			for(x=0;x<Location.length;x++){
				//if (Location[CurrentName]==Location[x]){
			//	alert(myLatLong[x][0], myLatLong[x][1]);
				
				//}
		
					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
					
					if (point[x] !="(, )"){
			   			map.addOverlay(createMarker(point[x], x, icon));
						//if (x==Math.ceil(Location.length/2)){
							//map.setCenter(new GLatLng(myLatLong[x][0], myLatLong[x][1]), myzoom);
						//}
						
					}
				}
			
		
			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 myaddress= place.address;
				myaddress = myaddress.replace(/, USA/g,'')
				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/" +  myaddress + "/todirections/" + vtodirections + "/" +"'\">" + myaddress + "</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.getElementById("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';
		}
	}
	
    //]]>


