function layoutResize() {
	var page = document.getElementById("page");
	page.style.width = (document.body.clientWidth < 992) ? "990px" : "auto";
}

jQuery(document).ready(function() {

if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) {
  layoutResize();
  jQuery(window).resize(function(){layoutResize();});
}

jQuery(function($) {
	$("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
});

jQuery('#leftside .va-bottom, #rightside .va-bottom').vAlign('bottom');

if (jQuery('#leftcol').height() > jQuery('#center-inner').height()) jQuery('#center-inner').height(jQuery('#leftcol').height());
if (jQuery('#rightcol-inner').height() > jQuery('#center-inner').height()) jQuery('#center-inner').height(jQuery('#rightcol-inner').height());



/* main-picture */
/*$('#main-slider').hide();*/

if($('#main-slider').is('.with-picture')){
	setTimeout ( function() {$('#main-picture').fadeOut(500)}, 2000 );
	setTimeout ( function() {$('#main-slider').fadeIn(1000)}, 2500 );
}
else {
	setTimeout ( function() {$('#main-slider').fadeIn(1000)}, 0 );
}
/* /main-picture */

/* frontpage slider */

var $group = $('#main-slider .books .group');
var total_size =  $('#main-slider .books .group a').length;
var $group_width = total_size*103;
$group.css({width: $group_width});

$('.book-infos .book-info').hide();
$('.group a').mouseleave(function (){
	$('.book-infos .book-info').hide();
});
$('.group a').mouseenter(function (){
	var this_class = $(this).parent().attr("class");
	$('.book-infos .' + this_class).fadeIn();
});
$('.slider').mouseleave(function (){
	$(this).removeClass('hovered');
});
$('.slider').mouseenter(function (){
	$(this).addClass('hovered');
});

var left = 0;
$('.nav-pager .prev').click(function (){
	if((left + 103*5) > 0){
		left = 0;
	}
	else {
		left += 103*5;
	}
	$group.animate({left: left});
});
$('.nav-pager .next').click(function (){
	if((left - 103*5*2) < ((-1)*$group_width)){
		left = (-1)*$group_width + 103*5;
	}
	else {
		left += -103*5;
	}
	$group.animate({left: left});
});

setInterval(slide, 2000);

function slide() {
	if($('.slider').hasClass('hovered')){
		left = left;
	}
	else {
		if(left <= ((-1)*$group_width + 103*5)){
			left = 0;
		}
		else {
			left += -103;
		}
	}
	$group.animate({left: left});
}
/* /frontpage slider */

});

