//Font replace
Cufon.replace('h1', {
	hover: true,
	textShadow: '#154e65 1px 1px'
});
Cufon.replace('#content-page h1', {
	hover: true
});
Cufon.replace('#intro h1', {
	hover: true
});
Cufon.replace('h2', {
	hover: true
});
Cufon.replace('h3', {
	hover: true
});
Cufon.replace('#sidepanel h3', {
	hover: true,
	textShadow: '#154e65 1px 1px'
});
Cufon.replace('#menu li a', {
	hover: true
});
Cufon.replace('.font-replace', {
	hover: true
});
Cufon.replace('.linkcatname', {
	hover: true
});

//Check windows size for menu position
function checkwindowsize() { 

	var menuheight = $("#menu-container").height() + 30;
	var windowheight = $(window).height();
	var windowwidth = $(window).width();
	
	if((windowheight < menuheight) || (windowwidth < 960)) { 
		$("#menu-container").css("position", "absolute");
	}
	else {
		$("#menu-container").css("position", "fixed");
	}
}
$(window).resize(function() {
  checkwindowsize();
});


$(document).ready(function() {
	
	
	
	//Check window size 
	checkwindowsize();
	
	//Tooltips
	$(".tooltip").tipTip({delay: 100});
	$(".tooltipup").tipTip({delay: 100, defaultPosition: "top"});

	
	//Fancybox 
	$(".youtube-box").fancybox({
					'width'				: 746,
					'height'			: 413,
					'autoScale'			: false,
					'centerOnScroll'	: true,
					'overlayColor'		: '#000000',
					'overlayOpacity'	: 0.9,
					'padding'			: 0,
					'titleShow'			: false,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'scrolling'			: 'no',
					'onStart'			: function() { 
						$('#content embed').addClass('hide');
						$('#content object').addClass('hide');
						$('#content iframe').addClass('hide');
					},
					'onClosed'			: function() { 
						$('#content embed').removeClass('hide');
						$('#content object').removeClass('hide');
						$('#content iframe').removeClass('hide');
					}
	});
	$(".fancybox").fancybox({
					'autoScale'			: true,
					'centerOnScroll'	: true,
					'overlayColor'		: '#000000',
					'overlayOpacity'	: 0.9,
					'padding'			: 10,
					'titleShow'			: false,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'scrolling'			: 'no',
					'onStart'			: function() { 
						$('#content embed').addClass('hide');
						$('#content object').addClass('hide');
					},
					'onClosed'			: function() { 
						$('#content embed').removeClass('hide');
						$('#content object').removeClass('hide');
					}
	});
	
	//Archive panel slide
	var sidepanel = 0;
	$('#archief').click(function() {
		if(sidepanel == 0) { 
			$("#sidepanel").animate({"marginRight": "+=246px"}, 400);
			sidepanel = 1;
		} else {
			$("#sidepanel").animate({"marginRight": "-=246px"}, 400);
			sidepanel = 0;
		}
	});
	
	//Archive month selector
	var selectmonth = 0;
	$('.month-archive-button').click(function (e) {
		e.preventDefault();
		$('ul#month-archive').slideToggle('medium', function() {
			if(selectmonth == 1) { 	 
				$('.month-archive-button').css("backgroundPosition", "0 0");
				selectmonth = 0;
			} else {
				selectmonth = 1;
			}
		});
		
		if(selectmonth == 0) { 	 
			$(this).css("backgroundPosition", "0 -35px");
		}
	
	});
	
	//Scroll to top
	
	// hide #back-top first
	$("#back-top").hide();
	
	// fade in #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});
 
		// scroll body to 0px on click
		$('#back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});
	
});
