jQuery(document).ready(function() {
	// Main navigation dropdowns
	jQuery("ul#nav").superfish({ speed: "fast", delay: 100 });
	
	// Search Box
	// using the label2value plugin
	label2value("form#searchform");
		
	// jump menus
	function initJumpMenus() {
		// Turns all <select> elements with the 'jumpmenu' class into jump menus
		var selectElements = document.getElementsByTagName("select");
		for( i = 0; i < selectElements.length; i++ ) {
			// Check for the class and make sure the element has an ID
			if( selectElements[i].className == "jumpmenu" && document.getElementById(selectElements[i].id) != "" ) {
				jumpmenu = document.getElementById(selectElements[i].id);
				jumpmenu.onchange = function() {
					if( this.options[this.selectedIndex].value != '' ) {
						// Redirect
						location.href=this.options[this.selectedIndex].value;
					}
				}
			}
		}
	}
	window.onload = function() {
		initJumpMenus();
	}
	
	// shims (for dealing with IE)
	jQuery("ul > li:first-child").addClass("firstChild");
	jQuery("ul > li:last-child").addClass("lastChild");
	jQuery("dl > dt:first-child").addClass("firstChild");
	jQuery("dl > dd:last-child").addClass("lastChild");
	
});
