
(function ($) {
	var notMovingInt = 5000;
	var mouseMoveInt;
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	
	$(document).ready(function(){
		mouseMoveInt = setTimeout(hideAll, notMovingInt);
		$("body").mousemove(function(event) {
			
			if($('#main-wrapper').css('display') == "none")
				showAll();
			clearTimeout(mouseMoveInt);
			mouseMoveInt = setTimeout(hideAll, notMovingInt);
		});
		
		$("#block-search-form").keydown( function() {
			if($('#main-wrapper').css('display') == "none")
				showAll();
			clearTimeout(mouseMoveInt);
			mouseMoveInt = setTimeout(hideAll, notMovingInt);
		});
		
		if(isiPad)
		{
			$('#page-wrapper').click(function() {
				$('body').trigger('mousemove');
			});
		}
	});
	
	function hideAll()
	{
		if($('.node-pageartikel').length == 0 || ($('.node-pageartikel').length == 1 && $('.node-pageartikel').css('display') == 'block'))
		{
			$('#main-wrapper').fadeOut();
			$('#picinfo').fadeOut();
			$('#slideshow_navi').fadeOut();
			$('#social-media').fadeOut();
			$('#slideshow_timer').hide();
			$('#block-search-form').fadeOut();
			$('#showSearch').removeClass('open');
		}
		else
		{
			showAll();
		}
	}
	
	function showAll()
	{
		$('#main-wrapper').fadeIn();
		$('#picinfo').fadeIn();
		$('#slideshow_navi').fadeIn();
		$('#social-media').fadeIn();
		$('#slideshow_timer').show();
	}
})(jQuery);


