if (GBrowserIsCompatible()) {
  
  // this variable will collect the html which will eventually be placed in the side_bar
  //var side_bar_html = "";

  // arrays to hold copies of the markers and html used by the side_bar
  // because the function closure trick doesnt work there
  var gmarkers = [];


  // A function to create the marker and set up the event window
  function createMarker(point,name,html) {
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowHtml(html);
	});
	// save the info we need to use later for the side_bar
	gmarkers.push(marker);
	// add a line to the side_bar html
	//side_bar_html += '<a href="javascript:showLocation(' + (gmarkers.length-1) + ')">' + name + '<\/a><br /><br />';
	 return marker;
  }


  // This function picks up the click and opens the corresponding info window
  function showLocation(i) {
	GEvent.trigger(gmarkers[i], "click");
  }


  // create the map
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setCenter(new GLatLng(41.077685,-74.662592), 8);

  // add the points    
  var point = new GLatLng(41.077685,-74.662592);
  var marker = createMarker(point,"<strong>Main Office</strong><br />540 Lafayette Road<br />Sparta, NJ 07871","<strong>Skyview Orthopedic Associates<br />Main Office</strong><br />540 Lafayette Road<br />Sparta, NJ 07871<br /><a href=\"http://maps.google.com/maps?daddr=540+Lafayette+Rd+%23+D,+Sparta,+NJ+07871-3498+(Skyview+Orthopedic+Associates)&geocode=CZvdipPu2KdHFcXPcgIdBbmM-yG7GoR7rMjbHQ&dirflg=&saddr=&f=d&dq=Skyview+Orthopedic+Associates+loc:+540+Lafayette+Rd+Nj&sll=40.973216,-74.652492&sspn=0.253223,0.026838&ie=UTF8&z=16\" target=\"_blank\">Get Directions</a>")
  map.addOverlay(marker);

  var point = new GLatLng(40.8626065,-74.5671662);
  var marker = createMarker(point,"<strong>Satellite Office</strong><br />477 State Route 10<br />College Plaza<br />Randolph, NJ 07869","<strong>Skyview Orthopedic Associates<br />Satellite Office</strong><br />477 State Route 10<br />College Plaza<br />Randolph, NJ 07869<br /><a href=\"http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=477+State+Route+10,+Randolph,+NJ+07869-2142+(Skyview+Orthopedic)&hl=en&geocode=&mra=ls&sll=40.862398,-74.567041&sspn=0.010305,0.015965&ie=UTF8&z=13\" target=\"_blank\">Get Directions</a>")
  map.addOverlay(marker);                                   
				   
  // put the assembled side_bar_html contents into the side_bar div
  //document.getElementById("side_bar").innerHTML = side_bar_html;
  
}

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