(function($){

var ns = "EventList";

window[ns] = function () {
  this.root = $('#event-list');
  if ( ! this.root.length ) return;
  
  this.handle = this.root.find('h3.title');
  this.content = this.root.find('div.content');
  
  this.init();
  this.observe();
};

window[ns].prototype = {
  init: function () {
    this.content.hide();
  },
  
  observe: function () {
    this.handle.hover(
        function () { $(this).css('opacity', 0.8); },
        function () { $(this).css('opacity', 1.0); }
      );
      
    this.handle.click( $.proxy( this.click, this ) );
  },
  
  click: function ( event ) {
    var index = $.inArray( event.currentTarget, this.handle );
    var content = this.content.eq(index);
    if ( content.is(':visible') ) {
      content.slideUp();
    } else {
      content.slideDown();
    }
  }
};

})(jQuery);

