$(document).ready(function() {
	var arClasses = ['color-one','color-two','color-three','color-four','color-five','color-six','color-seven'];
	/* Treeview Menu */
	$('ol.treeview a.fold').siblings('ul').hide(); 
	$('ol.treeview a.fold').click(function(e) {
		e.preventDefault();
		$(this).siblings('ul').toggle();
		var menu_state =  $.cookie('jsmenu');
		var theText = $(this).attr('href');
		theText = theText.replace('#','');
		if($(this).siblings('ul').css('display') == 'none') {
			$(this).html('&#8595;');
			menu_state = menu_state.replace(','+theText,'');
		} else {
			$(this).html('&#8593;');
			menu_state = menu_state+','+theText;
		}
		//alert(menu_state);
		$.cookie('jsmenu', menu_state);
	});
	
	$('ol.treeview > li').each(function(id, domRef) {
		//alert(arClasses[id]);
		$(this).addClass(''+arClasses[id]+'');
	});
	
	setMenuState($.cookie('jsmenu'));
	
	function setMenuState(cookieString) {
		if(cookieString == undefined) {
			return;
		}
		var menusDown = cookieString.split(",");
		$('ol.treeview a.fold').each(function(id, domRef) {
			//arClasses
			//alert(arClasses[id]);
			for(var i=0;i<menusDown.length;i++) {
				var compareString = $(this).attr('href');
				compareString = compareString.replace('#','');
				if(compareString == menusDown[i]) {
					$(this).siblings('ul').toggle();
				}
			}
		});
	}
	
});
