// START OF CHRIS ESLER FUNCTIONS

// QUICK TOGGLE FUNCTION
// objClass is the target flag className

function toggleDisplay(objClass){
 
		$S('.'+objClass).each(function(el){
		
			if (el.className.indexOf("Hide") != -1) el.className = el.className.replace("Hide","Show");
			else el.className = el.className.replace("Show","Hide");
 
		});
		
}

// FUNCTIONS TO TOGGLE THE PILL IMAGE AND SET CURRENT TOGGLE
// change pill to ON

function toggleAccordionImageShow(el) {
 
	// grab our pill image
	var obj = el.getLast().getFirst();
	
	// get our arrow id / accordion id
	var newArrowId = obj.id.replace(/arrow/g,'');
 
	// set current Arrow
	currentArrow = newArrowId;
 
	// set the new source
	if(!obj.src.test('Lite')){
		obj.setProperty('src',obj.src.replace(/.gif/g,'Lite.gif'));
	}
 
}
 
// change pill to off
function toggleAccordionImageHide(el) {
 
	// grab our pill image
	var obj = el.getLast().getFirst();
	
	// set the new source
	obj.setProperty('src',obj.src.replace(/Lite/g,''));
 
}
 
// ACCORDION VARS SETUP

var myAccordion;
var myStretch;
var myStretcher;
 
// WINDOW ONLOAD STUFF - onDomReady from Moottools

Window.onDomReady(function() {
	
	// get accordion elements
	myStretch = document.getElementsByClassName('toggler');
	myStretcher = document.getElementsByClassName('accordion');
	
	// setup the accordion elements by clearing display styles	
	myStretcher.each(function(el){
		el.style.display = '';
	});
	
	// Create the accordion
	myAccordion = new fx.Accordion(myStretch, myStretcher, 
		{
			/*fixedHeight: 125,*/
			opacity : true,
			openClose : false,
			onActive : function(el){toggleAccordionImageShow(el)},
			onBackground : function(el){toggleAccordionImageHide(el)},
			itemsOpen : [],
			start : 'closed'
		});
 
});