﻿
function isArray(obj) {
    return jQuery.isArray(obj);
}

if (!Array.prototype.addRange) {
    Array.prototype.addRange = function (items) {
        this.push.apply(this, items);
    };
}

if (!Array.prototype.clone) {
    Array.prototype.clone = function () {
        if (this.length == 1) {
            return [this[0]];
        }
        else {
            return Array.apply(null, this);
        }
    };
}

if (!Array.prototype.removeRange) {
    Array.prototype.removeRange = function (items) {
        var clone = this.clone();
        for (var i = 0; i < items.length; i++)
            clone.remove(items[i]);

        return clone;
    };
}
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function (item /*, startIndex */) {
        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] === item)
                return from;
        }
        return -1;
    };
}

if (!Array.prototype.contains) {
    Array.prototype.contains = function (item) {
        return this.indexOf(item) != -1;
    };
}

if(!Array.prototype.remove){
    Array.prototype.remove = function (item) {
        var index = this.indexOf(item);
        if (index >= 0)
            this.splice(index, 1);
    };
}

if (!Array.prototype.removeAt) {
    Array.prototype.removeAt = function (index) {
        this.splice(index, 1);
    };
}
