
// Checks if a value exists in an array
Array.prototype.inArray = function(needle) {
	for(theKey in this) {
		if(this[theKey] == needle) {
			return true;
		}
	}
	return false;
};

// Removes duplicate values from an array
Array.prototype.unique = function() {

	var uniqueArray = new Array()
	for(var i=0;i < this.length;i++) {
		if(!uniqueArray.inArray(this[i])) {
			uniqueArray.push(this[i]);
		}
	}
	return uniqueArray;
};

// Searches the array for a given value and returns the corresponding key if successful
Array.prototype.search = function(needle) {
	for(theKey in this) {
		if(this[theKey] == needle) {
			return key;
		}
	}
	return false;
};

// Fill an array with values
Array.prototype.fill = function() {
	for(var i=arguments[0];i < arguments[0] + arguments[1];i++) {
		if(arguments.length > 1) {
			this[i] = arguments[2]
		} else {
			this[i] = ""
		}
	}
};

// Apply a user function to every member of an array
Array.prototype.walk = function() {
	for(theKey in this) {
		if(arguments.length > 1) {
			this[theKey] = arguments[0](this[theKey],arguments[1])
		} else {
			this[theKey] = arguments[0](this[theKey]);
		}
	}
};

// Filters elements of an array using a callback function
Array.prototype.filter = function(callback) {
	var filterArray = new Array()
	for(theKey in this) {
		if(callback(this[theKey])) {
			filterArray[filterArray.length] = this[theKey];
		}
	}
	return filterArray;
};