function UIResizer(element,steps)
{
	var _RESIZE_INTERVAL = 25;
	var _INTERVAL_ID = null;
	var _element = element;
	_element.resizer = this;
	var _width = null;
	var _cWidth = null;
	var _cHeight = null;
	var _height = null;
	var _steps = steps;
	var _widthStepSize = null;
	var _heightStepSize = null;
	var queue = new Array();
	var onReady = null;
	var sleepTime = 0;
	
	this.resize = function(width,height,sleep,onready){
		resize(width,height,sleep,onready);
	}
	
	function resize(width,height,sleep,onready) {
		if (!isBusy()){
			_width = width;
			_height = height;
			_cWidth = parseInt(_element.style.width);
			_cHeight = parseInt(_element.style.height);
			_widthStepSize = (_width - _cWidth) / _steps;
			_heightStepSize = (height - _cHeight) / _steps;
			onReady = onready;
			sleepTime = (sleep==null?0:sleep);
			_INTERVAL_ID = setInterval(function(){tickResize();},_RESIZE_INTERVAL);
		}
		else {
			queue[queue.length] = new Array(width,height,sleep,onready);
		}	
	}
	
	function next()
	{
		if (queue[0]){
			resize(queue[0][0],queue[0][1],queue[0][2],queue[0][3]);
			queue = queue.slice(1,queue.length);
		}
	}
	
	function isBusy()
	{
		return (_INTERVAL_ID==null?false:true);	
	}
	this.isBusy = isBusy;
	
	function tickResize()
	{
		var cw = parseInt(_element.style.width);
		var ch = parseInt(_element.style.height);
		//var mL = parseInt(_element.style.marginLeft);
		//var mT = parseInt(_element.style.marginTop);
	
		if (cw < _width){
			_element.style.width = (cw+_widthStepSize<_width?cw+_widthStepSize:_width) + 'px';
			//_element.style.marginLeft = mL-Math.floor(Math.abs(_widthStepSize)/2) + 'px';
		}
		else if (cw > _width){
			_element.style.width = (cw+_widthStepSize>_width?cw+_widthStepSize:_width) + 'px';
			//_element.style.marginLeft = mL+Math.floor(Math.abs(_widthStepSize)/2) + 'px';
		}
		if (ch < _height){
			_element.style.height = (ch+_heightStepSize<_height?ch+_heightStepSize:_height) + 'px';
			//_element.style.marginTop = mT-Math.floor(Math.abs(_heightStepSize)/2) + 'px';
		}
		else if (ch > _height){
			_element.style.height = (ch+_heightStepSize>_height?ch+_heightStepSize:_height) + 'px';
			//_element.style.marginTop = mT+Math.floor(Math.abs(_heightStepSize)/2) + 'px';
		}
		if (cw == _width && ch == _height){
			clearInterval(_INTERVAL_ID);
			_INTERVAL_ID = null;
			if (onReady){
				onReady();
			}
			if (sleepTime!=0){
				setTimeout(next,sleepTime);
			}
			else {
				next();	
			}
		}
	}
}
