//used by homepages on root and manage users 12/6/2010
// used by admin menu 4/18/2011
// JavaScript Document
// DR-S 12/17/2010
// functions below written for onmouseover etc, when the call to the script will always be hide or diplay. But onmouseover/onmouseout aren't ADA friendly. They need to be called by onclick. So we need a toggle.
var currentHelp;
currentHelp = 'none';

// it won't always be 'help' we're toggling 4/18/2011 
function toggleDiv(id) {
	toggleHelpDiv(id);
}

//
function toggleHelpDiv(id) {
//alert('id: ' + id);
//alert('currentHelp: ' + currentHelp);
	if (currentHelp == id) {
		//alert('match');
		hideDiv(id);
		currentHelp = 'none';
	}
	else {
		//alert('not match');
		if (currentHelp != 'none') {
			//alert('currentHelp not none');
			hideDiv(currentHelp);
		}
		showDiv(id);
		currentHelp = id;
	}
//alert('id: ' + id);
//alert('currentHelp: ' + currentHelp);
}

function _gel(id) {
	return document.getElementById(id);
}
function ref(instance_or_id) {
	return(typeof(instance_or_id)=="string")?document.getElementById(instance_or_id):instance_or_id;
}
function hasClass(element,_className) {
	if(!element) {
		return;
	}
	var upperClass=_className.toUpperCase();
	if(element.className) {
		var classes=element.className.split(' ');
		for(var i=0;i<classes.length;i++) {
			if(classes[i].toUpperCase()==upperClass) {
				return true;
				}
			}
		}
	return false;
}
function addClass(element,_class) {
	if(!hasClass(element,_class)) {
		element.className+=element.className?(" "+_class):_class;
	}
}
function getDisplayStyleByTagName(o) {
	var n=o.nodeName.toLowerCase();
	return(n=="span"||n=="img"||n=="a")?"inline":"block";
}
function hideDiv(divName) {
	var tempDiv=_gel(divName);
	if(!tempDiv) {
		return;
	}
	tempDiv.style.display="none";
}
function showDiv(divName) {
	var tempDiv=_gel(divName);
	if(!tempDiv ) {
		return;
	}
	if(hasClass(tempDiv,"wasinline")) {
		tempDiv.style.display="inline";
		removeClass(tempDiv,"wasinline");
	}
	else if(hasClass(tempDiv,"wasblock")) {
		tempDiv.style.display="block";
		removeClass(tempDiv,"block");
	}
	else {
		tempDiv.style.display=getDisplayStyleByTagName(tempDiv);
	}
}
