/**
 * Canoe Scripts
 */
 
//masthead loader
jQuery(window).load(function() {
	var mastheadLoader = jQuery('.masthead-gallery-loader').addClass('loaded');
	setTimeout(function() {
		mastheadLoader.remove();
	}, 300);	
});
 
//Dynamic Masthead Height
jQuery(document).ready(function() {
	if (!Modernizr.touch) {
		jQuery(window).load(function() {
			setMastheadHeight();
		});
		jQuery(window).on('resize', function() {
			setMastheadHeight();
		});
		jQuery('.masthead-slider').on('adLayoutSliderReady', function() {
			setMastheadHeight();
		});
	}
});
function setMastheadHeight() {
	var mastheads = jQuery('.masthead-slider');
	var viewportHeight = jQuery(window).height();
	mastheads.each(function() {
		var masthead = jQuery(this);
		//get params
		var viewportPercentage = 25;
		var maxHeight = 360;
		var minHeight = 200;
		
		var mastheadHeight = viewportHeight * (viewportPercentage / 100);
		if (mastheadHeight > maxHeight) {
			mastheadHeight = maxHeight;
		} else if (mastheadHeight < minHeight) {
			mastheadHeight = minHeight;
		}
		//set masthead height
		masthead.height(mastheadHeight);
	});
}
//IE8 Masthead Fixes
jQuery(document).ready(function() {
	if (jQuery('html').hasClass('lt-ie9')) {
		jQuery('.masthead-full-placeholder-container, .masthead-placeholder-container').append('');
		jQuery('.masthead-slider').on('adLayoutSliderInitialized', function() {
			jQuery(this).find('.masthead-slide-image, .masthead-slide-video').append('');;
		});
		jQuery('.masthead-full-slider').on('adLayoutSliderFullInitialized', function() {
			jQuery(this).find('.masthead-full-slide-image, .masthead-slide-video').append('');
		});
	}
});
//Menu element width
jQuery(document).ready(function(){
	jQuery('.ad-layout-tabs-container').each(function(){
		var tabNavs = jQuery(this).find('.nav-tabs li');
		var numtabNavs = tabNavs.length;
		var tabNavsWidth = 100/numtabNavs;
		tabNavs.css('width', tabNavsWidth + '%');
	});
});