
var navFadeOutDelay = 1500; // Set delay for fade to active state

$(document).ready(function(){
		
	(function($){
		jQuery.fn.delay = function(millis,callBack){
			var object = $(this);
			$.extend(object,{callBack:callBack});
			return window.setTimeout(function() {
				object.callBack();
				return object;
			}, millis);
		}
	})(jQuery);
	
	var nav = {count:0};

	$(".box .nav-hide").hide(); //hide non active navigation on page load.

        $(function(){
		 $('.nav-advertise').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-advertise").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-advertise").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});

        $(function(){
		 $('.nav-links').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-links").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-links").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});

         $(function(){
		 $('.nav-articles').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-articles").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-articles").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});

          $(function(){
		 $('.nav-media').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-media").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-media").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});

     $(function(){
		 $('.nav-holidays').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-holidays").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-holidays").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});


        $(function(){
		 $('.nav-none').bind('hover',function(){ // On mouseenter, show navigation
                $(".box .nav-active").hide();
                $(".box .nav-hide").hide();
	        $(".box .nav-none").show();
			nav.count += 1;
		}).bind('hoverend',function(){ // On mouseleave, fade out navigation and show title
			var tmp = nav.count;
			$(".box .nav-none").delay(navFadeOutDelay, function(){ // Delay: wait X ms before navigation FadeOut
               if (tmp == nav.count) { // prevent delay from firing if user hovers navigation before the end of delay
			        $(this).fadeOut('fast', function(){ //Callback
                                                 $(".box .nav-active").show();
					});
                      }
		    });
		});
	});



});
