/* 
 * The following functions are built for use with the page components. (i.e. 
 * accordion, content_tabs etc.
 * 
 * */

/*
 * Depending on the state of the accordion component this function will open 
 * or close it including the content below it.
 * 
 * properties:
 * e: element
 */ 

function accordionswitch(e){	
	var currentClass = e.className;
	var accContent = getNextSibling(e);
	
	if(currentClass == "accordion_bar close"){
		e.className = "accordion_bar open";
		accContent.style.display = "block";
	} else if (currentClass == "accordion_bar open"){
		e.className = "accordion_bar close";
		accContent.style.display = "none";
	} else if (currentClass == "accordion_bar_doubleheight close") {
		e.className = "accordion_bar_doubleheight open";
		accContent.style.display = "block";
	} else if(currentClass == "accordion_bar_doubleheight open") {
		e.className = "accordion_bar_doubleheight close";
		accContent.style.display = "none";
	}

}


/*
 * This function is a patch for Firefox nextSibling bug while traversing 
 * html elements. The problem is that firefox will also return a break element
 * when this is not expected. The following function will correct that
 * problem and return an existing html element.
 * 
 * For more information see: 
 * - http://www.andrewsellick.com/21/javascript-nextsibling-firefox-bug-fix
 * 
 * properties:
 * e: element
 */
function getNextSibling(e){
 	followingElement = e.nextSibling;
	
	if(followingElement.nodeType != 1){
		followingElement = followingElement.nextSibling;
	}
	
	return followingElement;
}


/*
 * This functions are for showing and hiding
 */
function showI(e){
	var accContent = getNextSibling(e);
	accContent.style.display = "block";
}
function hideI(e){
	var accContent = getNextSibling(e);
	accContent.style.display = "none";
}