
  function find_wall_page(page_id)
  {
    $.ajax({
      url:"/commentMgt/find_comment",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        application_id: $('#user_id_id').val()
      },
      success: function(msg) {
        $('#user_wall_id').html(msg);
      }
    });
  }

  function remove_wall(wall_id)
  {
    if( confirm('是否删除该留言以及该留言下所有的回复？')==false )
      return false;
    else
    {
      $.ajax({
        url:"/commentMgt/remove_wall",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          wall_id: wall_id
        },
        success: function(msg) {
          if (msg=='session_is_null')
          {
            alert('您还没有登录，必须登录之后才能留言！');
          }
          else if(msg=='permit_is_not')
          {
            alert('不允许删除留言和留言下的回复！');
          }
          else if ( msg=='wall_is_not_exists' )
          {
            alert('该留言不存在！');
          }
          else
          {
            $('#user_wall_id').html(msg);
          }
        }
      });
    }
  }

  function reply_user_comment(reply_to_id, wall_id, comment_id)
  {
    if ( $.trim($('#'+comment_id).val()) == '' )
    {
      return;
    }
    else
    {
      var comment = $('#'+comment_id).val();
      while ( comment.indexOf("\n")!=-1 )
      {
        comment = comment.replace("\n", "<br>");
      }

      $.ajax({
        url:"/commentMgt/reply_user_comment",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          wall_id: wall_id,
          current_page_id: $('#wall_current_page_id_id').val(),
          comment: comment
        },
        success: function(msg) {
          if (msg=='session_is_null')
          {
            alert('您还没有登录，必须登录之后才能留言！');
          }
          else if(msg=='permit_from_comment')
          {
            alert('用户已经被禁止发表评论！');
          }
          else if (msg=='comment_too_long')
          {
            alert('留言内容不能超过1000个字！');
          }
          else
          {
            $('#user_wall_id').html(msg);
          }
        }
      });
    }
  }

  function post_user_comment()
  {
    if ( $.trim($('#user_comment_text_id').val()) == '' )
    {
      return;
    }
    else
    {
      var user_comment_text = $('#user_comment_text_id').val();
      while ( user_comment_text.indexOf("\n")!=-1 )
      {
        user_comment_text = user_comment_text.replace("\n", "<br>");
      }

      if ( document.getElementById('whisper_flag_id').checked == true )
      {
        $('#whisper_flag_id').attr('value', '1');
      }

      $.ajax({
        url:"/commentMgt/post_user_comment",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          application_id: $('#user_id_id').val(),
          user_comment_text: user_comment_text,
          whisper_flag: $('#whisper_flag_id').val()
        },
        success: function(msg) {
          if (msg=='session_is_null')
          {
            alert('您还没有登录，必须登录之后才能留言！');
          }
          else if(msg=='permit_from_comment')
          {
            alert('用户已经被禁止发表评论！');
          }
          else if (msg=='comment_too_long')
          {
            alert('留言内容不能超过1000个字！');
          }
          else
          {
            $('#user_comment_text_id').attr('value', '');
            $('#user_wall_id').html(msg);
          }
        }
      });
    }
  }

  function get_comment_view()
  {
      $.ajax({
        url:"/commentMgt/find_comment",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          application_id: $('#user_id_id').val()
        },
        success: function(msg) {
          $('#user_wall_id').html(msg);
        }
      });
  }

  function register_show(id)
  {
    $('#email_div_id').hide();
    $('#name_div_id').hide();
    $('#password_div_id').hide();
    $('#passconf_div_id').hide();
    $('#'+id).show();
  }

  function find_user_page(page_id)
  {
      $.ajax({
        url:"/userFunction/findUserPagination",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          current_page_id: page_id,
          page_size: 10,
          query_parameter: $('#query_parameter_id').val()
        },
        success: function(msg) {
          $('#user_pagination_id').html(msg);
          tb_init('a.thickbox, area.thickbox, input.thickbox');
        }
      });
  }

  function find_profile_friend(user_id, current_page_id)
  {
    $.ajax({
      url:"/userLogin/find_profile_friend",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: current_page_id,
        user_id: $('#user_id_id').val()
      },
      success: function(msg) {
        $('#friend_list_id').html(msg);
      }
    });
  }

  function query_users()
  {
      $.ajax({
        url:"/userFunction/findUserPagination",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          query_parameter: $('#query_parameter_id').val()
        },
        success: function(msg) {
          $('#user_pagination_id').html(msg);
          tb_init('a.thickbox, area.thickbox, input.thickbox');
        }
      });
  }

  function confirm_friendship(uid)
  {
    $.ajax({
      url:"/userFunction/confirm_friendship",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        user_id: uid
      },
      success: function(msg) {
        $('#request_confirm_helper').show();
        $('#request_pagination_id').html(msg);
      }
    });
  }

  function confirm_contributor(contributor_id)
  {
    $('<form action="" id="addContributorFormId" name="addContributorForm" method="POST"> <input type="hidden" name="contributor_id" value="'+contributor_id+'" /> </form>').appendTo('#content');

    document.addContributorForm.action = "/userFunction/confirm_contributor";
    document.addContributorForm.submit();
  }

  function ignore_friendship(uid)
  {
    $.ajax({
      url:"/userFunction/ignore_friendship",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        user_id: uid
      },
      success: function(msg) {
        $('#request_ignore_helper').show();
        $('#request_pagination_id').html(msg);
      }
    });
  }

  function get_friend_view(friend_id)
  {
    $.ajax({
      url:"/friend/friendMgt/check_user_is_myfriend",
      async:false,
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        friend_id: friend_id
      },
      success: function(msg) {
        if (msg == "yes")
        {
          alert('您已经发送过好友请求，正在等待对方确认！');
          return;
        }
        else if (msg == "friend")
        {
          alert('你们已经是朋友！');
          return;
        }
        else if (msg == "self")
        {
          alert('您不能加自己为好友');
          return;
        }
        else if (msg == "not")
        {
          $('<input type="hidden" name="friend_id" value="'+friend_id+'" />').appendTo('#friendViewForm');
          $('<input type="hidden" name="query_parameter" value="'+$('#query_parameter_id').val()+'" />').appendTo('#friendViewForm');
          document.getElementById('friendViewForm').submit();
        }
        else if (msg == "session_is_null")
        {
          alert("您已经长时间没有进行操作或没有登录系统，请重新登录！");
          var login_form_str = '<form action="" name="logoutForm" method="POST"></form>';
          $(login_form_str).appendTo('#content');
          document.logoutForm.action = "/logout";
          document.logoutForm.submit();
        }
      }
    });
  }

  function cancle_add_friend_view()
  {
    $('#addFriendForm').attr('action', '/userFunction/find_users');
    $('#addFriendForm').submit();
  }

  function save_my_signature()
  {
    $.ajax({
      url:"/userFunction/save_my_signature",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        about_me: $('#about_me1').val(),
        user_id: $('#user_id_id').val()
      },
      success: function(msg) {
        $('#about_me').attr('value', $('#about_me1').val());
        $('#edit_signature').hide();
        $('#read_signature').show();
        $('#group_image_message').html(msg);
        $('#group_image_helper').show();

      }
    });
  }

  function upload_profile_image()
  {
    if ($('#userfileId').val() == '')
    {
      alert('请您选择上传的图片');
      $('#userfileId').focus();
      return;
    }
    else if ( /jpg|jpeg|gif|png|bmp/i.test( $('#userfileId').val().match(/\.(\w+)$/)[0] )==false )
    {
      alert("您只能上传图片文件");
      return false;
    }

    $.ajaxFileUpload({
      url:'/userupload/upload/do_upload',
      secureuri:false,
      fileElementId:'userfileId',
      dataType: 'html',
      success: function (data)
      {
        var image_src = data;
        $('#profile_image_id').attr('src', data);
      },
      error: function (data, status, e)
      {
        alert(status);
      }
    });
  }

  function find_message_page(page_id)
  {
    url = '/mailbox/mailboxMgt/find_my_accepte_message';
    $.ajax({
      url: url,
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id
      },
      success: function(msg) {
        $('#accept_mailbox_pagination_id').html(msg);
        tb_init('a.thickbox, area.thickbox, input.thickbox');
      }
    });
  }

  function find_send_message_page(page_id)
  {
    url = '/mailbox/mailboxMgt/find_my_send_message';
    $.ajax({
      url: url,
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id
      },
      success: function(msg) {
        $('#send_mailbox_pagination_id').html(msg);
        tb_init('a.thickbox, area.thickbox, input.thickbox');
      }
    });
  }

  function save_username()
  {
    var username = $.trim( $('#username_id').val() );
    if ( username=='' )
    {
      $('#edit_full_name').show();
      $('#save_full_name').hide();
      alert('名字不能为空！');
      return;
    }
    else
    {
      $.ajax({
        url: '/accountMgt/save_username',
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          username: username
        },
        success: function(msg) {
          if ( msg.substr(0, 1)=='Y' )
          {
            $('#edit_full_name_id').html(username);
            $('#edit_full_name').show();
            $('#save_full_name').hide();
            $('#group_image_message').html(msg.substr(1));
          }
          else
          {
            $('#group_image_message').html(msg);
          }
          $('#group_image_helper').show();
        }
      });
    }
  }

  function save_email()
  {
    var email = $.trim( $('#email_id').val() );
    if ( email=='' )
    {
      $('#edit_email').show();
      $('#save_email').hide();
      alert('邮件不能为空！');
      return;
    }
    else
    {
      $.ajax({
        url: '/accountMgt/save_email',
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          email: email
        },
        success: function(msg) {
          if ( msg.substr(0, 1)=='Y' )
          {
            $('#edit_email_id').html(email);
            $('#edit_email').show();
            $('#save_email').hide();
            $('#group_image_message').html( msg.substr(1) );
          }
          else
          {
            $('#group_image_message').html(msg);
          }
          $('#group_image_helper').show();
        }
      });
    }
  }

  function change_password()
  {
    var old_password = $.trim( $('#old_password_id').val() );
    var password = $.trim( $('#new_password_id').val() );
    var passconf = $.trim( $('#confirm_password_id').val() );

    $.ajax({
      url: '/accountMgt/change_password',
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        password: password,
        passconf: passconf,
        old_password: old_password
      },
      success: function(msg) {
        $('#edit_password').show();
        $('#save_password').hide();
        $('#group_image_message').html(msg);
        $('#group_image_helper').show();
      }
    });
  }

  function find_recent_view_list()
  {
    $.ajax({
      url: '/userLogin/find_recent_view_list',
      type:"post",
      dataType:"html",
      async:false,
      timeout:20000,
      data: {
        type:'1'
      },
      success: function(msg) {
        $('#recent_view_id').html(msg);
      }
    });
  }

