/*
$Id: 
Copyright(C) 1996-2005 INCREMENT P CORP.
*/
function CreateButton( oOwnerDocument, strImgUp, strImgDown )
{
	var oButton = oOwnerDocument.createElement( "img" );
	oButton.onmousedown	= function ( e )
	{
		this.bPush	= true;
		this.bWithin	= true;
		this.src = this.strImgDown;
		var	oEvent = CMN_GetEvent( this.ownerDocument, e );
		oEvent.cancelBubble	= true;
		CMN_PreventDefault( oEvent );
	
		var oThis = this;
		
		var fCaptureMouseUp = function()
		{
			oThis.bPush = false;
			CMN_RemoveEventListener(	oThis.ownerDocument,
							CMN_GetEventName( "mouseup" ),
							fCaptureMouseUp )
		}
		CMN_AddEventListener(	oThis.ownerDocument,
					CMN_GetEventName( "mouseup" ),
					fCaptureMouseUp )
	}
	
	var fMouseOver = function( e )
	{
		this.bWithin	= true;
		if( this.bPush )
		{
			this.src = this.strImgDown;
		}
		else	
		{
			this.src = this.strImgUp;
		}
	}
	CMN_SetMouseOver( oButton, fMouseOver ); 
	
	var fMouseOut = function( e )
	{
		this.bWithin	= false;
		this.src = this.strImgUp;
	}
	CMN_SetMouseOut( oButton, fMouseOut );
	
	oButton.onmouseup	= function( e )
	{
		this.bPush	= false;
		this.bWithin	= false;
		var	oEvent = CMN_GetEvent( this.ownerDocument, e );
		oEvent.cancelBubble	= true;
		CMN_PreventDefault( oEvent );
		
		this.src = this.strImgUp;
		if( this.OnClickButton )
		{
			this.OnClickButton();
		}
	}
	
	oButton.onclick		= function( e )
	{
		var	oEvent = CMN_GetEvent( this.ownerDocument, e );
		oEvent.cancelBubble	= true;
		CMN_PreventDefault( oEvent );
	}
	
	oButton.style.position	= "absolute";
	oButton.style.zIndex	= 10;
	oButton.style.overflow	= "hidden";

	oButton.strImgUp	= strImgUp;
	oButton.strImgDown	= strImgDown;
	oButton.bPush		= false;
	oButton.bWithin		= false;
	oButton.src		= strImgUp;
	return	oButton;
}
