if (!Array.prototype.contains) {
    Array.prototype.contains = function(obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
            }
        }
        return false;
    }
}
if (!Array.prototype.containsClone) {
    Array.prototype.containsClone = function(obj) {
        var i = this.length;
        while (i--) {
            if (JSON.stringify(this[i]) === JSON.stringify(obj)) {
                return true;
            }
        }
        return false;
    }
}

if (!Array.prototype.swap) {
    Array.prototype.swap = function (x,y) {
      var b = this[x];
      this[x] = this[y];
      this[y] = b;
      return this;
    }
}