function favoriteStoreAdd(storeId) {
	$.ajax({
		type: "GET",
		url: '/favorites/stores/' + storeId + '/add/',
		success: function(data, textStatus) {
			ajaxStatusUpdate(new Array('Store successfully added to favorites!'), 'success');
		},
		error: function(request, textStatus, errorThrown) {
			if(request.responseText == '' || request.status != 500) {
				ajaxStatusUpdate(new Array('Store could not be added to favorites.'), 'error');
			}
			else {
				ajaxStatusUpdate(request.responseText.split("\n"), 'error');
			}
		}
	});
}

function favoriteBrandAdd(brandId) {
	$.ajax({
		type: "GET",
		url: '/favorites/brands/' + brandId + '/add/',
		success: function(data, textStatus) {
			ajaxStatusUpdate(new Array('Brand successfully added to favorites!'), 'success');
		},
		error: function(request, textStatus, errorThrown) {
			if(request.responseText == '' || request.status != 500) {
				ajaxStatusUpdate(new Array('Brand could not be added to favorites.'), 'error');
			}
			else {
				ajaxStatusUpdate(request.responseText.split("\n"), 'error');
			}
		}
	});
}
function favoriteStoreDelete(storeId) {
	$.ajax({
		type: "GET",
		url: '/favorites/stores/' + storeId + '/delete/',
		success: function(data, textStatus) {
			ajaxStatusUpdate(new Array('Store successfully deleted to favorites!'), 'success');
			$('#s_' + storeId + '_1').fadeOut(1000);
			$('#s_' + storeId + '_2').fadeOut(1000);
			$('#s_' + storeId + '_3').fadeOut(1000);
			window.setTimeout(function() {$('#s_' + storeId).remove();}, 1100);		},
		error: function(request, textStatus, errorThrown) {
			if(request.responseText == '' || request.status != 500) {
				ajaxStatusUpdate(new Array('Store could not be deleted to favorites.'), 'error');
			}
			else {
				ajaxStatusUpdate(request.responseText.split("\n"), 'error');
			}
		}
	});
}

function favoriteBrandDelete(brandId) {
	$.ajax({
		type: "GET",
		url: '/favorites/brands/' + brandId + '/delete/',
		success: function(data, textStatus) {
			ajaxStatusUpdate(new Array('Brand successfully deleted to favorites!'), 'success');
			$('#b_' + brandId + '_1').fadeOut(1000);
			$('#b_' + brandId + '_2').fadeOut(1000);
			$('#b_' + brandId + '_3').fadeOut(1000);
			window.setTimeout(function() {$('#b_' + brandId).remove();}, 1100);
		},
		error: function(request, textStatus, errorThrown) {
			if(request.responseText == '' || request.status != 500) {
				ajaxStatusUpdate(new Array('Brand could not be deleted to favorites.'), 'error');
			}
			else {
				ajaxStatusUpdate(request.responseText.split("\n"), 'error');
			}
		}
	});
}

function favoriteBrandEdit(brandId) {
	$('#b_' + brandId + '_notes').editable(
		'/favorites/brands/' + brandId + '/edit/', {
		type: 'textarea',
		submit: 'Save', 
		cancel: 'Cancel',
		rows: 5,
		cols: 55,
		placeholder: 'Click to Edit'
	});

	$('#b_' + brandId + '_notes').mouseover(function() {
		$(this).animate({backgroundColor: '#ffff99'}, {duration: 350})
			.animate({backgroundColor: '#f6f6f6'}, {duration: 350});
	});
}

function favoriteStoreEdit(storeId) {
		$('#s_' + storeId + '_notes').editable(
		'/favorites/stores/' + storeId + '/edit/', {
		type: 'textarea',
		submit: 'Save', 
		cancel: 'Cancel',
		rows: 5,
		cols: 55,
		placeholder: 'Click to Edit'
	});

	$('#s_' + storeId + '_notes').mouseover(function() {
		$(this).animate({backgroundColor: '#ffff99'}, {duration: 350})
			.animate({backgroundColor: '#f6f6f6'}, {duration: 350});
	});
}
