/*
  CodeBaby JavaScript Library
  Copyright (c) 2004-2006 CodeBaby Corp.
  All rights reserved.
  This source code can only be distributed in accordance with the terms of the license agreement entered into
  with CodeBaby.

  Version: LEX
  $Rev: 1184 $
  $Date: 2006-07-04 10:32:07 -0600 (Tue, 04 Jul 2006) $
  $URL: http://svn/svn/Development/JSLib/Branches/LEXSimplifyJavaScript/Core/cb/core/cb_library_common.js $
*/	 

/*******************************************************************************
  NOTE: this is a core CodeBaby file, and should not be modified in any way, 
  unless absolutely necessary.
*******************************************************************************/


/* This file is included to support IE5 */

if (typeof(undefined) == "undefined") {
    undefined = null;
}

if (typeof(Array.prototype.push) == "undefined") {
    Array.prototype.push = function(object) {
        this[this.length++] = object;
        return this.length;   
    }
}

if (typeof(Array.prototype.pop) == "undefined") {
    Array.prototype.pop = function() {
        var value = this[this.length-1];
        this.length--;
        return value;
    }
}

if (typeof(Array.prototype.splice) == "undefined") {
    Array.prototype.splice = function(startIndex, deleteCount, value1, value2) {
        // get the elements to be inserted
        var valueArray = new Array();
        for (var i=2; i<arguments.length; i++) {
            valueArray.push(arguments[i]);
        }
        
        var newArray = new Array(); 
        var deletedElements = new Array();
        
        // calculate the new length
        var newLength = this.length - deleteCount + valueArray.length;
        
        // first, delete any elements
        for (var i=0; i<this.length; i++) {
            
            // insert new elements
            if (i == startIndex) {
                for (var j=0; j<valueArray.length; j++) {
                    newArray.push(valueArray[j]);
                }
            }
            
            // omit deleted elements
            if (i < startIndex || i >= startIndex+deleteCount) {
                newArray.push(this[i]);
            } else {
                deletedElements.push(this[i]);   
            }
            
        }       
        
        // copy the elements to this object
        this.length = newArray.length;
        for (var i=0; i<newArray.length; i++) {
            this[i] = newArray[i];
        }
        
        return deletedElements;
    }
}

if (typeof(Array.prototype.shift) == "undefined") {
    Array.prototype.shift = function() {
        return this.splice(0,1);   
    }
}

/*if (typeof(Function.prototype.apply) == "undefined") {
    Function.prototype.apply = function(thisobj, args) {
        var argString = "";
        for (var i=0; i<args.length; i++) {
            argString += args[i];
            if (i < args.length-1) {
                argString += ", ";
            }
        } 
        return eval("this(" + argString + ");")
    }
}


if (typeof(Function.prototype.call) == "undefined") {
    Function.prototype.call = function(thisobj, arg1, arg2) {
        var argString = "";
        for (var i=1; i<arguments.length; i++) {
            argString += arguments[i];
            if (i < args.length-1) {
                argString += ", ";
            }
        } 
        return eval("this(" + argString + ");")
    }
}*/
