(function($) {
	$.fn.islider = function(s) {
		var s = $.extend({
			delay: 250
		}, s);
		
		
		var c = {
			it: null,
			slide: null,
			count: 0,
			current:0,
			left:0,
			width:244
		};

		return this.each(function(i, e) {
			c.it = $(this);
			c.slide = c.it.find('.slide');
			
			c.count = c.slide.find('.item-inner').size();
			c.slide.width(c.width * c.count);
			c.slide.css({left:c.left});
			
			c.it.find('.arr-r').click(_next);
			c.it.find('.arr-l').click(_prev);
			
			if (c.count == 3){
				c.it.find('.arr-r').remove();
				c.it.find('.arr-l').remove();
			}
			
			_after_move();
		});
		
		function _next(){
			if (c.current == c.count-3) return false;
			c.current++;
			c.left -= c.width;
			c.slide.animate({left:c.left}, s.delay);
			
			_after_move();
			
			return false;
		}
		
		function _prev(){
			if (c.current == 0) return false;
			c.current--;
			c.left += c.width;
			c.slide.animate({left:c.left}, s.delay);
			
			_after_move();
			
			return false;
		}
		
		function _after_move(){
			if (c.current == c.count-3) c.it.find('.arr-r').fadeOut(100); else c.it.find('.arr-r').fadeIn(100);
			if (c.current == 0) c.it.find('.arr-l').fadeOut(100); else c.it.find('.arr-l').fadeIn(100);
		}
	}
})(jQuery);

