if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (searchElement, fromIndex) { var k; if (this == null) { throw new TypeError('"this" is null or not defined'); } var O = Object(this); var len = O.length >>> 0; if (len === 0) { return -1; } var n = +fromIndex || 0; if (Math.abs(n) === Infinity) { n = 0; } if (n >= len) { return -1; } k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); while (k < len) { if (k in O && O[k] === searchElement) { return k; } k++; } return -1; }; } if (!Array.prototype.each) { Array.prototype.each = function (fn) { fn = fn || Function.K; var a = []; var args = Array.prototype.slice.call(arguments, 1); for (var i = 0; i < this.length; i++) { var res = fn.apply(this, [this[i], i].concat(args)); if (res != null) a.push(res); } return a; }; } if (!Array.prototype.contains) { Array.prototype.contains = function (needle) { for (i in this) { if (this[i] == needle) return true; } return false; } } if (!Array.prototype.uniquelize) { Array.prototype.uniquelize = function () { var ra = new Array(); for (var i = 0; i < this.length; i++) { if (!ra.contains(this[i])) { ra.push(this[i]); } } return ra; }; } if (!Array.minus) { Array.minus = function (a, b) { return a.uniquelize().each(function (o) { return b.contains(o) ? null : o }); }; } if (!Array.complement) { Array.complement = function (a, b) { return Array.minus(Array.union(a, b), Array.intersect(a, b)); }; } if (!Array.intersect) { Array.intersect = function (a, b) { return a.uniquelize().each(function (o) { return b.contains(o) ? o : null }); }; } if (!Array.union) { Array.union = function (a, b) { return a.concat(b).uniquelize(); }; }