var control = false;
var nextKey = false;


/////////////////////////////////////////////////////////
//
// 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'));
	//}
	obj.style.color = '#FFFFFF';

}

// 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,''));
	obj.style.color = '#A6A6A6';

}


/////////////////////////////////////////////////////////
//
// 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 : [0,1,2],
			start : 'first-open'
		}
	);
	/////////////////////////////////////////////////////////
	//
	// SETUP THE TOOLTIPS
	//
	
	// tooltip array
	var as = [];
	
	// grab all images that are supposed to have a tooltip
	$S('img.hasTooltip').each(function(a){ if (a.getAttribute('title')) as.push(a); });
	
	// create tooltip instance
	new Tips(as, {maxOpacity: 0.9, maxTitleChars: 300});	
	

});

//--->