Function.prototype.bindAsEventListener = function(object) {
  var __method = this, args = $A(arguments), object = args.shift();
  return function(event) {
     if(typeof $A === 'function'){                  // <-- Added Firefox Fix
         return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
     }
  }
}

// "Thanks to Dave for the hint!"
Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
     if(typeof $A === 'function'){                  // <-- Added Firefox Fix
         return __method.apply(object, args.concat($A(arguments)));
     }
  }
}

// removes whitespace-only text node children
// from a node and all its descendants
Element.cleanAllWhitespace = function(element) {
  var node = element.firstChild;
  while (node) {
    var nextNode = node.nextSibling;
    if (node.nodeType == 1)
      Element.cleanAllWhitespace(node);
    else if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
      element.removeChild(node);
    node = nextNode;
  }
  return element;
};

// returns the full text of an xml node
Element.nodeVal = function(node) {
  return node.childNodes && node.childNodes.length > 0 ?
    $A(node.childNodes).inject('', function (a, b) {
      return a + b.nodeValue;
    }) : '';
};


// Get the value of a radio group : http://xavisys.com/using-prototype-javascript-to-get-the-value-of-a-radio-group/
function $RF(form_id, radioGroupName) {
    if($(form_id).type && $(form_id).type.toLowerCase() == 'radio'){var radioGroupName=$(form_id).name;var form_id=$(form_id).form;} 
		else if($(form_id).tagName.toLowerCase()!='form'){return false;}
    var checked = $(form_id).getInputs('radio', radioGroupName).find(function(re){return re.checked;});
    return (checked) ? $F(checked) : null;
}