// handle button states. introduced for wir
function ButtonState( oInput )
{
	this._input = oInput;
	this._backgroundImage = this._input.style.backgroundImage.substr( 4, ( this._input.style.backgroundImage.length - 5  ) );
	
	if ( this._backgroundImage != "" )
	{
		this._input._parent = this;
		this._input.onmouseover = this.__mouseover;
		this._input.onmousedown = this.__mousedown;
		this._input.onmouseout = this.__mouseout;
		this._input.onclick = this.__mouseclick;
				
		// preserve styles
		this._input.style.width = this._input.offsetWidth + "px";
		this._input.style.height = ( this._input.offsetHeight / 3 ) + "px";
		this._input.src = "/media/image/clear.gif";
	}
};

ButtonState.prototype.__mouseover = function()
{
	if ( typeof XMLHttpRequest != "undefined" )
		this._parent._input.style.marginTop = "0px";
	
	this._parent._input.style.backgroundPosition = "0px " + ( this._parent._input.offsetHeight * -1 ) + "px";
};

ButtonState.prototype.__mouseout = function()
{
	this._parent._input.style.backgroundPosition = "0px 0px";
};

ButtonState.prototype.__mousedown = function()
{
	this._parent._input.style.backgroundPosition = "0px " + ( this._parent._input.offsetHeight * -2 ) + "px";
};

ButtonState.prototype.__mouseclick = function()
{
	this._parent._input.style.backgroundPosition = "0px 0px";
};

function initButtonState()
{
	// detect IE6 / IE7
	if ( window.ActiveXObject && typeof window.postMessage == "undefined" )
	{
		var aButton = document.getElementsByTagName( "input" );
		for ( var i = 0; i < aButton.length; ++i )
			if ( aButton[ i ].className.match( /button/ ) )
				new ButtonState( aButton[ i ] );
	}
}
