if (typeof Array.prototype.copy === 'undefined') {
	Array.prototype.copy = function(a) {
		var a = [],i = this.length;
		while (i--) {
			a[i] = this[i];
		}
		return a;
	};
}
if (typeof Array.prototype.indexOf === 'undefined') {
	Array.prototype.indexOf = function(n) {
		for (var i = 0; i < this.length; i++) {
			if (this[i] === n) {
				return i;
			}
		}
		return -1;
	}
}
if (typeof Array.prototype.lastIndexOf === 'undefined') {
	Array.prototype.lastIndexOf = function(n) {
		var i = this.length;
		while (i--) {
			if (this[i] === n) {
				return i;
			}
		}
		return -1;
	}
}
if (typeof Array.prototype.forEach === 'undefined') {
	Array.prototype.forEach = function(f) {
		var i = this.length,j,l = this.length;
		for (i = 0; i < l; i++) {
			if ((j = this[i])) {
				f(j);
			}
		}
	};
}
if (typeof Array.prototype.insert === 'undefined') {
	Array.prototype.insert = function(i, v) {
		if (i >= 0) {
			var a = this.slice(),b = a.splice(i);
			a[i] = value;
			return a.concat(b);
		}
	}
}
if (typeof Array.prototype.shuffle === 'undefined') {
	Array.prototype.shuffle = function() {
		var i = this.length,j,t;
		while (i--) {
			j = Math.floor((i + 1) * Math.random());
			t = arr[i];
			arr[i] = arr[j];
			arr[j] = t;
		}
	}
}
if (typeof Array.prototype.unique === 'undefined') {
	Array.prototype.unique = function() {
		var a = [],i,b = this.copy();
		b.sort();
		for (i = 0; i < b.length; i++) {
			if (b[i] !== b[i + 1]) {
				a[a.length] = b[i];
			}
		}
		return a;
	}
}
if (typeof Array.prototype.concat === 'undefined') {
	Array.prototype.concat = function(a) {
		for (var i = 0,b = this.copy(); i < a.length; i++) {
			b[b.length] = a[i];
		}
		return b;
	};
}
if (typeof Array.prototype.pop === 'undefined') {
	Array.prototype.pop = function() {
		var b = this[this.length - 1];
		this.length--;
		return b;
	};
}
if (typeof Array.prototype.push === 'undefined') {
	Array.prototype.push = function() {
		for (var i = 0,b = this.length,a = arguments; i < a.length; i++) {
			this[b + i] = a[i];
		}
		return this.length;
	};
}
if (typeof Array.prototype.shift === 'undefined') {
	Array.prototype.shift = function() {
		for (var i = 0,b = this[0]; i < this.length - 1; i++) {
			this[i] = this[i + 1];
		}
		this.length--;
		return b;
	};
}
if (typeof Array.prototype.slice === 'undefined') {
	Array.prototype.slice = function(a, c) {
		var i = 0,b,d = [];
		if (!c) {
			c = this.length;
		}
		if (c < 0) {
			c = this.length + c;
		}
		if (a < 0) {
			a = this.length - a;
		}
		if (c < a) {
			b = a;
			a = c;
			c = b;
		}
		for (i; i < c - a; i++) {
			d[i] = this[a + i];
		}
		return d;
	};
}
if (typeof Array.prototype.splice === 'undefined') {
	Array.prototype.splice = function(a, c) {
		var i = 0,e = arguments,d = this.copy(),f = a;
		if (!c) {
			c = this.length - a;
		}
		for (i; i < e.length - 2; i++) {
			this[a + i] = e[i + 2];
		}
		for (a; a < this.length - c; a++) {
			this[a + e.length - 2] = d[a - c];
		}
		this.length -= c - e.length + 2;
		return d.slice(f, f + c);
	};
}
if (typeof Array.prototype.unshift === 'undefined') {
	Array.prototype.unshift = function(a) {
		this.reverse();
		var b = this.push(a);
		this.reverse();
		return b;
	};
}
if (typeof Array.prototype.sum === 'undefined') {
	Array.prototype.sum = function() {
		for (var i = 0,sum = 0; i < this.length; sum += this[i++]);
		return sum;
	}
}
