/* Common DHTML JavaScript Library
** Please only remove comments from production version; save a copy with comments.
*/

// sets the CSS class of an element at runtime
function setClass(elm,clss) {
	// IE 5+ and NS 6...
	if (document.getElementById) {
		// You can either call the function with setClass(this,'ruleName') or setClass('elementID','rulName').
		// Test whether it's an object (else it must be a string) to handle both types of calls
		if(typeof elm=='object') {
			// test whether the element actually exists, if it does not exist, exit gracefully
			// rather than throwing a js error
			if(document.getElementById(elm)) { // attempt only if element exists
				elm.className = clss;
			}
		} else {
			if(document.getElementById(elm)) { // attempt only if element exists
				document.getElementById(elm).className = clss;
			}
		}
	// IE 4...
	} else if (document.all) {
		document.all[elm].className = clss;
	}
}

// toggles the display visibility of an element at runtime
function toggleVisibility(elm) {
		// IE 5+ and NS 6...
	if (document.getElementById) {
		// You can either call the function with toggleVisibility(this) or toggleVisibility('elementID').
		// Test whether it's an object (else it must be a string) to handle both types of calls
		if(typeof elm=='object') {
		
			if(elm.style.display != "none") {
				elm.style.display = "none";
			} else {
				elm.style.display = ""; 
			}
			
		} else {
			if(document.getElementById(elm).style.display != "none") {
				document.getElementById(elm).style.display = "none";
			} else {
				document.getElementById(elm).style.display = "block"; 
			}
		}
	
	// IE 4...

	} else if (document.all) {
		if(document.all[elm].style.display != "none") {
			document.all[elm].style.display = "none";
		} else {
			document.all[elm].style.display = "block";
		}
	}

}

// swaps an image source at runtime
function swapImage (img, imageSource) {
	// IE 5+ and NS 6...
	if (document.getElementById) {
		// You can either call the function with setClass(this,'ruleName') or setClass('elementID','rulName').
		// Test whether it's an object (else it must be a string) to handle both types of calls
		if(typeof img=='object') {
			img.src = imageSource;
		} else {
			document.getElementById(img).src = imageSource;
		}
	// IE 4...
	} else if (document.all) {
		document.all[img].src = imageSource;
	}
}

// opens a separate browser window
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// toggles a expandable/collapsable section control and its image
function toggleTwistee(elm) {
	toggleVisibility("div_" + elm);
	if(eval("div_" + elm).style.display=="none"){
		setClass(elm, 'twisteeBarClosed');
	} else {
		setClass(elm, 'twisteeBarOpen');
	}
}
