//adds js_hide.css if javascript is supported
if (document.getElementById && document.getElementsByTagName && document.createTextNode) 
{
	document.write('<link rel="stylesheet" type="text/css" title="KU Style" href="http://www2.ku.edu/~chairs/css/showHide.css" />');
}

//setup initialisation function
//.. gecko, safari, konqueror and generic
if(typeof window.addEventListener != 'undefined')
{
	window.addEventListener('load', toggle_init, false);
}
//.. opera 7
else if(typeof document.addEventListener != 'undefined')
{
	document.addEventListener('load', toggle_init, false);
}
//.. win/ie
else if(typeof window.attachEvent != 'undefined')
{
	window.attachEvent('onload', toggle_init);
}

var toggleElements = [];
var switcher;
var links = [];
/* Initialisation */
function toggle_init() {
	var i, link, id, target, fragment;
	switcher = document.getElementById('panelswitcher');
	if (switcher !=null) {
		links=switcher.getElementsByTagName('a');
		id=location.href.split('#')[1];
		if (typeof(id) != 'undefined') {
			fragment=id;
		} 
		for (i = 0; link = links[i]; i++) {
			id = links[i].href.split('#')[1];
			target = document.getElementById(id);
			toggleElements[toggleElements.length] = target;
			if (i==0 && typeof(fragment)=='undefined') {
				target.style.display='block';
				link.style.background = "url(http://www2.ku.edu/~hipaa/images/icons/arrow_down.gif) no-repeat 0 0.3em";
				link.style.fontWeight = "bold";
				link.style.color = "#000";
			}
			if (id==fragment) {
				target.style.display='block';
				link.style.background = "url(http://www2.ku.edu/~hipaa/images/icons/arrow_down.gif) no-repeat 0 0.3em";
				link.style.fontWeight = "bold";
				link.style.color = "#000";
			}
			link.onclick = toggle;
		}
	}
}

function toggle(e) {
	/* Adapted from http://www.quirksmode.org/js/events_properties.html */
	if (typeof e == 'undefined') {
		var e = window.event;
	}
	var source;
	if (typeof e.target != 'undefined') {
		source = e.target;
	} else if (typeof e.srcElement != 'undefined') {
		source = e.srcElement;
	} else {
		return true;
	}
	/* For most browsers, targ would now be a link element; Safari however
	returns a text node so we need to check the node type to make sure */
	if (source.nodeType == 3) {
		source = source.parentNode;
	}
	var id = source.href.split('#')[1];
	var elem;
	for (var i = 0; (elem = toggleElements[i]); i++) {
		if (elem.id != id) {
			elem.style.display = 'none';
			source.style.background = "url(http://www2.ku.edu/~hipaa/images/icons/arrow_down.gif) no-repeat 0 0.3em";
			source.style.fontWeight = "bold";
			source.style.color = "#000";
		} else {
			elem.style.display = 'block';	
		}
	}
	for (i = 0; (link = links[i]); i++) {
		if (link.href.split('#')[1] != id) {
			link.style.background = "url('') no-repeat 0 0.5em";
			link.style.fontWeight = "normal";
			link.style.color = "#0049AE";
		}
	}
	return false;
}