$(document).ready(function() { // JavaScript File BEGIN!

// Main Navigation DropDown
/*---------------------------------------------------------*/
function megaHoverOver(){
    $(this).find("ul").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
}

function megaHoverOut(){
  $(this).find("ul").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
  });
}

var config = {
     sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
     interval: 100, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};

$(".nav ul li ul").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
$(".nav ul li ul").parent().find("a:first").stop().append(" <small>&raquo;</small>");
$(".nav ul li").hoverIntent(config); //Trigger Hover intent with custom configurations

// NivoSlider (Used in the Header)
/*---------------------------------------------------------*/
$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'random', 
		slices:15,
		animSpeed:500, 
		pauseTime:3000,
		startSlide:0, 
		directionNav:true, 
		directionNavHide:true, 
		controlNav:true, 
		controlNavThumbs:false, 
      controlNavThumbsFromRel:false, 
		controlNavThumbsSearch: '.jpg', 
		controlNavThumbsReplace: '_thumb.jpg', 
		keyboardNav:true, 
		pauseOnHover:true, 
		manualAdvance:false, 
		captionOpacity:0.8, 
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} 
	});
});	


// Tabs
/*---------------------------------------------------------*/
$("ul.tabs").tabs("div.panes > div",{
	effect: 'slide'
});

// FancyBox (Used for the trainer & resgistration links)
/*---------------------------------------------------------*/
$("#signup-button").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
$(".trainer-link").fancybox({
				'width'				: 630,
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});


// loopedSlider (Used for Testimonials)
/*---------------------------------------------------------*/
$('#loopedSlider').loopedSlider({
		autoHeight: false,
		containerClick: false, //Click slider to goto next slide? true/false
		autoStart: 2500, //Set to positive number for true. This number will be the time between transitions.
		restart: 5000,
		effect: 'fade',
		hoverPause: true //Set to true to pause on hover, if autoStart is also true
});

// IE cat list float fix
/*---------------------------------------------------------*/
if (jQuery.browser.msie) {
	$('.widget_categories').append('<div class="clear"></div>');
};

});// JavaScript File END!
