function initMegaDrops() {

	function addMega(){
		$(this).addClass("hovering");
	}
	function removeMega(){
		$(this).removeClass("hovering");
	}
	
	var megaConfig = {
		interval: 300,
		sensitivity: 4,
		over: addMega,
		timeout: 50,
		out: removeMega
	};
	
	$("li.mega").hoverIntent(megaConfig);
}
function initSideColMenu() {
	$('.navcol ul').hide();
	$('.navcol li.parent-here ul').show();
	$('.navcol li a').click(
	    function() {
	      var checkElement = $(this).next();
	      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
	        $('.navcol ul:visible').slideUp('normal');
	        return false;
	        }
	      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
	        $('.navcol ul:visible').slideUp('normal');
	        checkElement.slideDown('normal');
	        return false;
	        }
	      }
	);
}
function initBigTargets() {
	$("div.bigTarget>p>a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(0)' // jQuery parent selector
	});
	$("div.bigTarget>h3>a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(0)' // jQuery parent selector
	});
	$("div.bigTarget>div>p>a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(1)' // jQuery parent selector
	});		
	$("div.bigTarget>div>h3>a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(1)' // jQuery parent selector
	});		
	$("div.bigTarget>div>a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(1)' // jQuery parent selector
	});		
}
function initMentorFormSubmit() { 
	var options = { 
		target:        '#hiddenDIV',   // target element(s) to be updated with server response 
	    beforeSubmit:  beforePost,  // pre-submit callback 
	    success:       afterPost  // post-submit callback 
	};
	$('#MentorApplicationForm').validate({
	    submitHandler: function(form) {
			$('#MentorApplicationForm').ajaxSubmit(options);
		}
	});
	// pre-submit callback 
	function beforePost() { 
		$("#mentorSubmit").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") {
			$("#MentorApplicationForm").hide();
			$("#mentorFormNotification").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 initMenteeFormSubmit() { 
	var options = { 
		target:        '#hiddenDIV',   // target element(s) to be updated with server response 
	    beforeSubmit:  beforePost,  // pre-submit callback 
	    success:       afterPost  // post-submit callback 
	};
	$('#MenteeApplicationForm').validate({
	    submitHandler: function(form) {
			$('#MenteeApplicationForm').ajaxSubmit(options);
		}
	});
	// pre-submit callback 
	function beforePost() { 
		$("#menteeSubmit").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") {
			$("#MenteeApplicationForm").hide();
			$("#menteeFormNotification").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 initSlideShows() {
	$('.slideshow').cycle({ 
	    fx:    'fade', 
	    timeout:  4500 
	 });
}
function initMentorFancyBox() {
	$("#wcMentorlightbox").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
	$("#ypsnMentorlightbox").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
	$("#wcMenteelightbox").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
	$("#ypsnMenteelightbox").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
	$("#wcMenteelightboxHp").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
	$("#ypsnMenteelightboxHp").fancybox({
		'overlayOpacity'	: '0.5',
		'scrolling'		    :  'no'
	});
}

function initShowOtherInput(){
	$('.othercheckbox').click(
    function() {
        $(this).parent().find('.otherinput').toggle();
    });
}

$(document).ready(function() {
	initMentorFancyBox();
	initMegaDrops();
	initSideColMenu();
	initBigTargets();
	initMentorFormSubmit();
	initMenteeFormSubmit();
	initSlideShows();
	initShowOtherInput();
	});
