// Set a browser cookie with name and value function setCookie(name, value) { document.cookie = name + "=" + value + "" + "; path=/"; } // Return the value of the browser cookie name, or null if none function getCookie(name) { var cookies = document.cookie.split(';'); var name = name + "="; for(var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; while (cookie.charAt(0)==' ') { cookie = cookie.substring(1, cookie.length); } if (cookie.indexOf(name) == 0) { return cookie.substring(name.length, cookie.length); } } return null; } // Delete the browser cookie name function removeCookie(name) { document.cookie = name + "=''; expires=Fri, 13 Jul 2001 00:00:00 UTC; path=/"; } // Return true if the control panel should be visible function isControlPanelVisible() { return getCookie("controlPanel") == "block"; } // Show the control panel based on the user's preferences. If instant is true, do the adjust in 0 milliseconds. function adjustControlPanelVisibility(instant) { if (isControlPanelVisible()) { if (instant) jQuery("#controlPanel").show(); else jQuery("#controlPanel").slideDown("fast"); } else { jQuery("#controlPanel").slideUp("fast"); } } // Hide the control panel function hideControlPanel() { removeCookie("controlPanel"); } // Toggle the control panel function toggleControlPanel() { setCookie("controlPanel", isControlPanelVisible() ? "none" : "block"); adjustControlPanelVisibility(); } // Return the div id corresponding to the toggle arrow for expanding menu menuId function toggleMenuArrow(menuId) { return menuId + "_toggle"; } // Toggle expanding menu named menuId function toggleMenu(menuId) { // Toggle the control panel visibility toggleVisibility(menuId); // Note the new display state state = document.getElementById(menuId).style.display; // Remember what's showing setCookie(menuId, state); // Adjust the arrow document.getElementById(toggleMenuArrow(menuId)).className = (state == "block") ? "expandingMenuOpen" : "expandingMenuClosed"; } // Adjust the visibility for the expanding menu based on the user's selection, defaulting to open function adjustMenuVisibility(menuId) { state = getCookie(menuId) ? getCookie(menuId) : "block"; document.getElementById(menuId).style.display = state; document.getElementById(toggleMenuArrow(menuId)).className = (state == "block") ? "expandingMenuOpen" : "expandingMenuClosed"; } // Push the search button function search() { document.searchForm.submit(); }