  Carousel = {

    register : function (container, itemsShown, itemsCount, itemWidth, jumpStep) {
      var l = document.getElementById (container + '_move_left');
      var r = document.getElementById (container + '_move_right');
      var w = document.getElementById (container + '_items_wrapper');
      jumpStep = jumpStep || 1

      var isRunning = false;
      var dx, to;

      var z = function() {
        w.scrollLeft += dx;
        if (w.scrollLeft == to) {
          isRunning = false;
          return;
        }
        setTimeout (z, 1);
      }

      l.onclick = function() {
        if (isRunning) return;
        if (!(w.scrollLeft > 0)) {
        	w.scrollLeft = ((itemsCount - itemsShown) * itemWidth);
        }
          isRunning = true;
          dx = -jumpStep;
          to = w.scrollLeft - itemWidth;
          z();
        
      }
      r.onclick = function() {
        if (isRunning) return;
        if (!(w.scrollLeft < (itemsCount - itemsShown) * itemWidth)) {
        	w.scrollLeft = 0;
        }
          isRunning = true;
          dx = +jumpStep;
          to = w.scrollLeft + itemWidth;
          z();
        
      }
      return function() {
		return parseInt (w.scrollLeft / itemWidth);
      }
    }
  }

