var gBlockUserId;
var gBlockDivId;
function blockUser( otherUserId, otherUserName, hasRelationship, divId )
{
  var confirmMsg = 'Blocking will prevent Notifications from ' + otherUserName + ' and prevent you from adding ' + otherUserName + ' to your friends and favorites list. Are you sure you want to continue?';
  if( hasRelationship )
  {
    confirmMsg = 'Blocking will prevent Notifications from ' + otherUserName + ' and remove ' + otherUserName + ' from your Friends and/or Favorites lists. Are you sure you want to continue?';
  }
  if( !confirm( confirmMsg ) )
  {
    return;
  }
  gBlockUserId = otherUserId;
  gBlockDivId = divId;
  var url = '/manageUserNetworkController.dobbb?op=blockUser';
  var params = 'otherUserId=' + otherUserId + "&otherUserName=" + otherUserName;
  ajaxRequest( url,
               params,
               onSuccessBlockUser );
}
function removeUserBlock( otherUserId, otherUserName )
{
  if( !confirm('Are you sure you want to remove the block on ' + otherUserName + '?') )
  {
    return;
  }
  gBlockUserId = otherUserId;
  var url = '/manageUserNetworkController.dobbb?op=removeUserBlock';
  var params = 'otherUserId=' + otherUserId + "&otherUserName=" + otherUserName;
  ajaxRequest( url,
               params,
               onSuccessRemoveBlock );
}
function onSuccessRemoveBlock( request )
{
  reportAjaxSuccessInline( request.responseText );
  $( 'removeUserBlockLink' + gBlockUserId ).style.display = 'none';
  $( 'blockUserLink' + gBlockUserId ).style.display = 'block';
  //re-show the "add" links"
  var addFriendLink = $( 'addFriendLink' + gBlockUserId );
  var addToFavoriteLink = $( 'addToFavoriteLink' + gBlockUserId );
  //alert(' addfriend = ' + addFriendLink + ', addfAv' + addToFavoriteLink );
  $( 'addFriendLink' + gBlockUserId ).style.display = 'block';
  $( 'addToFavoriteLink' + gBlockUserId ).style.display = 'block';
}
function onSuccessBlockUser( request )
{
  reportAjaxSuccessInline( request.responseText );
  hideElement( gBlockDivId );
  $( 'removeUserBlockLink' + gBlockUserId ).style.display = 'block';
  $( 'blockUserLink' + gBlockUserId ).style.display = 'none';
  //also hide the friend and favorite links
  $( 'removeFriendLink' + gBlockUserId ).style.display = 'none';
  $( 'addFriendLink' + gBlockUserId ).style.display = 'none';
  $( 'pendingFriendLink' + gBlockUserId ).style.display = 'none';
  $( 'acceptFriendLink' + gBlockUserId ).style.display = 'none';
  $( 'removeFavoriteLink' + gBlockUserId ).style.display = 'none';
  $( 'addToFavoriteLink' + gBlockUserId ).style.display = 'none';
}
