jQuery.fn.gallery = function(options){

    var self = this;
   
    var boucle = function(){
	var parent_left = self.parent().offset().left;
	if((self.children().last().offset().left + self.children().last().width()) < parent_left){   
 	    //jQuery(document).stopTime();  
	    self.stop(true);
            var parent_right = parseInt(self.parent().width());      
	    self.css('left', parent_right+'px');
	    
        }
    }

    var animation = function(){
      jQuery(document).everyTime(800, function(){
	  self.animate({'left': '-=50px'}, 800, 'linear', function(){	  
	    boucle();   
	  });
      });
    }
    
    var init = function(){
	animation();
    }

    init();

}

