//Setup adding and removing items from Local Storage
Storage.prototype.setArray = function(key, obj) {
    return this.setItem(key, JSON.stringify(obj));
}

Storage.prototype.getArray = function(key) {
    return JSON.parse(this.getItem(key));
}
// Removes an element from an array.
// String value: the value to search and remove.
// return: an array with the removed element; false otherwise.
Array.prototype.remove = function(k,v) {
	for (i=0; i < this.length; i++) {
	    if ((this[i].hasOwnProperty(k)) && (this[i][k] === v)) {
	        this.splice(i,1);
	        break;
	    } 
	}
}

// Take 24 hour time and convert it to a displayable time
function convertTime(x) {
	var hours24 = parseInt(x.substring(0, 2),10);
	var hours = ((hours24 + 11) % 12) + 1;
	var amPm = hours24 > 11 ? 'pm' : 'am';
	var minutes = x.substring(2);
	return hours + ':' + minutes + amPm;
}

// Take minutes and converts it to hours
function convertMinutes(x) {
	//Setup hours and minutes
	var hours = Math.floor(x/60);
	var minutes = x% 60;
	//Hacky hack hack to make numbers strings
	hours = hours + '';
	minutes = minutes + '';
	
	//Check to see if hours is long enough
	if (hours.length === 1) {
		hours = '0' + hours;
	}
	//And then the same on minutes
	if (minutes.length === 0) {
		minutes = '00';
	} else if (minutes.length === 1) {
		minutes = '0' + minutes;
	}
	
	//and pipe out the output
	return hours+minutes;
}

// Takes 24 hour time and converts it to minutes
function convertHours(x) {
	var hours = parseInt(x.substring(0,2));
	var minutes = parseInt(x.substring(2,4));
	return (hours * 60) + minutes
}