// thanks to http://ifohdesigns.com/blog/tutorials/unobtrusive-jquery-slide-toggle-with-cookies and http://www.bramme.net/
$(document).ready(function() {

	// the div that will be hidden/shown

	var panel = $("#ribbon");

	//the button that will toggle the panel

	var button = $("#slideribbon a");

	// do you want the panel to start off collapsed or expanded?

	var initialState = "expanded"; // "expanded" OR "collapsed"

	// the class added when the panel is hidden

	var activeClass = "hidden";

	// the text of the button when the panel's expanded

	var visibleText = "hide ribbon";

	// the text of the button when the panel's collapsed

	var hiddenText = "show ribbon";


	//---------------------------

	// don't edit below this line

	//---------------------------

	if($.cookie("panelState") == null) {

		$.cookie("panelState", initialState, {path: "/"});
	} 

	var state = $.cookie("panelState");

	if(state == "collapsed") {

		panel.hide();

		button.text(hiddenText);

		button.addClass(activeClass);

	}

	button.click(function(){

		if($.cookie("panelState") == "expanded") {

			$.cookie("panelState", "collapsed", {path: "/"});

			button.text(hiddenText);

			button.addClass(activeClass);

		} else {

			$.cookie("panelState", "expanded", {path: "/"});

			button.text(visibleText);

			button.removeClass(activeClass);

		}

		panel.slideToggle("slow");

		return false;

	});

});