// JS for the contact page		
$kuj(document).ready(function(){
	 
	 // For use in the Contact Information Page
	 $kuj("#feedback").hide();
	 $kuj("#info").show();
	 
	 $kuj("a#feedback_link").click(function(){
	 		 
	 			$kuj("#feedback").slideDown();
	 			$kuj("#info").slideUp();
	 			
	 	});
	 	
	 	$kuj("a#info_link").click(function(){
	 		 
	 			$kuj("#info").slideDown();
	 			$kuj("#feedback").slideUp();
	 			
	 	});
	 	
	 	$kuj('#cyclefade').cycle({
      fx:     'fade',
      speed:   1000,
      timeout: 4000
	  });

});

// JS for the left nav pop outs		
$kuj(document).ready(function(){ 
    $kuj("ul.sf-menu").supersubs({ 
        minWidth:    12,   // minimum width of sub-menus in em units 
        maxWidth:    19,   // maximum width of sub-menus in em units 
        extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                           // due to slight rounding differences and font-family 
    }).superfish();  // call supersubs first, then superfish, so that subs are 
                     // not display:none when measuring. Call before initialising 
                     // containing tabs for same reason. 
                     
    $kuj("ul.sf-menu").superfish({ 
        animation: {height:'show'},   // slide-down effect without fade-in 
        delay:     300               // 1.2 second delay on mouseout 
    }); 
    
    // JS for the lightbox photo gallery 
    //$kuj("a.inline_popup").fancybox({
		//	'hideOnContentClick':	false, 
		//	'frameWidth':					600, 
		//	'frameHeight':				400
		//});
		//
		//$kuj("a.group").fancybox({
		//	'hideOnContentClick': false
		//});
});

//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;
}