function groupsMenu() {
	// create a default array with all elements closed
	var groupsArray = new Array();
	groupsArray[0] = "closed";
	groupsArray[1] = "closed";
	groupsArray[2] = "closed";
	groupsArray[3] = "closed";
	$('#groups ul').hide();
	$('#groups li a').click(
		function() {
			$(this).next().slideToggle('normal',function(){
				var id = $(this).attr('id'); // the ID of a sliding element, ex: "slide_3"
				var number = id.charAt(6); // take just the number from the ID, ex: "3"
				if ($(this).is(':hidden')) {
					var state = "closed";
				} else if ($(this).is(':visible')) {
					var state = "open";
				}
				groupsArray[number] = state; // update the array to set the number of the element clicked to its new state, ex: groupsArray[3] = "open";
				$.cookie('groupsList', groupsArray); // save the updated array as a cookie
				return false;
			 });
		}
	);
	// if cookie exists, put data into an array
	if ($.cookie('groupsList')) {
		var temp = $.cookie('groupsList');
		var groupsList = new Array();
		groupsList = temp.split(',');
		// loop through array to find any sliding elements that should be opened
		for(var i=0; i < groupsList.length; i++) {
			// if an element is found in the cookie that should be opened, open it and update the array as well
			if (groupsList[i] == "open") {
				$('#groups #slide_' + i).show();
				groupsArray[i] = "open";
			}
		}
	// cookie doesn't exist, so create one with all elements closed.
	} else {
		$.cookie('groupsList', groupsArray);
	}
}
// Load groupsMenu when the page is ready for it.
$(document).ready(function() {groupsMenu();});// JavaScript Document