//the main function, call to the effect object

function init()
{
	//
	// find and setup any accordions
	//
	var stretchers = document.getElementsByClassName('stretcher');
	var toggles = document.getElementsByClassName('display');

	var myAccordion = null;
	var accordion_options = {opacity: true, duration: 400};



	if (stretchers.length > 0)
	{
		// alert('simple stretcher');
		myAccordion = new fx.Accordion(
			toggles,
			stretchers,
			accordion_options);
	}
	else if (toggles.length > 0)
	{
		// alert('closed stretcher');
		stretchers = document.getElementsByClassName('closed-stretcher');
		accordion_options['display'] = null;

		myAccordion = new fx.Accordion(
			toggles,
			stretchers,
			accordion_options);
	}

	//
	// if the user goes comes back to a page where they
	// have previously opened an accordion window, re-opened
	// the window.
	//
	function checkHash()
	{
		var found = false;
		toggles.each(function(h3, i)
		{
			if (window.location.href.indexOf('#' + h3.title) > 0)
			{
				myAccordion.showThisHideOpen(stretchers[i]);
				found = true;
			}
		});
		return found;
	}

	if (myAccordion != null && !checkHash()) myAccordion.showThisHideOpen(stretchers[0]);
}

window.onload = function() {
	Element.cleanWhitespace('wrap');
	init();
}
