$(document).ready(
	function() {
		$(".related img")
			.css({ opacity: .5})
			.hover(
				function() {
					$(this).stop().animate({ opacity: 1}, { duration: 100});
				},
				function() {
					$(this).stop().animate({ opacity: .5}, { duration: 1000, easing: 'easeInExpo'});
				}
			);
		$("#thumb-archive img")
			.css({ opacity: .5})
			.hover(
				function() {
					$(this).stop().animate({ opacity: 1}, { duration: 100});
				},
				function() {
					$(this).stop().animate({ opacity: .5}, { duration: 1000, easing: 'easeInExpo'});
				}
			);
		initKeyNavigation();
		$("#foto-wrapper").hover(
			function() {
				$(this).find('a').css({ display: 'block' })
			},
			function() {
				$(this).find('a').css({ display: 'none' })
			}
		);
	}
);

var inputActive = false;
function initKeyNavigation() {
	$("input, textarea").focus( function() { inputActive = true } );
	$("input, textarea").blur( function() { inputActive = false } );
	if($('a.next').get(0) || $('a.prev').get(0)) {
		$(window).keyup( function(event) {
			if(event.keyCode == 37 && !event.altKey && $('a.prev').get(0) && !inputActive) {
				location.href = $('a.prev').attr('href');
			}
			if(event.keyCode == 39 && !event.altKey && $('a.next').get(0) && !inputActive) {
				location.href = $('a.next').attr('href');
			}
		});
	}
}
