window.addEvent('domready', function() {
	
	var loc = $try( function(){ return decodeURIComponent( window.location.hash.substring(1).clean() ) } );
	//console.log('Location: %s', loc );
	var jumpTo = 0;
	
	if( loc ){ 
	
		$('accordion').getElements('h3.toggler').each(function(e, i){
		
			if( e.get('html').clean().toUpperCase() == loc.toUpperCase() ) {
			
				//console.log('Matching Location: %s', loc );
			
				jumpTo = i;
			
			}
			//console.log('%s: Content: %s', i, e.get('html') );
		});
		
	}
		
	var acc = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		opacity: false,
		show: jumpTo,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#41464D');
			
			//console.log('Toggler: %s', toggler.get('html').clean() );
			window.location.hash =  '#' + encodeURIComponent( toggler.get('html').clean() );
			
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#2f5565');
		},
		
	});
	
	if( acc ){
		
		$('accordion').setStyle('display',''); 
		
	}

});
