$(document).ready(function(){

	/**
	 * set hover/focus status on book covers + language switch
	 */

	$('a.cover', '#books, #language-switch')
		.bind({
			'mouseover focus': function() {
				$(this).closest('li').addClass('focus');
			},
			'mouseout blur': function() {
				$(this).closest('li').removeClass('focus');
			}
		});

	/**
	 * set hover/focus status on postit-new
	 */

	$('area', '.postit-new')
		.bind({
			'mouseover focus': function() {
				$(this).closest('.postit-new').addClass('focus');
			},
			'mouseout blur': function() {
				$(this).closest('.postit-new').removeClass('focus');
			}
		});


	/**
	 * enable swipe paging on touch devices
	 * jquery.touchswipe.js
	 */

	$('.swipe-l', '#content').swipe({
			swipeRight: function() {
				$('#paging-previous').click();
			},			
			swipeDown: function() {
				var target = $('#chapter-previous');
				if (target.length) {
					window.location.href = target.attr('href');
				}
			},
			threshold: 150,
			triggerOnTouchEnd: true,
	});
/*
	$('.img-l', '#content').swipe({
			swipeDown: function() {
				var target = $('#chapter-previous');
				if (target.length) {
					window.location.href = target.attr('href');
				}
			},
			threshold: 150,
			triggerOnTouchEnd: true,
	});
*/

	$('.swipe-r', '#content').swipe({
			swipeLeft: function() {
				$('#paging-next').click();
			},
			swipeDown: function() {
				var target = $('#chapter-next');
				if (target.length) {
					window.location.href = target.attr('href');
				}
			},
			threshold: 150,
			triggerOnTouchEnd: true,
	});
/*
	$('.img-r', '#content').swipe({
			swipeDown: function() {
				var target = $('#chapter-next');
				if (target.length) {
					window.location.href = target.attr('href');
				}
			},
			threshold: 150,
			triggerOnTouchEnd: true,
	});
*/

});
