function searchFavorites(query) {
	var feedback = [];
	var resultList = JSON.parse(localStorage.getItem("results"));
	if (resultList == null) {
		return feedback;
	} else {
		_.each(resultList, function(x) {
			if (x.name.toLowerCase().indexOf(query.toLowerCase()) > -1) {
				feedback.push(x);
			} else if (x.tags.toLowerCase().indexOf(query.toLowerCase()) > -1) {
				feedback.push(x);

			} else if (x.notes.toLowerCase().indexOf(query.toLowerCase()) > -1) {
				feedback.push(x);
			}
			else if (x.location.display_address.toLowerCase().indexOf(query.toLowerCase()) > -1) {
				feedback.push(x);
			}
		});
	}
	return feedback;
}


function getFavoriteCategories() {

	var feedback = {};
	var resultList = JSON.parse(localStorage.getItem("results"));
	//returns the list of lists (of categories);
	_.each(resultList, function(x) {
		feedback[x.name] = [];
		_.each(x.categories, function(y) {
			feedback[x.name].push(y[1]);
		});
	});
	var answer = {};
	//a temp variable used in getBroadCategories which will be filled which a business's category hierachy
	var cats = [];
	//a list of 'answer' lists; each element in cats is a list containing the hierachy for each business

	_.each(feedback, function(innerCat, ky) {

		//	alert(innerCat); works- shows the strings of the categories
		cats.push(getBroadCategories(answer, innerCat, categories));
		answer = {};
	});
	//alert(cats);
	return cats;
}

//this function needs testing

function getBroadCategories(answers, innerCat, globalCategories) {
	
	for (var singleCat in innerCat) {
		answers[singleCat] = [];
		var hierarchy = [];
		//alert(globalCategories);
		answers[singleCat] = findStrings(singleCat, hierarchy, globalCategories);

	}
	return answers;
}

function findStrings(singleCat, catsForThisCat, globalCategories) {
	for (var ky in globalCategories) {
		if ( typeof globalCategories == 'object') {
			catsForThisCat.push(globalCategories);
			findStrings(singleCat, catsForThisCat, globalCategories[ky]);
		} else if ( typeof globalCategories == 'string') {

			if (globalCategories.toLowerCase().search(singleCat.toLowerCase()) > -1) {
				alert(singleCat);
				return catsForThisCat;
				//return the list which contains the hierachy of categories for this business
				//first element in the list is the inner most category and the last element is the broad category
			} else {				
				catsForThisCat = [];
			}//else, the category of the item is not this one.
		}
	}
}

function getFavoritesWithinCategory(query) {
	var feedback = [];
	var resultList = JSON.parse(localStorage.getItem("results"));

	_.each(resultList, function(x) {
		if (x.categories == query) {
			feedback.push(x);
		}
	});
	return feedback;
}

function addBusinessToFavorite(business) {

	var resultList = JSON.parse(localStorage.getItem("results"));
	if (resultList == null) {
		resultList = [];

	}
	resultList.push(business);
	localStorage.setItem("results", JSON.stringify(resultList));
}

function deleteBusinessFromStorage(business) {
	var resultList = JSON.parse(localStorage.getItem("results"));
	var temp = removeA(resultList, business);
	localStorage.setItem("results", JSON.stringify(temp));
	getBookmarks(lastTerm[0]);
}

function removeA(array, item) {
	 for(var i in array){
    if(array[i].id == item.id) {
            array.splice(i,1);
            break;
            }
    }
	return array;
}

function saveBookmark(business, tags, notes) {
	if (tags == undefined) {
		tags = " ";
	}
	if (notes == undefined) {
		notes = " ";
	}
	business.tags = tags;
	business.notes = notes;
	var d = new Date();
	var day = d.getDate();
	var month = d.getMonth() + 1;
	var time = d.getTime();
	var year = d.getFullYear();
	business.dateAdded = time + " " + month + "/" + day + "/" + year;
	addBusinessToFavorite(business);
}
@@ -687,26 +687,24 @@
 gories() %7B%0D%0A
-%0D%0A
 %09var feedbac
@@ -1550,19 +1550,16 @@
 ies) %7B%0D%0A
-%09%0D%0A
 %09for (va
@@ -2418,20 +2418,16 @@
 %7D else %7B
-%09%09%09%09
 %0D%0A%09%09%09%09ca
@@ -2764,32 +2764,32 @@
 feedback;%0D%0A%7D%0D%0A%0D%0A
+
 function addBusi
@@ -2816,18 +2816,16 @@
 ess) %7B%0D%0A
-%0D%0A
 %09var res

Remove whitespace