Elevator = Class.create();
Elevator.prototype = {
	
	initialize: function(moveId) {
		this.moveId = $(moveId);
		this.maxSize = 0;
		this.moveSize = 0;
		this.displaySize = 0;
		this.defaultY = 0;
		this.currentY = 0;
		this.nowMoving = false;
		this.param =0; 
	},
	
	moveUp:function() {
		if (!this.checkProperty() || !this.IsEnableMoveUp() || this.nowMoving)
			return false;
		var move = -1 * this.moveSize; 
		new Effect.MoveBy(this.moveId.id,move,0, { 
			duration:0.4 , beforeStartInternal: function() { this.nowMoving = true; }.bind(this), afterFinishInternal: function(effect) { this.nowMoving = false; this.currentY = this.getCurrentPositionY(); }.bind(this)
		});
	},
	
	moveDown:function() {
		if (!this.checkProperty() || !this.IsEnableMoveDown() || this.nowMoving)
			return false;
		new Effect.MoveBy(this.moveId.id,this.moveSize,0, {
			duration:0.4 , beforeStartInternal: function() { this.nowMoving = true; }.bind(this) ,afterFinishInternal: function(effect) { this.nowMoving = false; this.currentY = this.getCurrentPositionY(); }.bind(this)
		});
	},
	
	moveStartup: function() {
		var moveSize = -(this.maxSize - this.displaySize);
		new Effect.MoveBy(this.moveId.id,moveSize,0, {duration:5});
	},
	
	checkProperty:function() {
		if (this.maxSize == 0 || this.moveSize == 0 || this.displaySize == 0) {
			return false;
		} else {
			return true;
		}
	},
	
	IsEnableMoveUp:function() {
		if (this.maxSize <= this.displaySize - (this.currentY)) {
			return false;
		} else {
			return true;
		}
	},
	
	IsEnableMoveDown:function() {
		if (this.currentY >= this.defaultY) {
			return false;
		} else {
			return true;
		}
	},
	
	getCurrentPositionY: function() {
		var y;
		if (typeof this.moveId.currentStyle == 'undefined') {
			y = this.moveId.style.top || getComputedStyle(this.moveId,"").top;
		} else {
			y = this.moveId.style.top || this.moveId.currentStyle.top;
		}
		y = parseInt(y);
		if (typeof y == 'undefined') {
			y = 0;
		}
		return y;
	}

}
