/**
  * Used to hide and show elements of the Jobs-Module
  *
  * @requires Prototype Library
  **/
  
/**
  * Shows an item, sets the class of the title belonging to it
  * to null and changes the title's onClick-event to hideItem() 
  *
  * @param (String) sItem ID of the block-item to be shown
  **/

function showItem(sItem) {

	var oItem = $(sItem);
	var sId = sItem.replace("jobs_", "");
	if (oItem) {
	
		oItem.style.display = "block";
		var oTitleObject = $("jobs_title_" + sId);
		if (oTitleObject) {
		
			oTitleObject.className = "active";
			oTitleObject.onclick = function () {
			
				hideItem(sItem);
			}
		}
	}
}

/**
  * Hides an item, sets the class of the title belonging to it
  * to "Active" and changes the title's onClick-event to showItem() 
  *
  * @param (String) sItem ID of the block-item to be hidden
  **/

function hideItem(sItem) {

	var oItem = $(sItem);
	var sId = sItem.replace("jobs_", "");
	if (oItem) {
	
		oItem.style.display = "none";
		var oTitleObject = $("jobs_title_" + sId);
		if (oTitleObject) {
		
			oTitleObject.className = null;
			oTitleObject.style.cursor = "pointer";
			oTitleObject.onclick = function () {
			
				showItem(sItem);
			}
		}
	}
}

/**
  * Loops through all objects that have the class "jobs_container" assigned
  * and hides them. This function will best be called right after the contents
  * are drawn rather than waiting until the onLoad-event will be called
  * for performance-reasons.  
  **/
  
function initShowHide() {

	var aoContainers = document.getElementsByClassName("jobs_container");
	for (var iContainerCount = 0; iContainerCount < aoContainers.length; ++iContainerCount) {
	
		var oContainer = aoContainers[iContainerCount];
		hideItem(oContainer.id);
	}
}