/**
 * Extensions for WS-AJAX by IBM.
 *
 * @author Jakob Kruse <kruse@kruse-net.dk>
 * @version $Id: ws-x.js,v 1.1 2006/03/02 20:17:00 Jakob Kruse Exp $
 */

// Check requirements
if (typeof Prototype != "object")
  alert("Prototype (prototype.js) required in ws-x.js");
if (typeof WS != "object")
  alert("WS-AJAX (ws.js) required in ws-x.js");
  
/**
 * getElementsByTagNameNS treats the namespace '*' special (meaning any namespace).
 * Since this is the only way to find elements with no namespace, it is introduced
 * below, for those browsers lacking getElementsByTagNameNS.
 */
XML.getElementsByQName = function(element, qname) {
  var nl = null;
  if(!element.getElementsByTagNameNS) {
    nl = new Array();
    var nodes = element.getElementsByTagName(qname.value_of());
    for (var n = 0; n < nodes.length; n++) {
      if (qname.namespace == '*' || nodes[n].namespaceURI == qname.namespace) {
        nl.push(nodes[n]);
      }
    }
  } else {
    nl = element.getElementsByTagNameNS(qname.namespace,qname.localpart);
  }
  return nl;
}

/**
 * A nice convenience function for something done quite frequently.
 */
Object.extend(SOAP.Element.prototype, {
  get_first_child : function(name) {
    return (this.get_children(new WS.QName(name, '*')))[0];
  }
});

// EOF
