  function getParams(args, result) {
    var i = 0;
    for (var name in result) {
      if (typeof(args[i]) == result[name]) {
        result[name] = args[i];
        i++;
      } else {
        result[name] = false;
      }
    } 
    return result;
  }

  var divObjectDump;  
  function showObjectHtml(name, obj, maxDepth) {
    if (!divObjectDump) {
      divObjectDump = document.createElement("div");
      divObjectDump.style.position = "absolute";
      divObjectDump.style.left = "25px";
      divObjectDump.style.top = "25px";
      divObjectDump.style.border = "1px solid blue";
      divObjectDump.style.background = "#FFF";
      divObjectDump.style.padding = "10px";
      divObjectDump.style.zIndex = "5000";
      divObjectDump.id = "divObjectDump";
      divObjectDump.name = "divObjectDump";
      document.body.appendChild(divObjectDump);
      //SET_DHTML("divObjectDump");
    }
    divObjectDump.innerHTML = "<h3>Dump of var</h3>\n" + getObjectHtml(name, obj, maxDepth);
  }
  
  function getObjectHtml(name, obj, maxDepth, limit) {
    function printObjectEx(obj, inc, depth) {
      result = "";
      try {  
        for (var key in obj) {
          i++;
          if (key.search(/parent.*/) != -1) break;
          if (i == limit) {
            result += inc + "...<br>\n";
            break;
            }
          if (typeof(obj[key]) == "object") {
            result += inc + key + "&nbsp;=&nbsp;[object]&nbsp;{<br>\n";
            if (depth < maxDepth) {
              result += printObjectEx(obj[key], inc + "&nbsp;&nbsp;&nbsp;&nbsp;", depth + 1);
            } else {
              result += inc + "...<br>\n";
            }
            result += inc + "}<br>\n";
          } else {
            result += inc + key + "&nbsp;=&nbsp;" + obj[key] + "<br>\n";
          }
        }
      } catch (e) {
        i++;
        result += inc + e + "<br>\n";
      }
      return result;
    }
    
    maxDepth = (maxDepth) ? maxDepth : 3;
    limit = (limit) ? limit : 250;
    var i = 0;
    var a = new Array(1);
    a[name] = obj;
    return printObjectEx(a, "", 0);
  }
  /*
  function addEvent( obj, type, fn ) {
    if ( obj.attachEvent ) {
      obj['e'+type+fn] = fn;
      obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
      obj.attachEvent( 'on'+type, obj[type+fn] );
    } else
      obj.addEventListener( type, fn, false );
  }
  function removeEvent( obj, type, fn ) {
    if ( obj.detachEvent ) {
      obj.detachEvent( 'on'+type, obj[type+fn] );
      obj[type+fn] = null;
    } else
      obj.removeEventListener( type, fn, false );
  }
  */
  
  function xmlElement(tag, attributes, text) {
    var obj = document.createElement(tag);
    for (var attr in attributes) {
      obj[attr] = attributes[attr];
    }
    if (text) {
      var objText = document.createTextNode(text);
      obj.appendChild(objText);
    }
    return obj;
  }

  function swapNodes(x, y, keepRefs) {
    if (keepRefs == true) {
      /*
      if (y.nextSibling == x) {
        var xBuf = x;
        x = y;
        y = xBuf;
        }
      */
      var ns6 = navigator.userAgent.toLowerCase().indexOf("netscape6") != -1;

      if (ns6) {
        //# works everywhere but its so gay
        var xNextSibling = x.nextSibling;
        var yNextSibling = y.nextSibling;
        var xParent = x.parentNode;
        var yParent = y.parentNode;

        var children = [];
        if (xParent != yParent) {
          yParent.style.display = 'none';
          for (var i = 0; i < yParent.childNodes.length; i++) {
            children[i] = yParent.childNodes[i] == x ? y : yParent.childNodes[i] == y ? x : yParent.childNodes[i];
            }
          for (var i = 0; i < children.length; i++) {
            yParent.appendChild(children[i]);
            }
          yParent.style.display = 'block';
          }
        children = [];
        xParent.style.display = 'none';
        for (var i = 0; i < xParent.childNodes.length; i++) {
          children[i] = xParent.childNodes[i] == x ? y : xParent.childNodes[i] == y ? x : xParent.childNodes[i];
          }
        for (var i = 0; i < children.length; i++) {
          xParent.appendChild(children[i]);
          }
        xParent.style.display = 'block';
        }      
      else {
        //# working except for NS6
        var buf = document.createTextNode('');
        x.parentNode.insertBefore(buf, x);
        y.parentNode.insertBefore(x, y);
        buf.parentNode.replaceChild(y, buf);
        }
      
      /*
      //# working except for NS6
      var xCopy = x.cloneNode(true);  
      var yCopy = y.cloneNode(true);  
      xParent.replaceChild(xCopy, x);
      yParent.replaceChild(yCopy, y);
      xParent.replaceChild(y, xCopy);
      yParent.replaceChild(x, yCopy);
      */
      
    } else {
      var buf = x.cloneNode(true);
      x.parentNode.replaceChild(y.cloneNode(true), x);
      y.parentNode.replaceChild(buf, y);
    }
  }
  function swapIds(x, y) {
    var xId = x.id;
    var yId = y.id;
    x.id = '';
    y.id = xId;
    x.id = yId; 
  }
  function getChildById(node, id, depth) {
    if (!depth) depth = 1;
    var child = node.firstChild;
    while (child != null) {
      if (child.id == id) {
        return child;
      } else {
        if (depth > 1 && child.hasChildNodes()) {
          var childChild = getChildById(child, id, depth - 1);
          if (childChild != null) {
            return child;
          }
        }
      }
      child = child.nextSibling;
    }
    return null;
  }

  function createToolButton(type, action, addClass) {
    //action = '#'; //wgScriptPath.replace(/$1/g, wgPageName);
    if (action)
      var button = xmlElement('a', {href: action});
    else
      var button = xmlElement('span');
    button.className = 'toolButton' + (addClass ? ' ' + addClass : '');
    button.appendChild(xmlElement('span', {className: type}));
    return button;
  }

  function trimToRange(low, x, high) {
    return (x > high) ? high : (x < low) ? low : x;
    } 

  function getCoords(htmlObj, htmlObjParent) {
    var result = {x: 0, y: 0};
    var obj = htmlObj;
    do {
      result.x += obj.offsetLeft;
      result.y += obj.offsetTop;
      if (!window.opera && !window.ie/* && obj != htmlObj*/) {
        result.x += parseInt($(obj).getStyle('border-left-width'));
        result.y += parseInt($(obj).getStyle('border-top-width'));
        }
      obj = obj.offsetParent;
      }
    while(obj && obj != htmlObjParent);
    return result;
    }

