$(document).ready(function() {
  var options = {
    mapTypeControl: false,
    zoom: 15,
    center: new google.maps.LatLng(35.592866, -81.830935),
    mapTypeId: google.maps.MapTypeId.SATELLITE
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"),
                                options);
  setMarkers(map, markers);
});
 
/**
 * Data for the markers consisting of a name, a LatLng and a zIndex for
 * the order in which these markers should display on top of each
 * other.
 */
var markers = [
  ['Hassco Industries', 35.592866, -81.830935, 4, '<h3>Carolina Powersports Park</h3><br /><a target="blank" href="http://maps.google.com/maps/ms?hl=en&ie=UTF8&msa=0&msid=201974913390664606452.00049eec2786a29380604&ll=35.593076,-81.835034&spn=0.015704,0.028024&t=h&z=16" class="directions">Get Directions</a>']
];
 
function setMarkers(map, locations) {
 
  var image = new google.maps.MarkerImage('/images/maps/marker.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(82, 67),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(25, 20));
  var shadow = new google.maps.MarkerImage('/images/maps/shadow.png',
      // The shadow image is larger in the horizontal dimension
      // while the position and offset are the same as for the main image.
      new google.maps.Size(130, 63),
      new google.maps.Point(0,0),
      new google.maps.Point(37, 47));
      // Shapes define the clickable region of the icon.
      // The type defines an HTML &lt;area&gt; element 'poly' which
      // traces out a polygon as a series of X,Y points. The final
      // coordinate closes the poly by connecting to the first
      // coordinate.
  var shape = {
      coord: [0, 0,  0, 67,  82, 67,  82 , 0],
      type: 'poly'
  };
  for (var i = 0; i < locations.length; i++) {
    var location = locations[i];
    var myLatLng = new google.maps.LatLng(location[1], location[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        shadow: shadow,
        icon: image,
        shape: shape,
        title: location[0],
        zIndex: location[3]
    });
	var infowindow = new google.maps.InfoWindow({
        content: location[4]
    });
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
  }
}
