
var accordion;
function initialiseElements()
{

	createMainAccordion();
	setElementVisibility( $( 'content' ), true );  // Reveal page content only once page has downloaded and Accordion has been initialised
	accordion.display( null);
}




function createMainAccordion()
{
	var togglers = $$('h2.atStart');	
	var stretchers = $$('div.atStart');
	accordion = new Accordion(togglers, stretchers, {
		display: 0,
		opacity: false,
		start: 'all-closed',
		onActive: function(toggler, stretcher) {
			toggler.setStyle('background-color', '#FF7D00'),
			toggler.setStyle('color', '#FFFFFF');
			activeSection = stretcher;
			//toggler.getElement( '.state' ).innerHTML = '';
			toggler.getElement( '.state' ).style.visibility = "hidden";
			//markVisited( toggler );
			//alert("onActive end");
		},
		onBackground: function(toggler, stretcher) {
		//	alert("onBackground begin");
			toggler.setStyle('background-color', '#E78E21');//'#6699cc');
			toggler.setStyle('color', '#FFF5AF');
			stretcher.setStyle('height', stretcher['offsetHeight']);
			toggler.getElement( '.state' ).style.visibility = "visible";
		},
		onComplete: function(toggler, stretcher) {
			var el = $(this.elements[this.previous]);
			if (el!=null){
				if (el.offsetHeight > 0) el.setStyle('height', 'auto');
			}
		}
	});
}


window.addEvent('domready', initialiseElements );

function setElementVisibility( element, visibility )
{
	if ( element )
	{
		element.style.display = ( visibility ? 'block' : 'none' );
	}
}







