// Hides all DIVs in the same parent of the layerid-sent into function
// And then displays the layer
// Also, marks the clicked layerID, and unmarks all other layers in the same parent.
// By using the last paramaters classname
function fnDisplayLayerHideAllFriends(strDisplayDiv,strMark,strMarkWithClass){
	oMark = document.getElementById(strMark);
	oDisplayDiv = document.getElementById(strDisplayDiv);
	
	// Get parents
	oParentMark = oMark.parentNode;
	oParentDiv = oDisplayDiv.parentNode;
	// Loop all friends, set all to hidden (by adding the class "hiddendiv")
	for (var i=0; i < oParentDiv.childNodes.length; i++){
		if (oParentDiv.childNodes[i].nodeName == "DIV"){
			// Get the classes of this DIV
			strClassnames = oParentDiv.childNodes[i].className;
			// Remove any earlier state
			rExp = /visiblediv|hiddendiv/gi;
			strClassnames = strClassnames.replace(rExp, "");
			if (oDisplayDiv.id != oParentDiv.childNodes[i].id){
				// Add a hide-class
				strClassnames = strClassnames + ' hiddendiv';
				
			}else{
				// Add a display class
				strClassnames = strClassnames + ' visiblediv';
			}
			// Set the class
			oParentDiv.childNodes[i].className = strClassnames;
		}
	}
	
	// Loop all friends, set all to be unmarked (by removing the class)
	for (var i=0; i < oParentMark.childNodes.length; i++){
		if (oParentMark.childNodes[i].nodeName == "A"){
			// Get the classes of this Anchor
			strClassnames = oParentMark.childNodes[i].className;
			// Remove any earlier state
			rExp = new RegExp(strMarkWithClass, "gi")
			strClassnames = strClassnames.replace(rExp, "");
			if (oMark.id == oParentMark.childNodes[i].id){
				// Add a selected class
				strClassnames = strClassnames + ' ' + strMarkWithClass;
			}
			// Set the class
			oParentMark.childNodes[i].className = strClassnames;
		}
	}
	// Reset the layout
	oDiv = document.getElementById('frontpagemainwrapperid');
	oDiv.style.height = 'auto';
	oDiv.style.height = '100%';
	
	// Reset the selection, otherwise browser shows active link
	oMark.blur();
}
// Function to toggle the visibility of a single ID.
function fnToggleLayer(strLayer) {
	if(strLayer != '') {
		oElement = document.getElementById(strLayer);
		// Find out if div is hidden or visible
		strClassnames = oElement.className;
		rExp = /sel/gi;
		strResults = strClassnames.search(rExp)
		// Remove any of the classes if present
		rExp = /sel/gi;
		strClassnames = strClassnames.replace(rExp, "")
		// Add the correct class depending on the first search
		if(strResults === -1){
			strClassnames = 'sel';
		}
		oElement.className = strClassnames;
	}
}
// Function to toggle the visibility of a single ID.
function fnToggleLayerHideSilbings(strLayer) {
	if(strLayer != '') {
		oElement = document.getElementById(strLayer);
		oElementParent = oElement.parentNode;
		// Loop all friends, set all to be unmarked (by removing the class)
		for (var i=0; i < oElementParent.childNodes.length; i++){
			if (oElementParent.childNodes[i].nodeName == "LI"){
				// Get the classes of this Anchor
				strClassnames = oElementParent.childNodes[i].className;
	
				// Remove any earlier state
				rExp = new RegExp("sel", "gi")
				strClassnames = strClassnames.replace(rExp, "");
	
				// Set the class
				oElementParent.childNodes[i].className = strClassnames;
			}
		}
		// Find out if div is hidden or visible
		strClassnames = oElement.className;
		rExp = /sel/gi;
		strResults = strClassnames.search(rExp)
		// Remove any of the classes if present
		rExp = /sel/gi;
		strClassnames = strClassnames.replace(rExp, "")
		// Add the correct class depending on the first search
		if(strResults === -1){
			strClassnames = 'sel';
		}
		oElement.className = strClassnames;
	}
}
// Function switch disabled
function fnSwitchDisabled(strID,strDisableID){
	oDisable = document.getElementById(strDisableID)
	oEnable = document.getElementById(strID)
	
	oDisable.disabled = true;
	oDisable.value = '';
	oDisable.className = 'disabled';
	oEnable.disabled = false;
	oEnable.className = '';
}
// Function to display or hide extra info in file/document-listings
function fnShowExtraInfo(oHref){
	oTR = oHref.parentNode.parentNode;
	oTRinfo = oTR.nextSibling;
	oDiv = document.getElementById("submainlistdocs");
	
	// IE uses 1 nextSibling, Mozilla uses two.
	if (oTRinfo.nodeName != 'TR'){
		oTRinfo = oTR.nextSibling.nextSibling;
	}
	
	// Toggle close or open
	if (oTR.className == 'sel'){
		oTR.className = '';
		oTRinfo.className = 'ei';
	}else{
		oTR.className = 'sel';
		oTRinfo.className = 'eisel';
	}
	// Resize wrapperdiv to stretch content
	oDiv.style.height = 'auto';
	oDiv.style.height = '100%';
	return false;
}
// Function to activate hover for LIs on IE
startList = function() {
	if (document.all&&document.getElementById){
		navRoot = document.getElementById("navigation");
		
		if (navRoot != null){
			for (i=0; i<navRoot.childNodes.length; i++){
				node = navRoot.childNodes[i];
				if (node.nodeName == "LI"){
					node.onmouseover = function() {	this.className+= " sel"; }
					node.onmouseout = function() { this.className = this.className.replace(" sel", ""); }
				}
			}
		}
	}
}
// Start script onload
window.onload = startList;
