	/* SETTINGS */
	
	//Create empty-vars
	//var groupNames = new Array();	
	//var togglerIDs = new Array();
	var g, areAllOpen, c, a, dispStatus, imgDisp, gHeight, expand, collapse, fVal;
	
	// Animation
	var ABS_MIN = 20;
	var FRAME_PX = 25;
	var FRAME_DELAY = 1;
	var MIN_GROUP_HEIGHT = "20px";
  
	/**
	 * Opens / Closes individual groups
	 * @param {String} gId Main div ID of group to be opened/closed
	 * @param {Integer} startHeight Height of collapsed group
	 */	
function toggleGroup(gId,startHeight,superGroup) {
		if(typeof hideDhtmlPop=="function")hideDhtmlPop()
		g = document.getElementById(gId);
		ABS_MIN = startHeight;
		areAllOpen = true;
		c = 0;
		if(g.style.height == '') { g.style.height = MIN_GROUP_HEIGHT; }
	
		//if group is closed, open it(and set expand-image & collapse-text)
		if(g.style.height == ABS_MIN + 'px') {
			_animateGroup(g,ABS_MIN,g.scrollHeight,FRAME_PX);
			_indicateOpenedState(gId,true)
		}
		//if group is open, close it(and set collapse-image & expand-text)
		else {
			_animateGroup(g,g.scrollHeight,ABS_MIN,-FRAME_PX);
			_indicateOpenedState(gId,false)
		}
		//determine if all superGroups are closed
		for(a=0; a < superGroup.length; a++) {
			dispStatus = document.getElementById(superGroup[a]).style.height;
			if(dispStatus == '' || dispStatus == MIN_GROUP_HEIGHT) { c++; }
		}
		//if not all are open, prep.for Collapse All img/txt
		if(c == 1 && g.style.height == MIN_GROUP_HEIGHT) {
			superGroup.areAllOpen = true;
			_indicateOpenedStateForTogglers(true,superGroup);
		}else {//if all are open, prep.for Expand All img/txt
			superGroup.areAllOpen = false; 
			_indicateOpenedStateForTogglers(false,superGroup);
		}
	}
	
	
	/**
	 * Opens/closes all groups
	 */
function  toggleAll(superGroup) {
		areAllOpen = true;
	
		//determine if all groups are closed
		for(a=0; a < superGroup.length; a++) {
			dispStatus = document.getElementById(superGroup[a]).style.height;
			if(dispStatus == '' || dispStatus == MIN_GROUP_HEIGHT) {
				areAllOpen = false;
				break;
			}		
		}

		//if all groups are closed, open all
		if(areAllOpen == false) {
			_openCloseGroups(superGroup,false);
		}
		//otherwise, close all (and then set Expand All img/txt)
		else {
			_openCloseGroups(superGroup,true);
		}
	}

	/**
	 * Opens all groups
	 */
function openAll(superGroup) {
	//open all (and then set Collapse All img/txt)
	_openCloseGroups(superGroup,false);
}
	
	/**
	 * Add group id-name to a superGroup array. Launched automatically on page load.
	 * THERE IS NO SUPERGROUP maker. Just define supergroups per page as arrays.
	 * @param {String} groupID "Container" name
	 */
function addGroup(groupID,superGroup) {
	superGroup.push(groupID);
	//nna.dom.getChildNodes(nna.dom.getChildNodes($(groupID))[0])[0].hideFocus=true;
	//jQuery('#'+groupID+' > * > *')[0].hideFocus=true;	
	document.getElementById(groupID).childNodes[0].hideFocus = true;
}

function _indicateOpenedState(groupID,isOpened){
	//nna.dom.getChildNodes(nna.dom.getChildNodes($(groupID))[0])[0].className=(isOpened)?'gOpened':'gClosed';
	//jQuery('#'+groupID+' > * > *')[0].className=(isOpened)?'gOpened':'gClosed';
	
	//$($('#'+groupID+'> *')[0]).children()[0].className=(isOpened)?'gOpened':'gClosed';
	document.getElementById(groupID).getElementsByTagName("a")[0].className=(isOpened)?'gOpened':'gClosed';
}
function _indicateOpenedStateForTogglers(isOpened,superGroup){
	for(var i=0;i<superGroup.togglerIDs.length;i++){
		//nna.dom.getChildNodes($(superGroup.togglerIDs[i]))[0].className=(isOpened)?'gOpened':'gClosed';
		//jQuery('#'+superGroup.togglerIDs[i]+' > *')[0].className=(isOpened)?'gOpened':'gClosed';
		//$($('#'+superGroup.togglerIDs[i])).children()[0].className=(isOpened)?'gOpened':'gClosed';
		document.getElementById(superGroup.togglerIDs[i]).childNodes[0].className=(isOpened)?'gOpened':'gClosed';
	}
}
	
	/**
	 * Add group id-name to a superGroup array. Launched automatically on page load.
	 * @param {String} groupID "Container" name
	 */
