	
	jQuery.easing['jswing'] = jQuery.easing['swing'];

	jQuery.extend( jQuery.easing,
	{
		def: 'easeOutCubic',
		swing: function (x, t, b, c, d) {
			return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
		},	
		easeOutCubic: function (x, t, b, c, d) {
			return c*((t=t/d-1)*t*t + 1) + b;
		}
	});
	


	function menuSpeed(height)
	{
		return 300 + ((height*2)/3);
	}	

	function menuMouseOver(menuIndex)
	{
			
			//first, if we have a close timer running (ie menu is presently open), cancel it...
			if(document.menuTimeout[menuIndex]!=0){
				clearTimeout(document.menuTimeout[menuIndex]);
			}

			//if we're not presently showing this menu...
			if(!document.menuShowing[menuIndex]){
				$menuHeading = $('#menuHeading'+menuIndex)
				$dropMenu = $('#'+$menuHeading.data("dropMenuID"));
				$menuHeading.addClass("leftNavMenuItemHover");						
				
				$child = $dropMenu.find(':first');
				$child.css('position','relative');				
				$dropMenu.css('clip','rect(0px,'+$dropMenu.width()+'px,'+$dropMenu.height()+'px,0px)');				
				$child.css('top',0-$dropMenu.height()-1);
				
				$child.stop().animate({top:'0px'},menuSpeed($dropMenu.height()),'easeOutCubic');
				
				$dropMenu.show();
					
				document.menuShowing[menuIndex] = true;			
			}
			
			//make sure the other menus are closed tho
			for(i=1;i<=document.menuCount;i++){
				if(i!=menuIndex && document.menuShowing[i]){
					if(document.menuTimeout[i]!=0){//if there is a timeout pending, stop it
						clearTimeout(document.menuTimeout[i]);
					}
					closeMenu(i); //just close menu
				}			
			}
			
	}		
	
	function menuMouseOut(menuIndex)
	{
		document.menuTimeout[menuIndex] = setTimeout('closeMenu('+menuIndex+');',500);	

	}
	
	function closeMenu(menuIndex)
	{
			if(document.menuShowing[menuIndex]){
				document.menuShowing[menuIndex] = false;
				document.menuTimeout[menuIndex] = 0; //no longer running a timer for this...
				$menuHeading = $('#menuHeading'+menuIndex)
				$dropMenu = $('#'+$menuHeading.data("dropMenuID"));
				$menuHeading.removeClass("leftNavMenuItemHover");		
				//$dropMenu.fadeOut(200);		
				$child = $dropMenu.find(':first');
				$child.stop().animate({top:''+(0-$dropMenu.height()-1)+'px'},menuSpeed($dropMenu.height()),'easeOutCubic',function(){$dropMenu.hide();/*make sure hidden at the end to stop it occupying space*/});
				
			}
	}
	
	function initialiseMenus(numberOfMenus)
	{		 
		document.menuCount=numberOfMenus;
		document.menuTimeout = new Array(); //id of timer if close is pending
		document.menuShowing = new Array(); //true/false if menu is presently being shown (not the display property, so independent of actual visibility (due to fades)).
		 
		for(i=1;i<=document.menuCount;i++){
		 	 document.menuTimeout[i] = 0;
			 document.menuShowing[i] = false;
			 $('#menuHeading'+i).data("dropMenuID",'dropMenu'+i);
			 $('#menuHeading'+i).data("dropMenuIndex",i);
			 $('#menuHeading'+i).hover(
				  function () {
					menuMouseOver($(this).data("dropMenuIndex"));
				  }, 
				  function () {
					menuMouseOut($(this).data("dropMenuIndex"));
				  }
				);				 
		}//i					
		
		//left navigation
		$(".navItem:not(.navItemSel)").hover(
		  function () {
			$(this).addClass("navItemHover");
		  }, 
		  function () {
			$(this).removeClass("navItemHover");
		  }
		);	
	}
	
	function preloadImages()
	{
		 $("<img>").attr("src", "/img/menuBottom.gif");
		 $("<img>").attr("src", "/img/menuTop.gif");
		 $("<img>").attr("src", "/js/lightboximg/lightbox-ico-loading.gif");	
		 $("<img>").attr("src", "/img/menuSelBg.gif");		 
	}
	
	function initialiseLightbox()
	{
		$('a.lightbox').lightBox({
			overlayBgColor: '#000000',
			overlayOpacity: 0.6,
			imageBlank: '/js/lightboximg/lightbox-blank.gif',
			imageLoading: '/js/lightboximg/lightbox-ico-loading.gif',
			imageBtnClose: '/js/lightboximg/lightbox-btn-close.gif',
			imageBtnPrev: '/js/lightboximg/lightbox-btn-prev.gif',
			imageBtnNext: '/js/lightboximg/lightbox-btn-next.gif',
			containerResizeSpeed: 350,
			fixedNavigation:false,
			txtImage: 'Screenshot',
			txtOf: 'of'
		});		
	}