// Transition class
function Transition() {
}

Transition.prototype.setObject = function(obj){
  this.object = obj;
  this.startLeft = this.endLeft = parseInt(this.object.style.left);
  this.startTop = this.endTop = parseInt(this.object.style.top);
  this.startWidth = this.endWidth = parseInt(this.object.style.width);
  this.startHeight = this.endHeight = parseInt(this.object.style.height);
};

Transition.prototype.setStartPosition = function(left, top) {
  this.startLeft = left;
  this.startTop = top;
}

Transition.prototype.setEndPosition = function(left, top) {
  this.endLeft = left;
  this.endTop = top;
}

Transition.prototype.setStartSize = function(width, height) {
  this.startWidth = width;
  this.startHeight = height;
}

Transition.prototype.setEndSize = function(width, height) {
  this.endWidth = width;
  this.endHeight = height;
}

Transition.prototype.setSteps = function(steps) {
  this.steps = steps;
}

Transition.prototype.move = function() {
  this.current_step = 0;
  var self = this;
  window.setTimeout(function(){self.nextmove();},20);
}

Transition.prototype.nextmove = function() {
  this.current_step = this.current_step+1;
  this.object.style.left = this.startLeft + (this.endLeft - this.startLeft) *  this.current_step / this.steps ;
  this.object.style.top = this.startTop + (this.endTop - this.startTop) *  this.current_step / this.steps ;
  this.object.style.width = this.startWidth + (this.endWidth - this.startWidth) *  this.current_step / this.steps ;
  this.object.style.height = this.startHeight + (this.endHeight - this.startHeight) *  this.current_step / this.steps ;
  if(this.current_step < this.steps) {
	  var self = this;
	  window.setTimeout(function(){self.nextmove();},20);
	} else {
	 this.done();
  }
}

Transition.prototype.done = function(){}

 