
JSTween = function(nm,id)
{	
	this.isActive=false
	this.myName=nm
	this.speed=8
	this.myID = id;
	this.myResizeInterval;
	this.myMoveInterval;
	this.Path = document.getElementById(this.myID);

}

JSTween.prototype._resize = function(nH,nW)
{
	var newH = nH;
	var tmpH = parseInt(this.Path.style.height) - ((parseInt(this.Path.style.height)-newH)/this.speed)

	var newW = nW;
	var tmpW = parseInt(this.Path.style.width) - ((parseInt(this.Path.style.width)-newW)/this.speed)
	if ( (Math.abs(tmpH-newH)<4)  && (Math.abs(tmpW-newW)<4) ){
		this.Path.style.height=newH + "px";
		//this.Path.style.width=newW + "px";
		clearInterval(this.myResizeInterval);

	}
	this.Path.style.height= Math.round(tmpH) + "px"
	this.Path.style.width= Math.round(tmpW) + "px"
}

JSTween.prototype.Resize = function(nH,nW)
{
	clearInterval(this.myResizeInterval);
	this.myResizeInterval = setInterval(this.myName+"._resize("+nH+","+nW+")",10);
}

JSTween.prototype.Move = function(nT,nL)
{
	clearInterval(this.myMoveInterval);
	this.myMoveInterval = setInterval(this.myName+"._move("+nT+","+nL+")",10);
}



JSTween.prototype._move = function(nT,nL)
{
	
	var newT = nT;
	var tmpT = parseInt(this.Path.style.top) - ((parseInt(this.Path.style.top)-newT)/this.speed)

	var newL = nL;
	var tmpL = parseInt(this.Path.style.left) - ((parseInt(this.Path.style.left)-newL)/this.speed)

	

	this.Path.style.top=(tmpT>parseInt(this.Path.style.top))? Math.ceil(tmpT) + "px" :  Math.floor(tmpT) + "px" 
	this.Path.style.left=(tmpL>parseInt(this.Path.style.left))? Math.ceil(tmpL) + "px" :  Math.floor(tmpL) + "px" 

	if ( (Math.abs(tmpT-newT)<1)  && (Math.abs(tmpL-newL)<1) ){
		this.Path.style.top=newT + "px";
		this.Path.style.left=newL + "px";
		clearInterval(this.myMoveInterval);
		
	}
}


