var Site = new Abstract({
	start: function() {
		this.setAccordion();
		this.setHashes();
		this.donorMessage();
		$('navi').effect('opacity', {duration: 300}).start(1);
	},
       
	setAccordion: function() {
		this.accordion = new AutoAccordion($$('h4.handle', 'accordion'), $$('.drawer', 'accordion'));
	},
	
	setHashes: function() {
    var index = this.accordion.togglers.indexOf($('section-' + location.hash.replace('#', '')));
    if (index >= 0) this.accordion.display(index);
		
		// add event to accordion to update url
		this.accordion.addEvent('onActive', function(toggler, i) { location.hash = toggler.id.replace('section-', ''); });
	},
	
	donorMessage: function() {
		if (location.hash == '#donated') {
			location.hash = 'support';
			
			$('support-body').setHTML(
				'<p>'+
				'Thanks for your support! Your donation will be used to cover medical costs, ' +
				'food, and needed computer equiptment for future projects. If you have any ' +
				'questions, feel free to contact me. <tt>:)</tt>' +
				'</p>'
			);
			
			this.accordion.display(this.accordion.togglers.indexOf($('section-support')));
		}
	}
});
window.addEvent('domready', function() { $('navi').setStyle('opacity', '0'); });
window.addEvent('load', Site.start.bind(Site));
