function initSearch() {
	$(function(){ //Document ready shorthand
	var $search = $('#keywords');//Cache the element for faster DOM searching since we are using it more than once
	original_val = $search.val(); //Get the original value to test against. We use .val() to grab value="Search"
	$search.focus(function(){ //When the user tabs/clicks the search box.
		if($(this).val()===original_val){ //If the value is still the default, in this case, "Search"
			$(this).val('');//If it is, set it to blank
		}
	})
	.blur(function(){//When the user tabs/clicks out of the input
		if($(this).val()===''){//If the value is blank (such as the user clicking in it and clicking out)...
			$(this).val(original_val); //... set back to the original value
		}
	});
});
}
function initMegaDrops() {

	function addMega(){
		$(this).addClass("hovering");
	}
	function removeMega(){
		// Assign var to autocomplete results div
		var checkAutoComplete = $(".ac_results");
		
		// Check if there are autocomplete results. If no results, then remove megadrop on hover out
		if((checkAutoComplete.is(":hidden")) || (checkAutoComplete.length == 0)){
			$(this).removeClass("hovering");
		}
	}
	
	var megaConfig = {
		interval: 500,
		sensitivity: 4,
		over: addMega,
		timeout: 500,
		out: removeMega
	};
	
	$("li.mega").hoverIntent(megaConfig);
}
function initCycle() {
	$('#slideshow').cycle({ 
	   fx: 'fade', 
	   speed: 1000,
	   timeout: 4000,
	   cleartypeNoBg: true
	 });
}
function initContactFormSubmit() { 
	var options = { 
		target:        '#hiddenDIV',   // target element(s) to be updated with server response 
	    beforeSubmit:  beforePost,  // pre-submit callback 
	    success:       afterPost  // post-submit callback 
	};
	$('#ContactForm').validate({
	    submitHandler: function(form) {
			$('#ContactForm').ajaxSubmit(options);
		}
	});
	// pre-submit callback 
	function beforePost() { 
		$("#contactSubmit").hide();
		$("#submitMessage").show();
	    // here we could return false to prevent the form from being submitted; 
	    // returning anything other than false will allow the form submit to continue 
	    return true; 
	} 
	// post-submit callback 
	function afterPost(rtn)  { 
	    if(rtn=="success") {
			$("#ContactForm").hide();
			$("#contactFormNotification").fadeIn("slow");
			pageTracker._trackPageview("/conversion/mentor-form-success");
		}else{
	        //there was an error, so grab the UL in the content ID, 
	        //inside the hidden DIV, and put it into the Message Notification
	      $("#errorMessage").html(  $("#hiddenDIV #content ul").html() );
		  $("#hiddenDIV").empty(); 
	     }
	}
}
function initPAmenu() {
  $('.PAmenu ul').hide();
  $('.PAmenu ul.current').show();
  $('.PAmenu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        $('.PAmenu ul:visible').slideUp('normal');
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('.PAmenu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }

$(document).ready(function() {
	initMegaDrops();
	initPAmenu();
	initSearch();
	initCycle();
	initContactFormSubmit();
});
