// <!--
		function getParameter ( queryString, parameterName ) {
		   var parameterName = parameterName + "=";
		   if ( queryString.length > 0 ) {

			  begin = queryString.indexOf ( parameterName );
			  if ( begin != -1 ) {
				 begin += parameterName.length;
				 end = queryString.indexOf ( "&" , begin );
			  if ( end == -1 ) {
				 end = queryString.length
			  }
			  return unescape ( queryString.substring ( begin, end ) );
		   }
		   return "null";
		   }
		}
		
    if (GBrowserIsCompatible()) {
      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
		
	//custom icon
		var iconGIN = new GIcon(); 
		iconGIN.image = 'images/logoman.png';
		iconGIN.iconSize = new GSize(40, 40);
		iconGIN.iconAnchor = new GPoint(20, 20);
		iconGIN.infoWindowAnchor = new GPoint(20, 20);
		
		var parkingIcon = new GIcon(); 
		parkingIcon.image = 'http://maps.google.com/mapfiles/ms/micons/parkinglot.png';
		parkingIcon.shadow = 'http://maps.google.com/mapfiles/ms/micons/parkinglot.shadow.png';
		parkingIcon.iconSize = new GSize(30, 30);
		parkingIcon.iconAnchor = new GPoint(15, 15);
		parkingIcon.infoWindowAnchor = new GPoint(15, 15);
		
		  
	  function createMarker(point,name,html) {
		var marker = new GMarker(point, {icon: iconGIN, title: name});
		var i = gmarkers.length;

		to_htmls[i] = '<div style="width:300px;height:180px">'+html + '<hr/><span class="dir">' + 'Start address:<form action="javascript:getDirections()">' +
		   '<input type="text" SIZE=35 MAXLENGTH=40 name="saddr" id="saddr" value="" />' +
		   '<INPUT value="Go" TYPE="SUBMIT"><br>' +
		   '<span class="hide">Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" /></span><input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + '"/></span></div>';
		from_htmls[i] = '<div style="width:300px;height:180px">'+html + '<hr/><span class="dir">' + 'End address:<form action="javascript:getDirections()">' +
		   '<input type="text" SIZE=35 MAXLENGTH=40 name="daddr" id="daddr" value="" />' +
		   '<INPUT value="Go" TYPE="SUBMIT"><br>' +
		   '<span class="hide">Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" /></span>' +
		   '<input type="hidden" id="saddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +'"/></span></div>';
		html = '<div style="width:300px;height:140px">'+html + '<hr/><span class="dir">Directions: <a href="javascript:tohere('+i+')">To here<\/a> - <a href="javascript:fromhere('+i+')">From here<\/a><\/span></div>';

		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml(html);
		});
		gmarkers.push(marker);
		htmls[i] = html;

		return marker;
	  }
	  
	  function createParkingMarker(point,name,html) {
		var marker = new GMarker(point, {icon: parkingIcon, title: name});
		var i = gmarkers.length;

		to_htmls[i] = '<div style="width:300px;height:190px">'+html + '<hr/><span class="dir">' + 'Start address:<form action="javascript:getDirections()">' +
		   '<input type="text" SIZE=35 MAXLENGTH=40 name="saddr" id="saddr" value="" /><INPUT value="Go" TYPE="SUBMIT"><br>' +
		   '<span class="hide">Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" /></span>' +
		   '<input type="hidden" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +'"/></span></div>';
		from_htmls[i] = '<div style="width:300px;height:190px">'+html + '<hr/><span class="dir">' + 'End address:<form action="javascript:getDirections()">' +
		   '<input type="text" SIZE=35 MAXLENGTH=40 name="daddr" id="daddr" value="" /><INPUT value="Go" TYPE="SUBMIT"><br>' +
		   '<span class="hide">Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" /></span>' +
		   '<input type="hidden" id="saddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +'"/></span></div>';
		html = '<div style="width:300px;height:150px">'+html + '<hr/><span class="dir">Directions: <a href="javascript:tohere('+i+')">To here<\/a> - <a href="javascript:fromhere('+i+')">From here<\/a><\/span></div>';

		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml(html);
		});
		gmarkers.push(marker);
		htmls[i] = html;

		return marker;
	  }

	  // ===== request the directions =====
	  function getDirections() {
		// ==== Set up the walk and avoid highways options ====
		var opts = {};
		if (document.getElementById("walk").checked) {
		   opts.travelMode = G_TRAVEL_MODE_WALKING;
		}
		if (document.getElementById("highways").checked) {
		   opts.avoidHighways = true;
		}
		// ==== set the start and end locations ====
		var saddr = document.getElementById("saddr").value
		var daddr = document.getElementById("daddr").value
		gdir.load("from: "+saddr+" to: "+daddr, opts);
		document.getElementById("directions").style.display = "block";
	  }

	  
	  // This function picks up the click and opens the corresponding info window
	  function myclick(i) {
		gmarkers[i].openInfoWindowHtml(htmls[i]);
	  }

	  // functions that open the directions forms
	  function tohere(i) {
		gmarkers[i].openInfoWindowHtml(to_htmls[i]);
	  }
	  function fromhere(i) {
		gmarkers[i].openInfoWindowHtml(from_htmls[i]);
	  }

	function clearDirections(){
		if(typeof( window[ 'gdir' ] ) != "undefined"){
			gdir.clear();
		}
		document.getElementById("directions").style.display = "none";
		map.setCenter(new GLatLng(37.789954, -122.400956), 15);
	}
	
	  // create the map
	  var map = new GMap2(document.getElementById("map"));
	  map.addControl(new GLargeMapControl3D());
	  map.addControl(new GHierarchicalMapTypeControl());
	  map.setCenter(new GLatLng(37.789954, -122.400956), 15);
	  
	  var point = new GLatLng(37.789954, -122.400956);
	  var label = "GreenInfo Network";
	  var html = "<b>GreenInfo Network</b><p>Our office is in the Chancery Building. Entry is via a public street-level mall with doors on both Market St and Sutter St. Visitors please sign in at the security desk before taking elevator to fifth floor.</p>";
	  var marker = createMarker(point,label,html,iconGIN);
	  map.addOverlay(marker);
	  
	  var point2 = new GLatLng(37.786793,-122.400192);
	  var label2 = "SFMOMA Garage";
	  var html2 = "<b>SFMOMA Garage</b><p>To enter, must pass SF Museum of Modern Art on Third St (one-way northbound) and turn right immediately after museum into Minna St. Garage is on right, midblock.</p>";
	  var marker2 = createParkingMarker(point2,label2,html2);
	  map.addOverlay(marker2);
	  
	  var point3 = new GLatLng(37.789831218,-122.4033239);
	  var label3 = "Ampco System Parking";
	  var html3 = "<b>Ampco System Parking</b><p>Entrance is on Sutter St between Montgomery and Kearny. Sutter is one-way street heading west; entrance is on left.</p>";
	  var marker3 = createParkingMarker(point3,label3,html3);
	  map.addOverlay(marker3);
	  
	  var point4 = new GLatLng(37.7897,-122.406906);
	  var label4 = "Sutter-Stockton Garage";
	  var html4 = "<b>Sutter-Stockton Garage</b><p>Easiest entrance is from right side of Bush St (one-way eastbound) where it crosses over Stockton on a bridge. Can also enter by turning right from Sutter (one-way westbound) onto Stockton. Third entrance: turn left from Stockton after passing through Stockton Tunnel from Chinatown.</p>";
	  var marker4 = createParkingMarker(point4,label4,html4);
	  map.addOverlay(marker4);
	  

	  // ======== enable scroll wheel navigation ==========
	  map.enableScrollWheelZoom();

	  // === create a GDirections Object ===
	  var gdir=new GDirections(map, document.getElementById("directions"));

	  // === Array for decoding the failure codes ===
	  var reasons=[];
	  reasons[G_GEO_SUCCESS]            = "Success";
	  reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
	  reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
	  reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
	  reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
	  reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
	  reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
	  reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
	  reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
	  reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";

	  // === catch Directions errors ===
	  GEvent.addListener(gdir, "error", function() {
		var code = gdir.getStatus().code;
		var reason="Code "+code;
		if (reasons[code]) {
		  reason = reasons[code]
		} 

		alert("Failed to obtain directions, "+reason);
	  });
		  
		  
		map.setCenter(new GLatLng(37.789954, -122.400956), 15);
		

		var jumpto = getParameter(window.location.href,"j");
		var showdirections = getParameter(window.location.href,"s");
		if(jumpto=="contact" && showdirections=="directions"){
			map.checkResize();
			map.setCenter(new GLatLng(37.789954,-122.400956),15);
			var show = '<div style="width:300px;height:140px"><b>GreenInfo Network</b><p>Our office is in the Chancery Building. Entry is via a public street-level mall with doors on both Market St and Sutter St. Visitors please sign in at the security desk before taking elevator to fifth floor.</p><hr/><span class="dir">Directions: <a href="javascript:tohere(0)">To here<\/a> - <a href="javascript:fromhere(0)">From here<\/a><\/span></div>';
			map.openInfoWindow(new GLatLng(37.789954, -122.400956), show);
		}

	}

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
	
// -->