(function( $ ){
  $.fn.contact_map = function( settings ) {
    var options = {
      zoom: 13,
      lat: 37.0625,
      lng: -95.677068
    };

    return this.each(function() {
      if ( settings ) { $.extend( options, settings ); }
      var lat_lng = new google.maps.LatLng(options['lat'], options['lng']);
      var map_options = {
        zoom: options['zoom'],
        center: lat_lng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var map = new google.maps.Map(document.getElementById(this.id), map_options);
      var geocoder = new google.maps.Geocoder();
      var marker = null;
      the_address = "7245 rue Alexandra, Montreal, Quebec, Canada, H2R 2Y9"
      geocoder.geocode(
        {  address: the_address  },
        function(results, status) {
          if (status != google.maps.GeocoderStatus.OK) {
            alert(the_address + " not found");
          } else {
            if (marker) { marker.setMap(null); }
            map.setCenter(results[0].geometry.location);
            var icon_size = new google.maps.Size(22,34);
            var map_icon = new google.maps.MarkerImage("/theme/4d3995b6dabe9d4c440000a2/stylesheets/images/catalpa-map-pin.png", icon_size );
            marker = new google.maps.Marker({
              map: map, 
              position: results[0].geometry.location,
              icon: map_icon
            });
          }
        }
      );
    });
  };
})( jQuery );

