/////////////////////////////////////////////////////////
//
// 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");

		});
		
}



/////////////////////////////////////////////////////////
//
// SETUP ACCORDION ASSOCIATIVE ARRAY
// maps key presses to the accordion toggle
// 49 = number 1 key, 50 = number 2 key, and so on
//
var accArray = [0, 1, 2, 3, 4]; 
var keyArray = [49, 50, 51, 52, 53]; 
var newAccArray = accArray.associate(keyArray);
var currentArrow = 0;


/////////////////////////////////////////////////////////
//
// 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 : true,
			onActive : function(el){toggleAccordionImageShow(el)},
			onBackground : function(el){toggleAccordionImageHide(el)},
			itemsOpen : [15],
			start : 'first-open'
		});

	

});
