
window.addEvent('domready', init);

function init() {
	
	// Create the Accordion effect
	var accordion = new Accordion('#schedule h1', '#schedule .times', {
		opacity : true,
		onActive: function(toggler, element) {
			toggler.setStyle('background-color', '#f16925');
		},
		onBackground: function(toggler, element) {
			toggler.setStyle('background-color', '#a6def3');
		}
	}, $('schedule'));
		
	// Get the current date, and round down the time
	var date = new Date();
	date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
	
	// Determine which day of the schedule to display by default
	var year = date.getFullYear();
	var text = $$('#schedule h1').getLast().getProperty('title');
	var splitted = text.split('-');
	if (date > Date.parse(splitted[1] + ', ' + year))
		year+=1;
	var dates = $$('#schedule h1');
	var i=0;
	while (dates[i] && date > Date.parse(dates[i].getProperty('title').split('-')[1] + ', ' + year)) {
		i++;
	}
	accordion.display(i);
}