/* Author: 

*/
var $j = jQuery.noConflict(); 
/*--------------This is for MEGA HOVER DROPDOWN--------------*/
	$j(document).ready(function() {
	

	function megaHoverOver(){
		$j(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$j(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $j(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$j(this).find(".row").each(function() {							   
				$j(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$j(this).find(".sub").css({'width' :biggestRow});
			$j(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$j(this).calcSubWidth();
			//Set Width
			$j(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $j(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $j(this).hide(); 
	  });
	}


	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: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$j("ul#topnav li .sub").css({'opacity':'0'});
	$j("ul#topnav li").hoverIntent(config);



});


/*--------------This is for FANCYBOX--------------*/

	$j(document).ready(function() {

	/* This is basic - uses default settings */
	
	$j("a#single_image").fancybox();
	
	/* Using custom settings */
	
	$j("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$j("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
	$j(".video-clip").click(function() {
	$j.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});
	
});

/*--------------This is for NIVO SLIDER--------------

$j(window).load(function() {
    $j('#slider').nivoSlider({
        effect:'random', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});*/

/*--------------This is for TOOLTIP POPUP--------------*/

$j(document).ready(function() {
$j(".story-tooltip").tooltip({ 
	effect: 'slide',
	slideOffset: 2,
	offset: 	[0, -115]
	});
});

/*--------------This is for CAROUSEL--------------*/



$j(function(){
    $j('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $j('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $j('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
});

/*--------------This is for Alkaline Membership Info--------------*/
	
$j(document).ready(function() {

	$j(".last dt:contains('Sign up For Your Free Alkaline Lifestyle Membership')").append(' <a class="story-tooltip" href="#" class="membership-info"><strong>Hover to learn more</strong></a><div class="tooltip"><h3>Alkaline Lifestyle Benefits</h3><p>Alkaline Lifestyle is <strong>a website dedicated to helping you live the healthiest &amp; happiest life you can</strong>. They offer expert opinions and resources on nutrition, fitness, mind, spirit, the science behind alkalinity, and much more.</p><p>This free 12 month membership will help you:</p><ul><li>Balance pH for healthy alkalinity</li><li>Lose Weight (correctly and healthily)</li><li>Improve energy, stamina, and vitality.</li><li>Reverse signs of aging</li><li>Prevent many chronic degenerative health conditions</li><li>&hellip;and much, much more.</li></ul><p>You owe it your health to take advantage of this wonderful opportunity!</p></div>');

$j(".story-tooltip").tooltip({ 
	effect: 'slide',
	slideOffset: 2,
	offset: 	[0, -115]
	});
});

$j(document).ready(function() {

    $j(".infographic .tooltip-1").hover(function () {
    $j(".tooltip-1 p").toggle("normal");
    });
		
		$j(".infographic .tooltip-2").hover(function () {
    $j(".tooltip-2 p").toggle("normal");
    });
		
		$j(".infographic .tooltip-3").hover(function () {
    $j(".tooltip-3 p").toggle("normal");
    });
		
		$j(".infographic .tooltip-4").hover(function () {
    $j(".tooltip-4 p").toggle("normal");
    });
		
		$j(".infographic .tooltip-5").hover(function () {
    $j(".tooltip-5 p").toggle("normal");
    });
	
		$j(".infographic .tooltip-6").hover(function () {
    $j(".tooltip-6 p").toggle("normal");
    });
	});