/*
Object.prototype.appendAfter = function(newElement) {
   //call insertBefore method on parent node to insert the new element before the element next to this
   this.parentNode.insertBefore(newElement, this.nextSibling);
}
 
Object.prototype.appendBefore = function(newElement) {
   //call insertBefore method on parent node to insert the new element before this
   this.parentNode.insertBefore(newElement, this);
}

Object.prototype.hasClass = function(className) {
   var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)'); //use this regexp
   return pattern.test(this.className); //to check for the class
}
 
Object.prototype.addClass = function(className) {
   if (!this.hasClass(className)) { //if the class isn't there already
      this.className += (' ' + className); //append it to the end of the class list
   }
}
 
Object.prototype.removeClass = function(className) {
   var pattern = new RegExp('(^|\\s)' + className + '(\\s|$)'); //use this regexp
   this.className = this.className.replace(pattern, ' '); //to make a search and replace by a blank space
}
*/
/*
Object.prototype.addEventEx = function(evtType, func) {
   if (this.addEventListener) { //gecko
      this.addEventListener(evtType, func, true);
   } else if (this.attachEvent) { //ie
      this.attachEvent('on' + evtType, func);
   } else { //all the others
      this['on' + evtType] = func;
   }
}


Object.prototype.removeElement = function(oldElement) {
   var childElements = oldElement.getElementsByTagName('*');
 
   for (var i = 0; i < childElements.length; i++) { //purge all elements contained in the element to remove
      purge(childElements[i]);
   }
 
   purge(oldElement); //purge the element to remove
   this.removeChild(oldElement); //remove it
 
   //function that came from Douglas Crockford site, that removes all the event handlers from de elements
   function purge(d) {
      var a = d.attributes, i, l, n;
      if (a) {
          l = a.length;
          for (i = 0; i < l; i += 1) {
              n = a[i].name;
              if (typeof d[n] === 'function') {
                  d[n] = null;
              }
          }
      }
      a = d.childNodes;
      if (a) {
          l = a.length;
          for (i = 0; i < l; i += 1) {
              purge(d.childNodes[i]);
          }
      }
   }
}

//call the function having each element of the array as parameter
Array.prototype.map = function(f) {
  for (i = 0; i < this.length; i++)
    f(this[i]);
}
*/
