(function($){
$.fn.extend({
        ScrollLeft:function(opt,callback){
                //Initialization
                if(!opt) var opt={};
                var _this=this.eq(0).find(".all_items");
                var     lineW=_this.find(".bag_item").width(), //total width
                        line=opt.line?parseInt(opt.line,2):parseInt(this.width()/lineW,2), 
                        speed=opt.speed?parseInt(opt.speed,10):500, 
                        timer=opt.timer?parseInt(opt.timer,10):3000; 
                if(line==0) line=1;
                var leftWidth=0-line*lineW;

                sLeft=function(){
                        _this.animate({
                                marginLeft:leftWidth
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find(".bag_item:first").appendTo(_this);
                                }
								_this.css({marginLeft:0});
                        });
                }
  
                timerID=setInterval("sLeft()",timer);
        } 
})
})(jQuery);

(function($){
$.fn.extend({
        ScrollRight:function(opt,callback){
                //Initialization
               if(!opt) var opt={};
                var _this=this.eq(0).find(".all_items");
                var     lineW=_this.find(".bag_item").width(), //total width
                        line=opt.line?parseInt(opt.line,2):parseInt(this.width()/lineW,2), 
                        speed=opt.speed?parseInt(opt.speed,10):500, 
                        timer=opt.timer?parseInt(opt.timer,10):3000; 
                if(line==0) line=1;
                var rightWidth=0-line*lineW;

                sRight=function(){
                        _this.animate({
                                marginLeft:-rightWidth
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find(".bag_item:last").prependTo(_this);
                                }
								_this.css({marginLeft:0});
                        });
                }
  
                 timerID=setInterval("sRight()",timer);
        } 
		
})
})(jQuery);
