/*****************************************************************************
Filename:	MMWCoreExtensions.js
Created:	04/10/2006
Created by:	James Norton
-----------------------------------------------------------------------------
Purpose:	Extends various in built JavaScript object types with useful extra
			methods and properties
Type:		Object extensions
-----------------------------------------------------------------------------
CHANGE LOG
-No	-Date		-Changed By		-Reason for change
*****************************************************************************/
self.base = function(method_name, o) {
    if (o.className == "" || o.className == null || o == null || typeof(o) != "object") return false;
    var method = eval(o.className + ".prototype." + method_name);
    if (method == null) return false;
    
    //build a list of arguments:
    var args = "";
    for (var i = 2, j= arguments.length; i<j; i++) {
        args += ", ";
        if (typeof arguments[i] == "string") {
            args += "'" + arguments[i] + "'";
        } else {
            args += arguments[i];
        }
    }
    
    var call = "method.call(o" + args + ");";
    eval(call);
    
    return true;
}
String.prototype.trim = function () {
    return this.replace(/^\s*|\s*$/g,'');
}

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}
