var hide_events = function() { $('.tabcalendar-event-details').hide(); }; var show_event = function(event_id) { hide_events(); $('.tabcalendar-event-details' + event_id).show(); }; $(function() { $('.calendar-listing>p').click(function() { $(this).next().toggle('fast'); return false; }).next().hide(); $('.tabcal-cell a').each(function(i,a) { var hashpos = a.href.indexOf('#'); if (hashpos < 0) return true; var hash = a.href.slice(hashpos); if (!hash.startsWith('#event-')) return true; a.onclick = function() { show_event(hash); return true; }; }); hide_events(); });