LAFAYETTESEALS = {

  common : {
    init : function() {
      //$("input[type=text],input[type=email], textarea").placehold();
      $('.home_meet img').tooltip({effect: 'fade', offset: [-4,0]});
    },
    
    finalize : function() {}
  },
  
  meet_detail : {
    init : function() {
      // Setup tabbed nav for results tables
      $('ul.tabs').tabs('div.panes > .pane');
      
      // Setup address map
      var $map = $('#map'),
          lat = $map.data('lat'),
          lon = $map.data('lon'),
          latlng = new google.maps.LatLng(lat, lon),
          opts = {
            zoom: 15,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
          },
          map = new google.maps.Map(document.getElementById("map"),opts);
              
      var marker = new google.maps.Marker({
        position: latlng, 
        map: map,
        title:"Pool Address"
      });
          
      var contentString = $('#location .address').html();
      var infowindow = new google.maps.InfoWindow({ content: contentString });
      infowindow.open(map,marker);
      
      // Setup colorbox for map
      $("#location .show_map").colorbox({inline:true, href:"#map_container"});
    }
  },
  
  pools : {
    init : function() {
      if ($('#map').length > 0) $('#map').jMapping({
        side_bar_selector: '#map_locations:first',
        location_selector: '.location',
        link_selector: 'a.map_item',
        info_window_selector: '.info_box'
      });
      $('#map_container').stickyScroll({ mode: 'manual', bottomBoundary: 490, topPadding: 10 }); 
    }
  },
  
  calendar : {
    init : function() {
      if($('.event').not('.meet').length > 0) {
         $('.event').not('.meet').find('a').colorbox({
          width: 450,
          height: 300
        });
      }
    }
  }

}


/* via http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/ */
UTIL = {
 
  fire : function(func,funcname, args){ 
    var namespace = LAFAYETTESEALS;  // indicate your obj literal namespace here 
    funcname = (funcname === undefined) ? 'init' : funcname;
    if (func !== '' && namespace[func] && typeof namespace[func][funcname] == 'function'){
      namespace[func][funcname](args);
    }  
  }, 
 
  loadEvents : function(){
    var bodyId = document.body.id;
 
    // hit up common first.
    UTIL.fire('common');
 
    // do all the classes too.
    $.each(document.body.className.split(/\s+/),function(i,classnm){
      UTIL.fire(classnm);
      UTIL.fire(classnm,bodyId);
    }); 
    UTIL.fire('common','finalize'); 
  } 
 
}; 
 
// kick it all off here 
$(document).ready(UTIL.loadEvents);
