//////////////////////////////////////////////////////////////////////////////
//  jaxbutton.js
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//  Jax.Widgets.Button constructor.
//
//	Usage:
//		new CfxButton( name, parent );
//////////////////////////////////////////////////////////////////////////////
Jax.Widgets.Button = function() {

	// Initialize member variables.
    var m_onclick = function(){};
	
	// Declare class and set instance.
	Jax.oop.declare(Jax.Widgets.Button, Jax.Widgets.Input);
	this.setInstance();
	
	//////////////////////////////////////////////////////////////////////////
	// initialize
	//////////////////////////////////////////////////////////////////////////
	this.initialize = function() {
		this.element = this.items.itemAt(0);
        this.bind("click", this.onClick);
	};
    
	//////////////////////////////////////////////////////////////////////////
	// clickHandler
	//////////////////////////////////////////////////////////////////////////
    this.clickHandler = function(handler) {
        this.checkHandler(handler);
        m_onclick = handler
    };
    
	//////////////////////////////////////////////////////////////////////////
	// onClick
	//////////////////////////////////////////////////////////////////////////
    this.onClick = function(sender, eventArg) {
        return m_onclick(sender, eventArg);
    };
    
    //////////////////////////////////////////////////////////////////////////
    // source
    //////////////////////////////////////////////////////////////////////////
    this.getSource = function() {
        return this.element.src;
    }
    
    this.setSource = function() {
        if (arguments.length) {
            this.element.src = arguments[0];
        }
    }
    
	// Initialize instance.
	if (arguments.length) {
		this.name = arguments[0];
		this.parent = arguments[1];
		this.items = this.getItems(this.name, this.parent);
		this.initialize();
	}
};