
jQuery.noConflict();

Scrollable = function (container, child){
  this.container = container;
  this.child = child;
  this.container_height = container.height();
  this.child_height = child.height();
//  this.div_pos = 0;
  this.div_pos = -this.container_height
  this.scroll_increment = 1;
  this.scroll_delay = 20;

  this.container.css('overflow','hidden');
  this.container.css('position','relative');
  this.child.css('position','relative');

//    this.container.css('border','1px solid red');
//    this.container.height('200px');

  this.StartScroller();

  var Obj = this;

  this.container.hover(  function() { Obj.StopScroller(); },
                         function() { Obj.StartScroller(); } );
}

Scrollable.prototype.ChildScroller = function () {
//    this.div_pos = ( this.div_pos + this.scroll_increment ) % this.container_height;
  this.div_pos = ( this.div_pos + this.scroll_increment );
//  if (this.div_pos >= this.container_height) {
  if (this.div_pos >= this.child_height) {
//    this.div_pos = 0;
  this.div_pos = -this.container_height
    this.child.fadeIn("slow");
  }
  this.child.css('top',-this.div_pos);
}

Scrollable.prototype.StopScroller = function () {
  clearInterval(this.scroll_interval);
}

Scrollable.prototype.StartScroller = function () {
  var Obj = this;
  this.scroll_interval = setInterval(function() {Obj.ChildScroller();},this.scroll_delay); //time in milliseconds
}

jQuery(document).ready(function(){

  // Do something with jQuery
  jQuery(".scrollable").each(function(i){
    var O = new Scrollable(jQuery(this),jQuery(this).children());
  });
});



