/* God damn IE start */
if (!Object.keys) {
	Object.keys = function(obj) {
		var keys = [], k;
		for (k in obj) {
			if (Object.prototype.hasOwnProperty.call(obj, k)) {
				keys.push(k);
			}
		}
		return keys;
	};
}
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(obj, start) {
		for (var i = (start || 0), j = this.length; i < j; i++) {
			if (this[i] === obj) {
				return i;
			}
		}
		return -1;
	};
}
if (!('lastIndexOf' in Array.prototype)) {
	Array.prototype.lastIndexOf = function(find, i /*opt*/) {
		if (i === undefined)
			i = this.length - 1;
		if (i < 0)
			i += this.length;
		if (i > this.length - 1)
			i = this.length - 1;
		for (i++; i-- > 0; )/* i++ because from-argument is sadly inclusive */
			if ( i in this && this[i] === find)
				return i;
		return -1;
	};
}
if (!('trim' in String.prototype)) {
	String.prototype.trim = function() {
		return this.replace(/^\s+/, '').replace(/\s+$/, '');
	};
}
/* God damn IE end */

/**
 * Overwrite underscore function to allow indexOf on an array of objects
 * @mixin
 */
var indexOfValue = _.indexOf;
_.mixin({
	indexOf : function(array, test) {
		if (!_.isFunction(test)) {
			return indexOfValue(array, test);
		}
		for (var x = 0; x < array.length; x++) {
			if (test(array[x])) {
				return x;
			}
		}
		return -1;
	}
});