 /* ------------------------------------------------------------
 * PROJECT        : FHSC Interface Standard
 * FILENAME       : jqsidenav.js
 * ------------------------------------------------------------
 * DATE CREATED   : 30 Aug 2006
 * LAST UPDATED   : 11 Sep 2007
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (http://www.ksscholl.com/)
 * ------------------------------------------------------------ */

/* ------------------------------------------------------------
 * EXPANDABLE SIDE NAVIGATION
 * ------------------------------------------------------------ */

$(document).ready(function(){

  // This hides and shows the side navigation block
	$("#snBlock,#snOpenIndicator")
	  .css("display","none")
		
	$("#snOpenIndicator").click(function() {
		$('#snBlock,#snOpenIndicator').fadeOut(500)
		$('#snClosedIndicator').fadeIn(500);
		});
	$("#snClosedIndicator").click(function() {
		$('#snBlock,#snOpenIndicator').fadeIn(500);
		$('#snClosedIndicator').fadeOut(500);
		});

  // This sets the initial styles of the collapsible Menu items
	$("div.sn")
	  .find("li:has(span.disabledModule)")
		  .css("background","transparent url(images/sn_plus_dim.gif) 5px 5px no-repeat")
			.end()
		.find("li ul")
			.addClass("secondary")
			.end()
		.find("li ul li ul")
			.removeClass("secondary")
			.addClass("tertiary")
			.end()
		.find("li:has(ul.secondary)")
			.addClass("expandable")
			.append("<div class=\"toggleCtrl\">")
			.end()
		.find("ul.tertiary")
		  .parent("li")
			.addClass("inflatable")
			.end()

  // This is the tertiary level control function
	$("li.inflatable > a")
//	  .mouseover(function() {
//			$(this)
//			  .css("fontWeight","bold")
//			  .css("background","#ECF2F9 url(images/sn_inflatable_minus.gif) right 4px no-repeat");
//			$("ul.tertiary", this)
//				.css("display","block");
//			})
//	  .mouseout(function() {
//			$("ul.tertiary", this)
//				.css("display","none");
//			$(this)
//			  .css("fontWeight","normal")
//			  .css("background","#FFF url(images/sn_inflatable_plus.gif) right 4px no-repeat");
//			});
	  .toggle(function() {
				$(this).parent("li:has(ul.tertiary)")
					.css("fontWeight","bold")
					.css("background","#ECF2F9 url(images/sn_inflatable_minus.gif) right 4px no-repeat")
					.find("ul.tertiary")
						.css("display","block");
			},function() {
				$(this).parent("li:has(ul.tertiary)")
					.css("fontWeight","normal")
					.css("background","#FFF url(images/sn_inflatable_plus.gif) right 4px no-repeat")
					.find("ul.tertiary")
						.css("display","none");
			});

  // This is the Collapse/Expand onClick function
	$(".sn div.toggleCtrl").click(function() {
		$(this).parent("li:has(ul)")
		  .swapClass("expandable","collapsible")
			.end()
		$("#snBlock") // Necessary to overcome an IE6 rendering bug
		  .css("visibility","hidden").css("visibility","visible")
		});

  // These are the collapse/expand buttons
	$("a.snCollapseAll").click(function(){
	  $("div.sn li.collapsible")
		  .removeClass("collapsible")
		  .addClass("expandable")
			});
	$("a.snExpandAll").click(function(){
	  $("div.sn li.expandable")
		  .removeClass("expandable")
		  .addClass("collapsible")
			});

	}); // end ready function
