
var DivContentRoller = Class.create({
	initialize: function(e, direction) {
		this.element = e;
		this.TotalHeight = 0;
		this._current = 0;
		this.height = e.getHeight();
		//this.eachHeight = e.;
		this.TotalElement = 10;
		this.TimeForScroll = 100;
		this.TimeForDelay = 20;// = 20 x 100
		this.horizontal = (direction == 'h');
		this.vertical = (direction == 'v');
		//this.direction = direction;
		this._intarvalID = null;
		var h = 0;
		var count = 0;
		this.element.childElements().each(function(e){h+=e.getHeight();count+=1;});
		this.TotalHeight = h - this.height;
		this.startScroll();
	},
	startScroll: function() {
		this.stopScroll();
			this._intarvalID = setInterval(function(){
											if (this.element.title=='out') {
											if (this.element.scrollTop%this.element.getHeight()==0) {
												if (this._current>=this.TimeForDelay) {
													this._current=0;
													this.element.scrollTop+=1;
												} else {
													this._current+=1;
												}
											} else {
												this.element.scrollTop+=1;
												//this._current=0;
											}
											//alert(this._current);
											if (this.element.scrollTop>=this.TotalHeight)this.element.scrollTop=0;
											}
										}.bind(this), this.TimeForScroll);
	},
	stopScroll: function() {
		if (this._intarvalID!=null) clearInterval(this._intarvalID);
	}
});
