var UserProfile = {
	General	: {},
	Favorites : {},
	Friends : {},
	Organize : {}
};

UserProfile.General.EventHandlers = {
	onPhotoAddClick : function () {
		Marvin.Utilities.PhotoUpload({'mode': 'user', 'setProfile': true, 'recordId': RequestedUserID})
		return false;
	},
	onAddToFriendsClick : function (element) {
		if(typeof(CurrentUser)!='undefined' && CurrentUser.UserID != '0') {
			$.showWindowSK('window-add-to-friends', {
				ajax	:	'/pages/snippets/add_to_friends.php?friendUserId=' + RequestedUserID + '&friendUserName=' + encodeURI($(element).attr('username'))
			});
		} else {
			$('#window-loading').jqmHide();
			$.showWindowSK('window-login', {
				modal: true,
				ajax		: '/pages/snippets/login.php'
			}, function () {
				LoginSnippet.OnSuccess = function () {
					$('#window-login').jqmHide();
					$.showWindowSK('window-add-to-friends', {
						ajax	:	'/pages/snippets/add_to_friends.php?friendUserId=' + RequestedUserID + '&friendUserName=' + encodeURI($(element).attr('username'))
					});
				};
			});
		}
		return false;
	},
	onRemoveFromFriendsClick : function (element) {
		$.addLoadingBehaviour(element, {'text' : ''});
		var callParameters = {
			id		: 1,
			api		: 'User',
			command	: 'removeFriend',
			params	: {
				userId	: RequestedUserID
			}
		};
		$.postSK({
			data : {data:JSONstring.make(callParameters)},
			onsuccess : function (data) {
				$(element).removeLoadingBehaviour(false, function() {
					$('#action-add-to-friends').fadeIn();
				});
			}
		});
		return false;
	},
	onFlagClick : function () {
		Marvin.Utilities.Flag({'type': 'user', 'recordId': RequestedUserID});
		return false;
	}
}

// On DOM ready - Start
$(function() {
	$('#user-photo-add-link').click(UserProfile.General.EventHandlers.onPhotoAddClick);
	//if (CurrentUser.UserID == RequestedUserID) $('.container').addClass('ownerProfile');
	$('#action-add-to-friends').click(function() {UserProfile.General.EventHandlers.onAddToFriendsClick(this)});
	$('#action-remove-from-friends').click(function() {UserProfile.General.EventHandlers.onRemoveFromFriendsClick(this)});
	//$('#action-share').click(TrackProfile.General.EventHandlers.onShareClick);
	$('#action-flag').click(UserProfile.General.EventHandlers.onFlagClick);
});
// On DOM ready - End
