$(document).ready(function () {
	if ($('.browse .wrap img').size() > 1) {
		$('.browse .wrap img').hide();
		var firstimg = $('.wrap img').first();
		$(firstimg).show();
		var timer = setInterval( function () {
			$(firstimg).fadeOut(500);
			if ($(firstimg).next().size()) {
				firstimg = $(firstimg).next();
			} else {
				firstimg = $('.wrap img').first();
			}
			$(firstimg).fadeIn(500);

		}, 3000);
	}
	if ($('#carousel img').size() > 1) {
		if ($('#carousel').carouFredSel({
			responsive: true,
			circular: false,
			auto: false,
			items: {
				visible: 1,
				width: 482,
				height: 297
			},
			scroll: {
				fx: 'directscroll'
			}
		}));
		$('#thumbs a').click(function() {
			$('#carousel').trigger('slideTo', '#'+this.href.split('#').pop());
			$('#thumbs a').removeClass('selected');
			$(this).addClass('selected');
			return false;
		});
	}

	if ($('aside .rotate').length && $('aside .rotate .deal').length > 3) {
		$('aside .rotate').carouFredSel({
			items: 3,
			direction: 'up',
			scroll: {
				items: 1,
				duration: 400,
				pauseOnHover: true,
				mousewheel: true
			},
			next: {
				duration: 3000
			}
		});
	}
	if ($('.main-slideshow').length) {
		$('.main-slideshow .wrapper').carouFredSel({
			items: 1,
			direction: 'left',
			scroll: {
				items: 1,
				duration: 600,
				pauseOnHover: true,
				mousewheel: true,
				fx: 'crossfade'
			},
			next: {
				duration: 3000
			}
		});
	}

});
