function MorphineAnimation(element, styleToModify) {
	this.compteur = 0 ;
	this.vitesse = 0 ;
	this.timerAnim = null ;
	this.func = null ;
	this.element = element ;
	this.unit = "px" ;
	this.pos = 0 ;
	this.styleToModify = styleToModify ;
	this.fps = 50 ;
}

MorphineAnimation.prototype.start = function(pos1, pos2, vitesse) {
	this.pos = this.pos1 = pos1 ;
	this.pos2 = pos2 ;
	this.vitesse = vitesse ;
	this.set(this.pos1) ;
	this.jouer() ;
}
MorphineAnimation.prototype.stop = function() {
	this.set(this.pos2) ;
	//alert(this.pos2) ;
	if (this.timerAnim!=null) window.clearTimeout(this.timerAnim) ;
	this.timerAnim = null ;
}
MorphineAnimation.prototype.set = function(pos) {
	this.pos = pos ;
	this.element.style[this.styleToModify] = this.pos+this.unit ;
	if (this.pos==0) this.element.style.display = "none" ;
	else this.element.style.display = "block" ;
}

/*
MorphineAnimation.prototype.setFunction = function(func) {
	this.func = func ;
}
*/
MorphineAnimation.prototype.jouer = function() {
	//if (morphine_animation.func) morphine_animation.func() ;
	this.deplacement() ;
	if (this.vitesse>0 && this.pos>=this.pos2) this.stop() ;
	else if (this.vitesse<0 && this.pos<=this.pos2) this.stop() ;
	else this.timerAnim = window.setTimeout(this.jouer.bind(this), Math.round(1000/this.fps)) ;
}

MorphineAnimation.prototype.deplacement = function() {
	this.pos += this.vitesse ;
	this.set(this.pos) ;
}




