var UserRelation = {
 favoriteChange : function(action, ufName) {
    url = '/relation/json/'+action+'/'+ufName;
    var ajax = new Ajax.Request( url, 
				 {
				 method: 'get',
				     onSuccess: function(transport, json){
					 UserRelation.favoriteCallback(json);
				   },
				     onFailure: function(transport){
					 genericMessageModal('There has been a problem reaching the Open Salon servers. ' + 
							     'Please let us know what you were trying to do at ' + 
							     '<a href="mailto:open.problems@salon.com">open.problems@salon.com</a>');
				   }
				 });

  },

 favoriteCallback : function (json) {
	if (json.success) {
	//This represents the new state of the button. 
	//If the user pressed add this should be remove
	buttonState = json.responseData.buttonState;
	if (buttonState == 'remove') {
	    buttonLabel = 'Remove Favorite';
	    modalMessage = 'This user has now been added to your favorites';
	}
	else if (buttonState == 'add') {
	    buttonLabel = 'Add Favorite';
	    modalMessage = 'This user has now been removed from your favorites';
	}

	linkString = '<a onclick="UserRelation.favoriteChange(\''+buttonState+'\',\'kerry_lauerman\')">'+buttonLabel+'</a>';
	$('about_make_favorite').update(linkString);
	genericMessageModal(modalMessage);
	} else {
	    genericMessageModal('There has been a problem reaching the Open Salon servers. ' + 
				'Please let us know what you were trying to do at ' + 
				'<a href="mailto:open.problems@salon.com">open.problems@salon.com</a>');
	}
    }
}