/*
Side Navigation - by Russell James Smith (AWA) April 2007.

This code is dependant on the JQuery Lib.

On calling the initialize function this code will setup events to
deal with the opening and closing of the side-nav.
*/

function sideNav_initialize () { 

	/* hide all side nav that shouldn't be open .filter(".open") */
	// $("div.sideNav div.inner").wrap("<div class=\"peekaboo\"></div>");
	
	/* hide all side nav that shouldn't be open .filter(".open") */
	$("div.sideNav").not(".open").find("div.peekaboo").toggle();
	
	
	/* Functions to display alt tags for the h3 tags on */
	/* the left nav when the menus are open/closed      */
	$("div.sideNav h3").each(function(){
	  
	    var className;
	    className = $(this).parent().attr("class");
	    
	    if (className == "sideNav closed open")
	    {
	        $(this).attr("title", "Collapse");
	    }
	    
	    else if (className == "sideNav closed")
	    {
	        $(this).attr("title", "Expand");
	    }
	    
	});
	

	/* function to show/hide side nav */
	$("div.sideNav h3").click(function() {
		if ( $(this).parent().attr("class").search(/open/i) >= 1 ) {
			    $(this).parent().toggleClass("motion").find("div.peekaboo").slideUp("fast",function(){
	   		    $(this).parent().toggleClass("motion").toggleClass("open");
	 		});
	 		
	 		$(this).attr("title", "Expand");
	 		$(this).toggleClass("open");
	 	  
		} else {						
			    $(this).parent().toggleClass("motion").find("div.peekaboo").slideDown("fast",function(){
	   		    $(this).parent().toggleClass("motion").toggleClass("open");
	 		});
	 		
	 		    $(this).attr("title", "Collapse");
	 		    $(this).toggleClass("open");
 		}
	});
}