// when doc has loaded
$(function() {

	function addMega(){
	
		// add class for highlighting on hover
		$(this).find('span.lib_mm_hd').addClass('hover').end()

		// animate drop down content into view
		.find('.gis').slideDown('normal').end()

		// style for when hovering to set display:block (visible) after initially being set to :none.
		.addClass('hovering');

		}

	function removeMega(){

		// remove class for highlighting on hover
		$(this).find('span.lib_mm_hd').removeClass('hover').end()

		// animate drop down content out of view
		.find('.gis').slideUp('normal').end()

		// remove class so not displayed
		.removeClass('hovering');

	}

// overide the default settings
	var megaConfig = {
 		interval: 100,
 		sensitivity: 10,
 		over: addMega,		// on hover function
 		timeout: 100,
 		out: removeMega		// on out function
	};

	// Set z-index values to defeat ie7 bug so mega menus on top of animated object
	// issue - http://richa.avasthi.name/blogs/tepumpkin/2008/01/11/ie7-lessons-learned/
	// jquery solution - http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/#comment-105
	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});

	// initiate mage menu
	// attach the hoverIntent to each li in the tabs ul,
	// passing it a config object as a single parameter
	$('li.lib_mm_con').hoverIntent(megaConfig)

});
