
$(document).ready(function() {
	// hides the slickbox as soon as the DOM is ready
	// (a little sooner than page load)
	$('#products-nav ul').parent().siblings().find("ul").hide();
	
	//open the current category
	var parent = $('.products-current');
	
	//if parent exists
	if (parent.length) {
		//loop over parents until #products-nav and open it
		while (parent) {
			if (parent.is('#products-nav')) {
				break;
			}

			parent.show();
			
			parent = parent.parent();
		}
	}
	
	// toggles the slickbox on clicking the noted link
  	$('#products-nav a').click(function() {
 		$(this).next().toggle('normal');

		//return false;
  	});
});

/*
Collapsible nav 0.1.0 - plugin for collapsing navigation and remembering the closed/open state
http://scottdarby.com/

Copyright (c) 2009 Scott Darby

Requires: jQuery 1.3
		  jquery.cookie plugin by Klaus Hartl

Licensed under the GPL license:
http://www.gnu.org/licenses/gpl.html
*/
/*
jQuery.fn.collapsibleNav = function(options) {

	var defaults = {
		hideByDefault: 'top-1,top-2,top-3,top-4,top-5,top-6,top-7', //ids of elements you want hidden by default
		clickController: 'h4', //your heading elements
		slideSpeed: 'normal' //speed of animation
	};

	//initial variables
	var opts = jQuery.extend(defaults, options),
		$list = jQuery(this),
		$heading = $list.find(opts.clickController),
		$listItems = $list.children(),
		closedItems;
	
	//function that is called when slidable is clicked
	function updateArray(e) {
		//get id of element for adding to array
		var eId = jQuery(e).attr('id');
		
		//look for element in cookie array
		var arrPos = jQuery.inArray(eId, closedItems);

		if (arrPos == -1) {
			//element not in array, add element
			closedItems.push(eId);
		} else {
			//element in array, remove element
			closedItems.splice(arrPos, 1);
		}
		//update cookie
		jQuery.cookie('closedItems', closedItems, { path: '/', expires: null });
	}
	
	//remember closed/open state of nav items
	if (jQuery.cookie) {
		
		//if no cookie called "closedItems" exists, then create one with
		//elements you want hidden by default.
		//'1' is given as first value to prevent cookie from being 
		//deleted if it contains no ids
		
		if (!jQuery.cookie('closedItems')) {
			jQuery.cookie('closedItems', '1,'+opts.hideByDefault, { path: '/', expires: null });
		}

		//if cookie exists
		if (jQuery.cookie('closedItems')) {
			
			//split cookie into array
			closedItems = jQuery.cookie('closedItems').split(',');
			//iterate through array and apply closed class to each element within it
			for (var i = 0; i < closedItems.length; ++i) {
				jQuery('#' + closedItems[i]).addClass('closed');
			}
			//hide content underneath each element that has a class of closed
			jQuery('.closed').children('ul').hide();
		}
	}
	
	//$heading.append('<span class="toggleIcon"> </span>');
	
	$heading.click(function(){
		
		var $target = jQuery(this),
			$parent = $target.parent();

		//toggle closed class
		$parent.toggleClass('closed');

		//slidey stuff
		$target.next().slideToggle(opts.slideSpeed);

		//update cookie with current li
		updateArray($parent);

		return false;

	});
	
	return this;
	
};
*/