/***********************************************************************************************************************
DOCUMENT: includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 3/26/2009
UPDATED: 3/25/2010
DESCRIPTION: This is the JavaScript required to create the accordion style menu.  Requires jQuery library
NOTE: Because of a bug in jQuery with IE8 we had to add an IE stylesheet hack to get the system to work in all browsers. I hate hacks but had no choice :(.
************************************************************************************************************************/
$(document).ready(function() {

	$('.accord ul li.selected').addClass('on');

	//accordION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.accord ul li a').click(function() {
		//REMOVE THE ON CLASS FROM ALL BUTTONS
		//$('.accord ul li').removeClass('on');
		$(this).parent().children("li").removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	//$('.accord ul li ul').slideUp('normal');
	 	$(this).parent().parent().find("ul").slideUp('normal');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next('ul').is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).parent().addClass('on');
			  
			//OPEN THE SLIDE
			$(this).next('ul').slideDown('normal');
		 }
	 });
	
	
	/********************************************************************************************************************
	CLOSES ALL S ON PAGE LOAD
	********************************************************************************************************************/	
	$('.accord ul li ul').hide();
	$('.accord ul li.selected ul').show();
});

