$(document).ready(function() {	

$('#tabMenu > li').click(function(){
	if (!$(this).hasClass('selected')) {    
		$('#tabMenu > li').removeClass('selected');
		$(this).addClass('selected');
		$('.boxBody div').slideUp('1500');
		$('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
	}

	}).mouseover(function() {  
		$(this).addClass('mouseover');
		$(this).removeClass('mouseout');   

	}).mouseout(function() { 
		$(this).addClass('mouseout');
		$(this).removeClass('mouseover');    

	});	


$("#navcat").height(0);
$("#navcat ul").css({marginLeft: 288});

$boxes = $(".bx");
n = $boxes.size();
w = 144*n;
$("#navcat ul").width(w);
		
	if (n<3) { n = 2 };

$('#debugger').append('n => ');
$('#debugger').append(n);

	box = n-1;
	scrollCat(box);
		
	function scrollCat(box) {
		var h1 = $boxes.eq(box).outerHeight(true);
		var h2 = $boxes.eq(box-1).outerHeight(true);
		var h = Math.max(h1, h2);
				
		$boxes.removeClass('brd');

		$("#navcat").animate({
			height: h
		}, 800, 'easeInOutBack');
		
		$("#navcat ul").animate({
			marginLeft: -144*(box-1)
		}, 800, 'easeInOutBack');
		
		$boxes.eq(box).addClass('brd');
		
$('#debugger').append(', b=> ');
$('#debugger').append(box);

		if (box > 1) {
			$("#prev").bind("click", prevBut);
		} else {
			$("#prev").unbind("click", prevBut);
		};
			
		if (box < n - 1) {
			$("#next").bind("click", nextBut);
		} else {
			$("#next").unbind("click", nextBut);
		};

	};
	
	function prevBut() {
		box -= 1;
		scrollCat(box);
	};
	
	function nextBut() {
		box += 1;
		scrollCat(box);
	};
	
});

$(document).ready(function() {
$("a[rel=gallery]").fancybox();
		
$("a[rel=zoom]").fancybox({
	'transitionIn': 'elastic',
	'transitionOut': 'elastic',
	'speedIn': 600, 
	'speedOut': 200, 
	'overlayShow':	false
	});
});

