$(function(){
	var $ul = $(".b-slyder ul"),
		$larr = $(".b-slyder .arrow_left"),
		$rarr = $(".b-slyder .arrow_right"),
		$first = $(".b-slyder li:first-child"),
		$last = $(".b-slyder li:last-child"),
		
		crnt = 0,
		count = $(".b-slyder li").length,
		animated = false;
		
	$rarr.click(function(e){
		if (!animated) {
			animated = true;
			if (crnt == count -1) {
				$ul.css({
					left: "0%"
				});
				$last.prependTo($ul);
				$ul.animate({
					left: "-100%"
				}, function(){
					$last.appendTo($ul);
					$ul.css({left: "0%"});
					crnt = 0;
					animated = false;
				})
				
			} else {	
				$ul.animate({
					left: "-=100%"
				}, function(){
					animated = false;
					crnt++;
				});
				
			}
			return false;
		};
	});
	
	$larr.click(function(e){
		if (!animated) {
			animated = true;
			if (crnt == 0) {
				$ul.css({
					left: -(count-1)*100 + "%"
				});
				$first.appendTo($ul);
				$ul.animate({
					left: "+=100%"
				}, function(){
					$first.prependTo($ul);
					$ul.css({left: -(count-1)*100 + "%"});
					crnt = count-1;
					animated = false;
				})
				
			} else {	
				$ul.animate({
					left: "+=100%"
				}, function(){
					animated = false;
					crnt--;
				});
				
			}
			return false;
		};
	});

});

