
// When the DOM is ready
$('document').ready(function(){

	/* -- Menu width -- */
	var $menuWidth = 10;
	$('#menu ul').children().each(function() {
		$menuWidth += $(this).outerWidth();
	});
	//$('#menu').css('width', $menuWidth + 'px');
	
	/* -- Fancybox -- */

	// Set Fancybox defaults
	$.fn.fancybox.defaults.overlayColor = '#000';
	$.fn.fancybox.defaults.overlayOpacity = 0.7;
	$.fn.fancybox.defaults.hideOnContentClick = false;
	$.fn.fancybox.defaults.padding = 0;
	$.fn.fancybox.defaults.titlePosition = "inside";
	$.fn.fancybox.defaults.centerOnScroll = true;
	
	// Activate Fancybox links
	$('a.fancybox').fancybox();
	
	// Active input-hints (search-boxes)
	$('#search-top, #search-footer').inputHint();
	// Hide labels
	$('.search-label').hide();
	
	/* -- Thumbnails -- */

	// Fade in thumbnail images
	$('.tile a, .fancybox, .thumbnail').children('img').FadeInImageOnLoad();
	
	// Hover on thumb:
	$('a.thumb').hoverIntent(function() {
		$('#thumb-hover').stop().remove();
		$newElement = $('<div id="thumb-hover">Klik om te vergroten</div>');
		$newElement.hide();
		$(this).append($newElement);
		$newElement.fadeIn('fast');
	}, function() {
		$('#thumb-hover').remove();
	});
	
	/* -- Tables -- */
	$('.reading table tr:odd td').css('background-color', '#f8f4ee');
});

/**
 * Toggle a html-element
 * 
 * This function will show or hide (animated) a element
 *
 * @param element jQuery element
 * @param bool TRUE to show, FALSE to hide
 * @return void
 */
function toggleElement(element, displayFlag, speed) {
	if (!$(element).is(':animated')) {
		(displayFlag) ? $(element).stop().slideDown(speed) : $(element).stop().slideUp(speed);
	}
}
