


$(document).ready(function() {

	//
	// Mega Menu
	//

	function showMega(){
	  $(this).addClass("hovering");
	  $( $(this).children('.subNav') ).slideDown("medium");
	}
	
	function hideMega(){
	  $(this).removeClass("hovering");
	  $( $(this).children('.subNav') ).slideUp("fast");
	}

	var megaConfig = {    
  		interval: 200,
 		sensitivity: 4,
		over: showMega,
		timeout: 300,
		out: hideMega
	};

	$("li.mega").hoverIntent(megaConfig);
	
	
	
	//
	// Search Form
	//

	var shortForms = new Array(
	  "#search_form"
	);
	handleShortFormEvent(shortForms);
	 
	
	/**
	 * Handle initialization of all short forms
	 *
	 * @param array shortForms Array of short form IDs
	 */
	function handleShortFormEvent(shortForms) {
	  for (var i in shortForms) {      
		shortFormInit(shortForms[i]);
	  }
	}
	 
	/**
	 * Initialize a short form. Short forms may contain only one text input.
	 *
	 * @param string formID The form's ID, including #
	 */
	function shortFormInit(formID) {
	  // Get the input ID and it's label text
	  var labelValue = $(formID + " input[type='text']:first").siblings("label").html();
	  var inputID = "#" + $(formID + " input[type='text']:first").attr("id");
	 
	  // Set the input value equal to label text
	  $(inputID).val(labelValue);
	 
	  // Attach event listeners to the input
	  $(inputID).bind("focus blur", function(e){
		var eLabelVal = $(this).siblings("label").html();
		var eInputVal = $(this).val();
	 
		// Empty input value if it equals it's label
		if (eLabelVal == eInputVal) {
			$(this).val("");
		// Reset the input value if it's empty
		} else if ($(this).val() == "") {
		  $(this).val(eLabelVal);
		}
	  });
	}
	
	
	// VALIDATE:
	
	
	

});


