$(function() {
	$('.thumb a').mouseenter(function() {
		$(this).children('.hover').fadeIn(250);
	}).mouseleave(function(){
		$(this).children('.hover').fadeOut(250);
    });
	$('.imgbox').mouseenter(function() {
		$(this).children('.next').fadeIn(250);
		$(this).children('.prev').fadeIn(250);
		$(this).children('.zoom').fadeIn(250);
	}).mouseleave(function(){
		$(this).children('.next').fadeOut(250);
		$(this).children('.prev').fadeOut(250);
		$(this).children('.zoom').fadeOut(250);
    });
	
	$('.zoom').click(function() {
		$('.imgbox #carousel li[rel=itemvisible] a').triggerHandler('click');
		return false;
	});

	function mycarousel_initCallback(carousel)
	{
		$('.imgbox .next').bind('click', function() {
			carousel.next();
			return false;
		});

		$('.imgbox .prev').bind('click', function() {
			carousel.prev();
			return false;
		});

		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	
	function itemvisible(first, object) {
		object.setAttribute("rel", "itemvisible");
	}

	function itemhidden(first, object) {
		object.setAttribute("rel", "");
	}

	jQuery(document).ready(function() {
		jQuery('#carousel').jcarousel({
			scroll: 1,
			auto: 5,
			wrap: 'both',
			initCallback: mycarousel_initCallback,
			buttonNextHTML: null,
			buttonPrevHTML: null,
			itemVisibleInCallback: itemvisible,
			itemVisibleOutCallback: itemhidden
		});
	});
	
	$('#navi li').mouseenter(function() {
		$(this).children('.hover').clearQueue();
		$(this).children('.hover').animate({'top': '0px'}, 250);
	}).mouseleave(function() {
		$(this).children('.hover').clearQueue();
		$(this).children('.hover').animate({'top': '-49px'}, 250);
	});
	
});
