document.observe("dom:loaded", function() {
  $$('#gallery a').invoke('observe', 'click', function(event){
    Event.stop(event);
    $$('#main_gallery_image img').first().writeAttribute('src', Event.element(event).ancestors().first().readAttribute('href'));
    $$('.selected_gallery_image').first().removeClassName('selected_gallery_image');
    Event.element(event).ancestors()[1].addClassName('selected_gallery_image');
  });
  
  $$('.event_modal').invoke('observe', 'click', function(event){
    Event.stop(event);
    //"Modalbox.show('/events/select_day?day=#{date.day}&month=#{date.month}&year=#{date.year}', {title: '#{date.strftime('%B %d, %Y')}', width:700, afterLoad: function(){playAudioClip();Modalbox.resizeToContent();}, beforeHide: function(){soundManager.stopAll();}})"
    Modalbox.show(this.href, {title: this.title, 
                              width:700,
                              height: 500,
                              afterLoad: function(){playAudioClip();Modalbox.resizeToContent();}, 
                              beforeHide: function(){soundManager.stopAll();}
    });
  });
});
