var HorizontalSizer = function(elementId, displaySize, hoverElementId, increment, delay)
{
	this.elementId=elementId;
	this.displaySize=displaySize;
	this.increment=increment;
	this.delay=delay;
	
	this.targetSize=0;
	this.timer=null;

	var othis=this;
	$(hoverElementId).hover(function() { othis.changeSize.call(othis); });
			
};
		
HorizontalSizer.prototype.changeSize=function()
{
	this.targetSize=this.displaySize-this.targetSize;

	this.startResizing();
};
	
HorizontalSizer.prototype.startResizing=function()
{
	if (this.timer != null)
	{
		clearInterval(this.timer);
		this.timer=null;
	}
	
	var othis=this;
    this.timer = setInterval( function() { othis.resizeIteration.call(othis); } , this.delay);
};

HorizontalSizer.prototype.resizeIteration=function()
{
	var element=$(this.elementId);
	if (element.width() > this.targetSize+this.increment)
	{
		element.width(element.width()-this.increment);
	}
	else 
	{
		if (element.width() < this.targetSize-this.increment)
		{
			element.width(element.width()+this.increment);
		}
		else
		{
			element.width(this.targetSize);
			clearInterval(this.timer);
			this.timer=null;
		}
	}
};