function Tween(elem, valeurs){
	
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
									V A R I B L E S
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	
	this.elem		= elem;
	this.obj_val;
	this.end;
	this.deb;		
	this.temps;
	
	this.ips 	= 30;		
	this.nms	= 1000/this.ips;
	this.interval;
	this.inter;
	this.onComplete = new Function;
	
	this.onPos = new Function;
	this.pos_val = false;
	
	this.dist;
	this.pos = 0; //entre 0 et 1 -> position du mouvement
	this.transition = new Function;
	this.complete_bis = false;
	this.onPosFlag = false;
	
	var debug = false;
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
									Mouvements
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	
	
	this.moveTo = function(to, temps){
		
		this.onPosFlag = true;
		
		this.stopMvt();
		this.inter = 1/(temps/this.nms);
		var okmvt = false;
		var dist = new Object;
		this.deb = this.copy_object(this.obj_val);
		this.end = this.copy_object(to);		
		this.temps = temps;		
		this.pos = 0;
		
		
		 
		var okbis = true;
		for(ii in to){
			if(to[ii] != this.obj_val[ii]){
				okbis = false;
				continue;
			}
		 }
		 if(okbis){
			 if(this.complete_bis){
				this.onComplete();
			}
			this.move(to);
		 }
		
		
		for(ii in this.obj_val){
			if(to[ii]!==false && (to[ii] != this.obj_val[ii] || to[ii] != this.end[ii])){
					okmvt = true;					
					
					if(typeof(to[ii]) == 'array' || typeof(to[ii]) == 'object'){
						
						dist[ii] = new Array();
						this.deb[ii] = this.copy_array(this.obj_val[ii]);
						var i;
						for(i=0; i<this.obj_val[ii].length;i++){
							dist[ii][i] = to[ii][i] - this.obj_val[ii][i];
						}	
									
					}else{
						dist[ii] = to[ii] - this.obj_val[ii];
					}
			}else{
				dist[ii] = false;
			}
		}
		
		if(!okmvt){
			return;
		}
		this.dist = dist;
		
		
		
		var obj = this;
		this.interval = setInterval(function(){obj.mvt()},this.nms,this);
		this.mvt();
		
	}
	
	this.mvt = function(){
			
		  var pos_tmp = this.pos;
		  this.pos += this.inter;	
		  var inc = this.transition(this.pos);
		  if(pos_tmp == this.pos){
			clearInterval(this.interval);
		  }
		 	
		 
		 for(ii in this.obj_val){
			 if(this.dist[ii] !== false){
				 if(typeof(this.obj_val[ii]) == 'array' || typeof(this.obj_val[ii]) == 'object'){
					  for(i=0; i<this.obj_val[ii].length;i++){
						  this.obj_val[ii][i] = Math.round(this.deb[ii][i] + (this.dist[ii][i]*inc));
					  }
				
				  }else{
					  this.obj_val[ii] = parseInt(this.deb[ii]) + parseInt(this.dist[ii]*inc);
				  }
			 }
		  }
		  
		  if(this.pos_val !== false && this.onPosFlag){
			  if(this.pos >=this.pos_val){				 	
			  		this.onPos();
					this.onPosFlag = false;
			  }
		  }
		  
		  if(this.pos >=1){
			  this.fin();
			  
		  }else{
			  this.move();
		  }		  
	  }
	
	
	
	
	this.fin = function(){
		clearInterval(this.interval);
		this.move(this.end);		
		this.obj_val = this.copy_object(this.end);	
		
		
		this.onComplete();
		
	}
	
	this.stopMvt = function(){
		clearInterval(this.interval);
	}
		
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
									F O N C T T I O N S
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	
	this.copy_array = function(var_array){
		var i;
		var ret = new Array();
		for(i=0;i<var_array.length;i++){
			ret[i] = var_array[i];
		}
		return ret;
	}
	
	this.copy_object = function(var_obj){
		var i;
		var ret = new Object;
		for(ii in var_obj){
			if(typeof(var_obj[ii]) == 'array' || typeof(var_obj[ii]) == 'object'){
				ret[ii] = this.copy_array(var_obj[ii]);
			}else{
				ret[ii] = var_obj[ii];
			}
		}
		return ret;
	}
	
	// ---------------------------------------------------   GESTTION DES PARAMETRES
	this.move = function(){
		for(ii in this.obj_val){
			if(this.dist[ii] === 0 || this.dist[ii]){
				if(ii != 'opacity'){
					this.elem.style[ii] = this.getCssVal(ii);
					
				}else{
					this.modAlpha(this.obj_val[ii]);
				}
			}
		}		
	}
	
	this.getCssVal = function(param){
			var val = this.obj_val[param];
			
			if(!isNaN(val)){
				val = Math.floor(val);
			}
			
			switch(param){
				
				case 'height' :
				case 'width' :
				case 'minWidth' :
				case 'top' :
				case 'left' :
				case 'bottom' :
				case 'right' :
				case 'margin' :
				case 'marginTop' :
				case 'marginBottom' :
				case 'marginLeft' :
				case 'marginRight' :
				case 'paddingTop' :
				case 'paddingBottom' :
				case 'paddingLeft' :
				case 'paddingRight' :
				case 'padding' :
				case 'fontSize' :
					if(isNaN(val))return;	
					return val+'px';
					break;
				case 'opacity' :
					return val;
					break;
					
				case 'color' :
				case 'backgroundColor' :
					return this.mod_color(val);
					break;
			}
	}
	
	this.mod_color = function(vals){
		if(vals.length !=3)return;
		var color = vals.join(',');
		return 'rgb('+color+')';
	}
	
	
	
	
	
	this.modAlpha = function(opa){
		
		this.elem.style.visibility = (opa ==0)?'hidden':'visible';
		
		if(document.all && !window.opera){ 
			 //elem.style.filter = "alpha(opacity=" + opa + ");";
			
			this.elem.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=' + (opa) + ')';
			
			if(opa>99){
				this.elem.style.filter='';
			}
		}else{
			opa = Math.round(opa);
			var Val = opa/100;
			if(isNaN(Val))return;
			
		 	this. elem.style.setProperty( "-moz-opacity", Val, "");
		  	this.elem.style.setProperty( "-khtml-opacity", Val, "");
		 	this.elem.style.setProperty( "opacity", Val, "");
		  
		}
		
	}
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
									T R A N S I T I O N S
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	
	this.linear = function(pos){
		return pos;
	}
	
	this.ease = function(pos){
			if(pos >= 1) return 1
			pos =  -(Math.cos(pos*(Math.PI)));
			pos +=1;
			return pos/2;
	}
	this.easeOut = function(pos){
			if(pos >= 1) return 1
			pos =  Math.sin(pos*(Math.PI/2));			
			return pos;
	}
	
	this.easeIn = function(pos){
			if(pos >= 1) return 1
			return pos*pos;
	}
	
	this.transition = this.ease;
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
								I N I T I A L I S A T I O N
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	this.obj_val	= this.copy_object(valeurs);

	this.dist = this.copy_object(valeurs);
	this.move(); // --- bouger le 1er truc
}
