jQuery(document).ready(function($) {
	
	/* Front page slider */
	if ( ! franzJS.sliderDisable ) {
		$('.carousel').carousel({
			interval: franzJS.sliderInterval * 1000
		});
		$('.carousel .slide-title').each(function(){
			charLimit = 17;
			defaultSize = 5.2;
			minSize = 2.5;
			if ($(this).text().length > charLimit) {
				fontSize = (17 / $(this).text().length) * 5.2;
				if (fontSize < minSize ) fontSize = minSize;
				$(this).css('font-size',  fontSize + 'vw');
			}
		});
	}
	
	/* Make the navbar smaller as visitor scrolls down */
	$(window).scroll(function() {
		var height = $(window).scrollTop();
		if ( height > 85 ) $('body').addClass('navbar-pinned');
		else $('body').removeClass('navbar-pinned');
	});
	
	/* Go to parent link of a dropdown menu if clicked when dropdown menu is open */
	$('.dropdown-toggle[href]').click(function(){
		if ($(this).parent().hasClass('open') || $(this).parent().hasClass('dropdown-submenu') ) window.location = $(this).attr('href');
	});	
	
	/* Smooth scroll to comment form */
	$('.comment-form-jump a').click(function(e){
		e.preventDefault();
		$('html, body').animate({scrollTop: $($(this).attr('href')).offset().top - 100}, 1000);
	});
});