// Gaia Ajax Copyright (C) 2008 - 2009 Gaiaware AS. details at http://gaiaware.net/

/* 
 * Gaia Ajax - Ajax Control Library for ASP.NET
 * Copyright (C) 2008 - 2009 Gaiaware AS
 * All rights reserved.
 * This program is distributed under either GPL version 3 
 * as published by the Free Software Foundation or the
 * Gaia Commercial License version 1 as published by
 * Gaiaware AS
 * read the details at http://gaiaware.net
 */
 
/* ---------------------------------------------------------------------------
   Class basically wrapping the ASP.Button WebControl class
   --------------------------------------------------------------------------- */
Gaia.Button = Class.create(Gaia.WebControl, {

  // "Constructor"
  initialize: function(element, options){
    this.initializeButton(element, options);
  },

  initializeButton: function(element, options){
    // Calling base class constructor
    this.initializeWebControl(element, options);
    this.initializeDefaultValidation();
  },

  // Sets text of button
  setText: function(value){
    this.element.value = value;
    return this;
  },

  // Sets text of button
  setPostBackUrl: function(value){
    this.options.url = value;
    return this;
  },

  // Sets a function to call when button is clicked
  setOnClientClick: function(value) {
    if (value)
        this.element.onclick = new Function(value).bindAsEventListener(this.element);
    else {
        this.element.onclick = null;
        this.element.removeAttribute('onclick');
    }   
    
    return this;
  },

  _getElementPostValue: function(){
    return '';
  },

  _getElementPostValueEvent: function(){
    return '&' + this.getCallbackName() + '=' + $F(this.element.id);
  }
});

Gaia.Button.browserFinishedLoading = true;
