// Gaia Ajax Widgets Copyright (C) 2007  Frost Innovation AS. details at http://ajaxwidgets.com/

/* 
 * Gaia Ajax Widgets, an Ajax Widget Library
 * Copyright (C) 2007  Frost Innovation AS
 * All rights reserved.
 * This program is distributed under either GPL version 2 
 * as published by the Free Software Foundation or the
 * Gaia Commercial License version 1 as published by
 * Frost Innovation AS
 * read the details at http://ajaxwidgets.com/
 */




/* --------------------------------------------------------------------------------------------------------------------
   Class basically wrapping the stuff that's common between different ASP.Button WebControl classes
   -------------------------------------------------------------------------------------------------------------------- */
Gaia.ButtonHelper_shouldRunAjaxRequest = function(){
   if( this.options.url != Gaia.Control._defaultUrl ){
    // This button has UPDATED the PostBackUrl INSIDE an Ajax Event handler
    var originalForm = document.getElementsByTagName('form')[0];
    var form = document.createElement('form');
    form.action = this.options.url;
    form.method = 'post';
    $A(originalForm.elements).each(function(el){
      if( el.type && el.tagName == 'INPUT' ){
        var input = document.createElement('input');
        input.type = el.type;
        input.name = el.name;
        input.value = el.value;
        input.id = el.id;
        form.appendChild(input);
      }
    });
    Element.hide(form);
    document.getElementsByTagName('body')[0].appendChild(form);
    form.submit();
    return false;
  }
  return true;
}
