Fx.Scrollpage = new Class();
Fx.Scrollpage.prototype = Object.extend(new Fx.Base(), {
	initialize: function(el, options, type, size, step) {
		this.el = $(el);
		this.setOptions(options);
		this.now = 0;
		this.type = type;
		this.offsetHeight = this.el.offsetHeight;
		this.offsetWidth = this.el.offsetWidth;
		switch(this.type){
			case 'horizontal':
				this.height = size;
				this.vstep = step;
				break;
			case 'vertical':
				this.width = size;
				this.hstep = step;
				break;
		}
	},
	increase: function() {
		switch(this.type){ 
			case 'horizontal':
				this.el.style.top = this.now + "px";
				break;
			case 'vertical':
				this.el.style.left = this.now + "px";
				break;
		}
	},
	scroll: function(direction){
		this.clearTimer();
		switch(direction){
			case 'down':
				if(this.now == 0 || (this.now - this.height) > (0-this.offsetHeight)){
					if(this.now - this.vstep < 0-this.offsetHeight){
						this.custom(this.now, 0-this.offsetHeight);
					} else {
						this.custom(this.now, this.now - this.vstep);
					}
				}
				break;
			case 'up':
				if(this.now != 0 || (this.now + this.height) < 0){
					if(this.now + this.height > 0){
						this.custom(this.now, 0);
					} else {
						this.custom(this.now, this.now + this.vstep);
					}
				}
				break;
			case 'top':
				if(this.now != 0 || (this.now + this.height) < 0){
					this.custom(this.now, 0);
				}
				break;

			case 'right':
				if(this.now == 0 || (this.now - this.width) > (0-this.offsetWidth)){
					if(this.now - this.hstep < 0-this.offsetWidth){
						this.custom(this.now, 0-this.offsetWidth);
					} else {
						this.custom(this.now, this.now - this.hstep);
					}
				}
				break;

			case 'left':
				if(this.now != 0 || (this.now + this.width) < 0){
					if(this.now + this.width > 0){
						this.custom(this.now, 0);
					} else {
						this.custom(this.now, this.now + this.hstep);
					}
				}
				break;
		}
	}
});
