jQuery(function($){
	$('nav li').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});
	
	
	
	/*
		Timeline
	*/
(function(){
	var $timeline_header = $('#timeline > header');
	var $timeline_header_list = $timeline_header.children('ul');
	var $timeline_footer = $('#timeline > footer');
	var $timeline_footer_list = $timeline_footer.children('ul');
	var $timeline_years = $timeline_header_list.children().length;
	var $timeline_padding = 0;
	$('#scrollbar .slider').slider().bind('slide',function(evt,ui){
		var $timeline_width = ($timeline_years * 170) - ($timeline_header.width()) + (2 * $timeline_padding);
		var left = ((($timeline_width) / -100) * ui.value);
		$timeline_header_list.stop().css({left: left + 'px'});
		$timeline_footer_list.stop().css({left: left + 'px'});
	});
	$timeline_footer.css({height: $timeline_footer_list.height()});
	var $window = $(window);
	$window.resize(function(evt){
		$timeline_padding = ($window.width() - 961) / 2;
		$timeline_header_list.css({marginLeft: $timeline_padding});
		$timeline_footer_list.css({marginLeft: $timeline_padding});
	}).trigger('resize');
})();	

	/*
		Gallery
	*/
(function(){
	$('#gallery li a img, #videogallery li a img').each(function(){
		var $this = $(this);
		var width = $this.width();
		var height = $this.height();
		if (width < height)
			$this.css({	width: 50,
						height:	height * (50 / width),
						top: (50 - (height * (50 / width))) / 2});
		else
			$this.css({	height: 50,
						width:	width * (50 / height),
						left: (50 - (width * (50 / height))) / 2});
	});
    $("a[rel^='prettyPhoto']").prettyPhoto({
		theme:'facebook',
		overlay_gallery: false,
		social_tools: '',
		slideshow: false
	});
})();
(function(){
	$('form input[type=submit]').each(function(idx,elem){
		$(elem).replaceWith('<a href="#" class="button submit">'+$(elem).val()+'</a>');
	});
	$('form a.button.submit').click(function(){
		$(this).closest('form').submit();
	});
	
})();
	/*
		Searchbox
	*/
(function(){
	$('#input-search').keyup(function(evt){
		if (evt.keyCode == 13) $(this).submit();
	}).click(function(evt){
		var $this = $(this);
		if (evt.pageX - $this.offset().left >= 189 && $this.val() != '' && $this.val() != $this.attr('placeholder'))
		{
			evt.preventDefault();
			evt.stopPropagation();
			$this.blur().submit();
		}
	}).bind('mouseleave',function(){
		$(this).removeClass('submit');
	}).bind('mousemove',function(evt){
		if (evt.pageX - $(this).offset().left >= 189)
			$(this).addClass('submit');
		else
			$(this).removeClass('submit');
	}).bind('submit',function(){
		window.location.href= '/nl/Zoekresultaat.html;q=' + escape($(this).val());
	});
})();

});