function addTogglerID(togglerID,superGroup) {
	superGroup.togglerIDs.push(togglerID);
	//nna.dom.getChildNodes($(togglerID)).hideFocus=true;
	//jQuery('#'+togglerID+'> *').hideFocus=true;
	
	//$($('#'+togglerID)).children().hideFocus=true;
	
	var nodeList = jQuery(togglerID).children();
	for (i=0;i<nodeList.length;i++){
	  // test for an element else ignore
	  if(nodeList[i].nodeType == 1){
			nodeList[i].hideFocus=true;
		}
	}
}
	
	
	/**
	 * Expand group NOT USING supergroup yet!!
	 */
function expandCategory() {
		//split up the URI by the ? if-present
		var URIarg = location.search.substr(1).split('?').toString();
	
		//if uri includes argument, argument-name is valid and argument-value is not blank and is numeric, open the group specified in the URI-argument
		if(URIarg != "" && URIarg.split('=')[0] == "expandCategory" && URIarg.split('=')[1] != "" && !isNaN(URIarg.split('=')[1])) { eval('toggleGroup("accordionGroup_' + URIarg.split('=')[1] + '",' + parseInt(MIN_GROUP_HEIGHT) + ')'); }
		//otherwise, open default-group
		else { _toggleGroup1(); }
	}
	
	
	/* ########################### INTERNAL FUNCTIONS ########################### */
	
	/**
	 * Animate group
	 * @param {Object} g DIV being expanded/collapsed
	 * @param {Integer} minH Minimum height, initial height and current height of section
	 * @param {Integer} maxH Maximum height, height of the fully expanded section
	 * @param {Integer} delta Controls animation interval, set with FRAME_PX var
	 * @param {Function} thenTrigger Function to fire after animation, if any
	 */
	function _animateGroup(g,minH,maxH,delta,thenTrigger) {
		if(delta > 0) {
			//open the group
			if(minH <= maxH) {
				g.style.height = minH + "px";
				setTimeout(function() { _animateGroup(g,(minH+delta),maxH,delta,thenTrigger); }, FRAME_DELAY);
			}
			else {
				g.style.height = g.scrollHeight + "px";
				if(typeof thenTrigger == "function") { thenTrigger(); }
				return;
			}
		}
		else {
			//close the group
			if(minH >= ABS_MIN) {
				g.style.height = minH + "px";
				setTimeout(function() { _animateGroup(g,(minH+delta),maxH,delta,thenTrigger); }, FRAME_DELAY);
			}
			else {
				g.style.height = ABS_MIN + "px";
				if(typeof thenTrigger == "function") { thenTrigger(); }
				return;
			}
		}
	}
	
	// Open or Close Groups
	function _openCloseGroups(items,allOpened,thenTrigger) {
		var wasTriggered = false;
		


		//if all are Not open
		if(allOpened == false) {
			for(a=0; a < items.length; a++) {
				g = document.getElementById(items[a]);			
				gHeight = document.getElementById(items[a]).style.height;
				if(gHeight == "") { gHeight = MIN_GROUP_HEIGHT; }
				if(gHeight == MIN_GROUP_HEIGHT) {
					_animateGroup(g,parseInt(MIN_GROUP_HEIGHT),g.scrollHeight,FRAME_PX,thenTrigger);
					wasTriggered=true
				}
			}
		}
		//if all are open
		else {
			for(a=0; a < items.length; a++) {
				g = document.getElementById(items[a]);
				gHeight = document.getElementById(items[a]).style.height;
				if(parseInt(gHeight) > parseInt(MIN_GROUP_HEIGHT)) {
					_animateGroup(g,g.scrollHeight,parseInt(MIN_GROUP_HEIGHT),-FRAME_PX,thenTrigger);
					wasTriggered=true;
				}
			}
		}
		for(var i=0;i<items.length;i++){
			_indicateOpenedState(items[i],!allOpened);
		}
		_indicateOpenedStateForTogglers(!allOpened,items);			

		if(!wasTriggered && typeof thenTrigger == "function") { thenTrigger(); }
	}
	
	// Scroll Element Into View
	function _thenScrollIntoView() {
		//if newScrollAnchor exists, scroll to it
		if(newScrollAnchor) {
			document.getElementById(newScrollAnchor).scrollIntoView();
			newScrollAnchor = null;
		}
	}
	
	// Group1 Accordion-activator
	function _toggleGroup1() {
		toggleGroup('accordionGroup_1',parseInt(MIN_GROUP_HEIGHT));
	}



