/********************************************************************************************************************
	heavily modified accordian script for the purposes of this project - please don't modify without talking to Rod first
********************************************************************************************************************/	

$(document).ready(function() {
	 
	//ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.accordionButton').click(function() {
		
		// sets the cookie so we can open the proper tab when the user navigates back to the page.
		var myCook = $(this).attr("id");
			
			document.cookie = "acc="+ myCook;
			
		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.accordionButton').removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.accordionContent').slideUp('fast');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next().is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('on');	
			  
			//OPEN THE SLIDE
			$(this).next().slideDown('slow');
			
		 } 
	});
	  
	/*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	//ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
	$('.accordionButton').mouseover(function() {
		//alert($(this).attr('class'))
		
		if ($(this).attr('class') != 'accordionButton on' ){
		
		$(this).addClass('over');}
		
	//ON MOUSEOUT REMOVE THE OVER CLASS
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	
	/*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/
	
	/********************************************************************************************************************
	OPENS THE CHEV TAB *unless* we have the acc cookie, in which case we open the appropriate tab
	********************************************************************************************************************/	
	$('.accordionContent').hide();
	
		var myAcc = getCookie("acc");
			if(myAcc) {
			$("#"+myAcc).trigger('click');
			}
			else {
			$("#chev-butt").trigger('click');
			//prevent setting the cookie on the default click
			del_cookie("acc");
			}
		});

