
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};


var activePage = null;
var mouseOnbutton = false;
$(document).ready(
				  function(){
						// center layout
						$("#slider").easySlider();
						//enable nav menu hovers
						activePage = $('#active_nav');//remember the current page
						nav();
					});

//enables hover styles for nav menu.
function nav()
{
	$('.nav_button *').mouseenter(
					   function(){
						   mouseOnButton = true;
							$('#active_nav').removeAttr('id');
							$(this).parents('.nav_button').attr('id','active_nav');
					   }
	);
	//when mouse leaves the menu, the active button should be the original button that was highlighted
	$('#nav').mouseout(
					 function(){
						 mouseOnButton = false;
						 $(this).delay(100,
									   function(){
										   if(!mouseOnButton){
											$('#active_nav').removeAttr('id');
											activePage.attr('id','active_nav');
										   }
					 					}
						);
					 }
				 );
}
