jQuery(document).ready(function(){
	
	jQuery('#rightCol .moduletable-slide h3').each(function(index){
		var $this=jQuery(this);
		var $checkElement=$this.next('div');
		var $modID=$checkElement.attr('id');
		if (jQuery.cookie($modID) == 'close') {
			jQuery($checkElement).hide();
			$this.addClass('close');
		}
		else {
			$this.addClass('open');
		}
		$this.click(function(){
			checkCookie($checkElement, $this, $modID);
		})
	});
	
	jQuery('button').click(function(){
		jQuery.cookie('menuCookie','',{expires:-1});
		jQuery('.panelMenu > li ul').hide();
		showCookie()
	})
});

function checkCookie($checkElement, $this, $modID) {
	if($checkElement.is(':hidden')){
		$checkElement.slideDown("fast");
		$this.removeClass('close');
		$this.addClass('open');
		cookieValue='open';
		jQuery.cookie($modID,cookieValue)
	}
	else{
		$checkElement.slideUp();
		cookieValue='close';
		$this.removeClass('open');
		$this.addClass('close');
		jQuery.cookie($modID,cookieValue)
	}
}