
  // requires mootools

  var LC_slider = function () {

    this.__init__();

  }; // end LC_slider()

  LC_slider.prototype = {

    __init__: function () {

      this.width          = 50; // in pixels
      this.height         = 50; // in pixels

      this.tiles          = []; // DOM elements
      this.current_tile   = 0;
      this.tweening       = false;

      this.container      = null; // DOM element
      this.tile_container = null; // private DOM element

    }, // end __init__()

    add_tile: function (element_or_html) {

      if (typeof(element_or_html) == "string") {

        element           = document.createElement("DIV");
        element.innerHTML = element_or_html;
        element_or_html   = element;

      } // end if

      element_or_html.style.position = "absolute";
      element_or_html.style.top      = "0px";
      element_or_html.style.left     = (this.width * (this.tiles.length)) + "px";

      this.tiles.push(element_or_html);

    }, // end add_tile()

    back: function () {

      if (this.current_tile > 0) {

        this.current_tile--;

        return this.go_to(this.current_tile);

      } // end if

    }, // end back()

    forward: function () {

      if (this.current_tile < (this.tiles.length - 1)) {

        this.current_tile++;

        return this.go_to(this.current_tile);

      } // end if

    }, // end forward()

    go_to: function (index) {

      if (!this.tweening && this.container && $(this.container)) {

        if (index != this.current_tile) {

          this.current_tile = index;

        } // end if

        this.tweening = true;

        var tween = new Fx.Tween($(this.tile_container), {"property" : "left"});

        tween.addEvent("complete", function () {

          this.tweening = false;

        }.bind(this));

        return tween.start(((this.current_tile * this.width) * -1));

      } // end if

    }, // end go_to()

    render: function () {

      this.tile_container                = document.createElement("DIV");
      this.tile_container.style.position = "relative";
      this.tile_container.style.left     = "0px";

      for (var i = 0; i < this.tiles.length; i++) {

        this.tile_container.appendChild(this.tiles[i]);

      } // end for

      if ($(this.container.childNodes)) {

        $(this.container.childNodes).each(function (el) {

          el.destroy();

        });
  
      } // end if

      this.container.appendChild(this.tile_container);

    }, // end render()

    set_container: function (element) {

      if (element && $(element)) {

        this.container                = element;
        this.container.style.overlay  = "hidden";
        this.container.style.position = "relative";

      } // end if

    } // end set_container()

  }; // end class LC_slider

