$(function(){
	var time = 5;
	$(".action .close").click(function(){
		$(".action").animate({opacity:0}, 500, function(){
			$(this).remove();
		});
		return false;
	});
	$("tr.odd > td:last-child").addClass("last-child");
	var block = 5;
	var intval;
	function slide(){
		if(block == 0){ block = 5; }
		$(".bg"+block).fadeOut(750, function(){
			var bg = $(this);
			$(this).remove();
			$(".sh-preview .inners").prepend(bg.css({display:"block"}));
		});
		block--;
	}
	
	$("img.to-left").click(function(){
		clearInterval(intval);
		var firstEl = $(".sh-preview .inners .inner:first-child");
		$(".sh-preview .inners .inner:first-child").remove();
		$(".sh-preview .inners").append(firstEl.css({display:"none"}));
		firstEl.fadeIn(750);
		block++;
		intval = setInterval(slide, time*1000);
	});
	$("img.to-right").click(function(){
		clearInterval(intval);
		slide();
		intval = setInterval(slide, time*1000);
	});
	function intval(){
		intval = setInterval(slide, time*1000);
	}
	intval();
});