$(document).ready(function() {

	//hide module descriptions and menu contents on ready
	$('.moduleDescription').hide();
	$('.menuContents').hide();

	//indent the categoryTitle on mouseenter
	$('.categoryTitle').bind("mouseenter",function(){
			if (!$(this).hasClass('open')) {
				$(this).children('.categoryTitleLeft').animate({marginLeft:"10px"},150);
			}
			else {
				$(this).children('.categoryTitleLeft').animate({marginLeft:"0px"},150);
			}
		}).bind("mouseleave",function(){
			if (!$(this).hasClass('open')) {
				$(this).children('.categoryTitleLeft').stop().css({marginLeft:"0px"});
			}
			else {
				$(this).children('.categoryTitleLeft').stop().css({marginLeft:"10px"});
			}
		});

	//mouseenter on .categoryTitle shows menu contents after 1 second, as well as toggleSlides menu contents on click
	$('.categoryTitle').bind("mouseenter",function(){
		$(this).animate({opacity:"1.0"},1000,function(){
			$(this).next('.menuContents').slideDown(200).prev().addClass('open');
		});
	}).click(function(){
		$(this).stop().next('.menuContents').slideToggle(200).prev().toggleClass('open');
	}).bind("mouseleave",function(){
		$(this).stop();
	});

	//mouseenter on .moduleTitle animates the projectName text
	$('.moduleTitle').bind("mouseenter", function() {
		$(this).children(".projectName").animate({marginLeft:"5px", color: "#DDDD77"},200, function(){
			$(this).animate({color: "#000000"},800);
		})
	}).bind("mouseleave", function () {
		$(this).children(".projectName").stop().css({marginLeft: "0px",color: "#000000"});
	});

	//mousing over .moduleTitles will show contents for one module at a time.
	$('.moduleTitle').bind("mouseenter", function() {
		if(!$(this).hasClass('open')) { //if this is not already open, start the process to show the module description
			$(this).animate({opacity: "1.0"}, 1000, function() {
				$('.moduleCategory').find('.moduleTitle').addClass('inactive');					
				$(this).removeClass('inactive').addClass('locked');
				$(this).children('.moduleDescription').slideDown(150, function () {
					$(this).parent().removeClass('locked');
					$('.moduleCategory').find('.inactive').children('.moduleDescription').slideUp(150);
				});
			});
		}
	}).bind("mouseleave",function() {
		if (!$(this).hasClass('locked')) {
			$(this).stop();
		}
	});

});