
  function flash_embed_url(book_id)
  {
	if ( confirm('是否重新产生外链地址？')==true )
    {
		$.ajax({
		  url:"/book/bookMgt/flash_embed_url",
		  type:"post",
		  async:false,
		  dataType:"html",
		  timeout:20000,
		  data: {
			book_id: book_id
		  },
		  success: function(msg) {
			alert('已经产生外链地址');
		  }
		});
	}
	else
	    return;
  }

  function find_by_book_tag(tag_name)
  {
    var form_str = '<form action="/explore/exploreMgt/find_by_tag" id="search_group_form_id" name="search_group_form" method="POST"><input type="hidden" name="tag_name" value="'+tag_name+'" /></form>';
    $(form_str).appendTo('#content');

    document.search_group_form.submit();
  }

  function select_theme_for_book(theme_id, theme_name)
  {
    var old_theme_id = $('#theme_id_id').val();
    $('#theme_model_id_'+old_theme_id).removeClass('theme_selected');

    $('#theme_id_id').attr('value', theme_id);
    $('#theme_model_id_'+theme_id).addClass('theme_selected');

    var message = '您选择了（<span class="font_blue">' + theme_name + '</span>），在编辑过程中可以继续修改主题模板！'
    $('#message_show_id').html(message);
    $('#select_theme_helper').show();
  }

  function toggleOnOff(open, close)
  {
    $('#' + open).css('display', 'block');
    $('#' + close).css('display', 'none');
  }

  function select_my_shelf()
  {
    $.ajax({
      url:"/book/shelfMgt/findShelfPagination",
      type:"post",
      async:false,
      dataType:"html",
      timeout:20000,
      data: {
        query_parameter: 'hello'
      },
      success: function(msg) {
        $('#shelf_pagination_id').html(msg);
        $('#shelf_flag_id').attr('value', 'yes');
      }
    });
  }

  function find_shelf_page(page_id)
  {
    $.ajax({
      url:"/book/shelfMgt/findShelfPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: $('#shelf_page_size_id').val(),
        shelf_type: $('#shelf_type_id').val(),
        enter_shelf: $('#enter_shelf_id').val()
      },
      success: function(msg) {
        $('#shelf_pagination_id').html(msg);
      }
    });
  }

  function find_shelf_book_page(page_id)
  {
    $.ajax({
      url:"/book/shelfMgt/findShelfBookPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: $('#book_page_size_id').val(),
        shelf_id: $('#shelf_id_id').val(),
        shelf_current_page_id: $('#shelf_current_page_id_id').val(),
        enter_shelf: $('#enter_shelf_id').val()
      },
      success: function(msg) {
        $('#shelf_pagination_id').html(msg);
      }
    });
  }

  function select_my_book(image_id)
  {
    $.ajax({
      url:"/book/bookMgt/findBookPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        type: 1
      },
      success: function(msg) {
        $('#book_pagination_id0').html(msg);
      }
    });
  }

  function find_books(type)
  {
    $.ajax({
      url:"/book/bookMgt/findBookPagination",
      type:"post",
      async:false,
      dataType:"html",
      timeout:20000,
      data: {
        book_query_type:type
      },
      success: function(msg) {
        if ( type!=null )
        {
          $('#book_query_type_id').attr('value', type);
          if ( type=='1' )
          {
            $('#book_published_pagination_id').html(msg);
            $('#published_book_flag_id').attr('value', 'yes');
          }
          else if ( type=='2' )
          {
            $('#book_contribute_pagination_id').html(msg);
            $('#contribute_book_flag_id').attr('value', 'yes');
          }
          else
          {
            $('#book_pagination_id0').html(msg);
            $('#edit_book_flag_id').attr('value', 'yes');
          }
        }
        else
        {
          $('#book_pagination_id0').html(msg);
          $('#edit_book_flag_id').attr('value', 'yes');
        }

		tb_init('a.thickbox, area.thickbox, input.thickbox');
      }
    });
  }

  function find_all_my_books()
  {
    $.ajax({
      url:"/book/bookMgt/findBookPagination",
      type:"post",
      async:false,
      dataType:"html",
      timeout:20000,
      data: {
        book_query_type:'1'
      },
      success: function(msg) {
        $('#book_pagination_id0').html(msg);
      }
    });

    $('#book_in_editing').hide();
    $('#all_books').show();
    $('#book_not_in_shelf').hide();
  }

  function find_books_not_in_shelf()
  {
    $.ajax({
      url:"/book/bookMgt/findBookPagination",
      type:"post",
      async:false,
      dataType:"html",
      timeout:20000,
      data: {
        book_query_type:'2'
      },
      success: function(msg) {
        $('#book_pagination_id0').html(msg);
      }
    });

    $('#book_in_editing').hide();
    $('#all_books').hide();
    $('#book_not_in_shelf').show();
  }

  function find_book_page(page_id)
  {
    var type = $('#book_query_type_id').val();
    $.ajax({
      url:"/book/bookMgt/findBookPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: 5,
        book_query_type: type,
        user_id: $('#user_id_id').val()
      },
      success: function(msg) {
        if ( type!=null )
        {
          if ( type=='1' )
          {
            $('#book_published_pagination_id').html(msg);
            $('#published_book_flag_id').attr('value', 'yes');
          }
          else if ( type=='2' )
          {
            $('#book_contribute_pagination_id').html(msg);
            $('#contribute_book_flag_id').attr('value', 'yes');
          }
          else
          {
            $('#book_pagination_id0').html(msg);
            $('#edit_book_flag_id').attr('value', 'yes');
          }
        }
        else
        {
          $('#book_pagination_id0').html(msg);
          $('#edit_book_flag_id').attr('value', 'yes');
        }

        tb_init('a.thickbox, area.thickbox, input.thickbox');
      }
    });
  }

  function find_profile_book_page(page_id)
  {
    var type = $('#book_query_type_id').val();
    $.ajax({
      url:"/userLogin/find_profile_book_page",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: 16,
        book_query_type: type,
        user_id: $('#user_id_id').val()
      },
      success: function(msg) {
        $('#book_pagination_id0').html(msg);
      }
    });
  }

  function enter_shelf(book_id)
  {
    window.open('/book/shelfMgt/queryShelf/'+book_id, 'newwindow', 'height=400, width=400, top=200, left=300, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no');
  }

  function update_shelf(shelf_id)
  {
    document.shelfForm.action = "/book/shelfMgt/editShelf";
    $('#shelf_id_id').attr("value", shelf_id);
    document.shelfForm.submit();
  }

  function edit_book_ignore_order(book_id)
  {
    edit_the_book(book_id, 'yes');
  }

  function edit_book(book_id)
  {
    edit_the_book(book_id, '');
  }

  function edit_the_book(book_id, ignore_order)
  {
    var form_str = '<form action="/book/bookMgt/editBook" id="bookSubmitFormId" name="bookSubmitForm" method="POST"><input type="hidden" name="book_id" value="'+book_id+'" /><input type="hidden" name="ignore_order" value="'+ignore_order+'" /></form>';
    $(form_str).appendTo('#content');

    var login_form_str = '<form action="" name="logoutForm" method="POST"></form>';
    $(login_form_str).appendTo('#content');

    $.ajax({
      url:"/book/bookMgt/book_is_locked",
      async:false,
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id
      },
      success: function(msg)
      {
        var sign = msg.substr(0, 1);
        if (sign == "Y")
        {
          var locker = msg.substr(1);
          alert(locker+' 正在编辑该书，请稍候！');
          return;
        }
        else if(msg == "self")
        {
          if ( confirm('您已经在其他浏览器中编辑该书。是否失效此浏览器？')==true )
          {
            document.bookSubmitForm.action = "/book/bookMgt/editBook";
            document.bookSubmitForm.submit();
          }
          else
            return;
        }
        else if(sign == "N")
        {
          document.bookSubmitForm.action = "/book/bookMgt/editBook";
          document.bookSubmitForm.submit();
        }
        else if(msg == 'session_is_null')
        {
          alert("您已经长时间没有进行操作或没有登录系统，请重新登录！");

          document.logoutForm.action = "/logout";
          document.logoutForm.submit();
        }
        else
        {
          alert("请您重新登录！");

          document.logoutForm.action = "/logout";
          document.logoutForm.submit();
        }
      },
      error: function(obj, msg, ex) {
        alert(ex);
      }
    });

  }

  function query_books_in_shelf(shelf_id)
  {
    var url = "/book/shelfMgt/findBooks";

    $.ajax({
      url:url,
      type:"post",
      dataType:"html",
      async:false,
      timeout:5000,
      data: {
        shelf_id: shelf_id,
        shelf_current_page_id: $('#shelf_current_page_id_id').val(),
        enter_shelf: $('#enter_shelf_id').val()
      },
      success: function(msg) {
        $('#shelf_flag_id').attr('value', 'no');
        $('#shelf_pagination_id').html(msg);
      }
    });
  }

  function queryBookShelf(shelf_id)
  {
    var url = "/book/shelfMgt/queryBookShelf";
    var form_str = '<form action="" id="queryBookShelfFormId" name="queryBookShelfForm" method="POST"> <input type="hidden" name="shelf_id" value="'+shelf_id+'" /> <input type="hidden" name="shelf_current_page_id" value="1" /> </form>';
    $(form_str).appendTo('#content');

    document.queryBookShelfForm.action = "/book/shelfMgt/queryBookShelf";
    document.queryBookShelfForm.submit();
  }

  function select_my_collection()
  {
    $.ajax({
      url:"/book/shelfMgt/find_collection_books",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_query_type: '1'
      },
      success: function(msg) {
        $('#collection_pagination_id').html(msg);
        $('#collection_flag_id').attr('value', 'yes');
      }
    });
  }

  function find_collection_book_page(page_id)
  {
    $.ajax({
      url:"/book/shelfMgt/find_collection_book_pagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: $('#book_page_size_id').val()
      },
      success: function(msg) {
        $('#collection_pagination_id').html(msg);
      }
    });
  }

  function delete_collection(book_id, current_page_id)
  {
    if (confirm('您确定不再收藏该书')==true)
    {
      $.ajax({
        url:"/book/shelfMgt/delete_collection",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          book_id: book_id,
          current_page_id: current_page_id
        },
        success: function(msg) {
          $('#collection_pagination_id').html(msg);
        }
      });
    }
  }

  function hide_or_show(image_id)
  {
    $('#book_indicate_img').attr('src', 'http://static.qidimo.com/images/arrow1.jpg');
    $('#shelf_indicate_img').attr('src', 'http://static.qidimo.com/images/arrow1.jpg');
    $('#collection_indicate_img').attr('src', 'http://static.qidimo.com/images/arrow1.jpg');

    $('#'+image_id).attr('src', 'http://static.qidimo.com/images/arrow.jpg');
  }

  function query_myshelf()
  {
    document.shelfForm.action = "/book/shelfMgt/findSepecialShelves";
    document.shelfForm.shelf_type.value = "1";
    document.shelfForm.submit();
  }

  function query_mycollection()
  {
    document.shelfForm.action = "/book/shelfMgt/findSepecialShelves";
    document.shelfForm.shelf_type.value = "2";
    document.shelfForm.submit();
  }

  function createNewBook()
  {
    document.shelfForm.action = "/book/bookMgt";
    document.shelfForm.submit();
  }

  function get_shelf_view(shelf_id)
  {
    if (shelf_id!=null)
    {
      $('#current_shelf_id_id').attr('value', shelf_id);
    }

    $.ajax({
      url:"/book/shelfMgt/get_shelf_view",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        shelf_id: shelf_id,
        current_page_id: $('#shelf_current_page_id_id').val()
      },
      success: function(msg) {
        $('#create_new_shelf_id').html(msg);
        $('#shelf_pagination_id').hide();
        $('#create_new_shelf_id').show();

        $("input.file_1").stylefile({
          image: "/images/browse.gif",
          imageheight : 30,
          imagewidth : 60,
          width : 165,
          height: 22
        });
      }
    });
  }

  function createNewShelf()
  {
    $.ajax({
      url:"/book/shelfMgt/createNewShelf",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        shelf_id: $('#shelf_id_id').val(),
        name: $('#shelf_name_id').val(),
        cover_image: $('#image_key').val()
      },
      success: function(msg) {
        $('#create_new_shelf_id').html(msg);

        $("input.file_1").stylefile({
          image: "/images/browse.gif",
          imageheight : 30,
          imagewidth : 60,
          width : 165,
          height: 22
        });
      }
    });
  }

  function deleteShelf(shelf_id)
  {
    if (confirm('您确定要删除该书架吗？'))
    {
      var url = "/book/shelfMgt/delete_shelf";

      $.ajax({
        url:url,
        type:"post",
        dataType:"html",
        timeout:5000,
        data: {
          shelf_id: shelf_id
        },
        success: function(msg) {
          $('#shelf_pagination_id').html(msg);
        }
      });
    }
  }

  function put_into_shelf(shelf_id)
  {
    if (shelf_id == '')
    {
      alert('请选择书架');
      return;
    }

    $('<input type="hidden" name="shelf_id" value="'+shelf_id+'" />').appendTo('#inputFormId');
    document.getElementById('inputFormId').action = '/book/shelfMgt/enter_shelf';
    document.getElementById('inputFormId').submit();
  }

  function upload_shelf_image(shelf_id)
  {
    if ($('#fileToUpload').val() == '')
    {
      alert('请您选择上传的图片');
      $('#fileToUpload').focus();
      return;
    }
    else if ( /jpg|jpeg|png|gif|bmp/i.test( $('#fileToUpload').val().match(/\.(\w+)$/)[0] )==false )
    {
      alert("您只能上传图片文件");
      return false;
    }

    var url = "/book/upload/do_upload/"+shelf_id;
    $.ajaxFileUpload({
      url: url,
      secureuri:false,
      fileElementId:'fileToUpload',
      dataType: 'html',
      success: function (data)
      {
        dataarray = data.split(";");
        $('#profile').attr("src", dataarray[0]);
        $('#shelf_id').attr("value", dataarray[1]);
        $('#image_key').attr("value", dataarray[2]);
      },
      error: function (data, status, e)
      {
        alert(status);
      }
    });
  }

  function remove_book_from_shelf(book_id, shelf_id, current_page_id)
  {
    if ( confirm('您确定要移除该书')==false )
    {
      return;
    }

    $.ajax({
      url:"/book/shelfMgt/remove_book_from_shelf",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id,
        shelf_id: shelf_id,
        current_page_id: current_page_id
      },
      success: function(msg) {
        $('#shelf_pagination_id').html(msg);
      },
      error: function(obj, msg, ex) {
        alert(ex);
      }
    });
  }

  function delete_book(book_id, current_page_id)
  {
    if ( confirm('您确定要删除该书')==false )
    {
      return;
    }

    var type = $('#book_query_type_id').val();
    $.ajax({
      url:"/book/bookMgt/deleteBook",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id,
        current_page_id: current_page_id,
        book_query_type: type
      },
      success: function(msg) {
        if ( type!=null )
        {
          if ( type=='1' )
          {
            $('#book_published_pagination_id').html(msg);
            $('#published_book_flag_id').attr('value', 'yes');
          }
          else if ( type=='2' )
          {
            $('#book_contribute_pagination_id').html(msg);
            $('#contribute_book_flag_id').attr('value', 'yes');
          }
          else
          {
            $('#book_pagination_id0').html(msg);
            $('#edit_book_flag_id').attr('value', 'yes');
          }
        }
        else
        {
          $('#book_pagination_id0').html(msg);
          $('#edit_book_flag_id').attr('value', 'yes');
        }

        tb_init('a.thickbox, area.thickbox, input.thickbox');
      },
      error: function(obj, msg, ex) {
        alert(ex);
      }
    });
  }

  function choose_query_book()
  {
    if ($('#book_query_type_id').val()=='0')
    {
      $('#book_in_editing').show();
      $('#all_books').hide();
      $('#book_not_in_shelf').hide();
    }
    else if ($('#book_query_type_id').val()=='1')
    {
      $('#book_in_editing').hide();
      $('#all_books').show();
      $('#book_not_in_shelf').hide();
    }
    else
    {
      $('#book_in_editing').hide();
      $('#all_books').hide();
      $('#book_not_in_shelf').show();
    }
  }

  function get_book_view(book_id, current_page_id, book_query_type)
  {
    $('<input type="hidden" name="book_id" value="'+book_id+'" />').appendTo('#bookViewForm');
    $('<input type="hidden" name="current_page_id" value="'+$('#book_current_page_id_id').val()+'" />').appendTo('#bookViewForm');
    $('<input type="hidden" name="book_query_type" value="'+$('#book_query_type_id').val()+'" />').appendTo('#bookViewForm');
    document.getElementById('bookViewForm').submit();
  }

  function public_new_book(book_id)
  {
    $('<input type="hidden" name="book_id" value="'+book_id+'" />').appendTo('#bookViewForm');
    $('<input type="hidden" name="current_page_id" value="'+$('#book_current_page_id_id').val()+'" />').appendTo('#bookViewForm');
    $('<input type="hidden" name="book_query_type" value="'+$('#book_query_type_id').val()+'" />').appendTo('#bookViewForm');
    $('<input type="hidden" name="public_new_book" value="true" />').appendTo('#bookViewForm');
    document.getElementById('bookViewForm').submit();
  }

  function clear_book_tag_list()
  {
    if ($.trim( $('#book_tag_list').val() )=='')
      $('#book_tag_list').attr('value', '标签请空格分开');
    else
      if ($.trim( $('#book_tag_list').val() )=='标签请空格分开' )
        $('#book_tag_list').attr('value', '');
  }

  function update_book()
  {
    document.getElementById('newBookForm').action = '/book/bookMgt/updateBook';
    document.getElementById('newBookForm').submit();
  }

  function checkAllGroups(check)
  {
		var allInputs = document.getElementsByTagName('input');
		for(i=0;i<allInputs.length;i++)
		{
			if(allInputs[i].name=='groups')
			{
				allInputs[i].checked=check;
			}
		}
  }

  function get_groups()
  {
    var groupStr = '';

		var allInputs = document.getElementsByTagName('input');
		for (i=0; i<allInputs.length; i++)
		{
			if(allInputs[i].name=='groups' && allInputs[i].checked)
			{
        groupStr += allInputs[i].value;
        groupStr += ':';

        var d = document.getElementsByName('radio_name_'+allInputs[i].value);
        for (j=0; j<d.length; j++)
        {
          if ( d[j].checked)
            groupStr = groupStr + d[j].value;
          else
            groupStr += '0';
        }
        groupStr += ';';
      }
		}

    return groupStr;
  }

  function set_groups(book_id)
  {
    var group_list_str = get_groups();

    $.ajax({
      url:"/book/bookMgt/set_groups",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id,
        group_list_str: group_list_str
      },
      success: function(msg) {
        $('#book_group_id').html(msg);
        $('#set_groups_id').show();
      }
    });
  }

  function return_shelf_list()
  {
    $.ajax({
      url:"/book/shelfMgt/findShelfPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: $('#shelf_current_page_id_id').val(),
        shelf_type: 0,
        enter_shelf: $('#enter_shelf_id').val()
      },
      success: function(msg) {
        $('#shelf_pagination_id').html(msg);
        $('#shelf_pagination_id').show();
        $('#create_new_shelf_id').hide();
      }
    });
  }

  function post_book_comment()
  {
    if ( $.trim($('#book_comment_text_id').val()) == '' )
    {
      $('#add_comment_form').hide();
      return;
    }
    else
    {
      book_comment_text = $('#book_comment_text_id').val();
      while ( book_comment_text.indexOf("\n")!=-1 )
      {
        book_comment_text = book_comment_text.replace("\n", "<br>");
      }

      $.ajax({
        url:"/book/bookMgt/post_book_comment",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          book_id: $('#book_id_id').val(),
          book_comment_text: book_comment_text
        },
        success: function(msg) {
          if (msg=='session_is_null')
          {
            var login_form = '<form action="" name="loginForm" method="POST"></form>';
            $(login_form).appendTo('#content');

            document.loginForm.action = "/userLogin/onLogin";
            document.loginForm.submit();
          }
          else if(msg=='permit_from_comment')
          {
            alert('用户已经被禁止发表评论！');
          }
          else if (msg=='comment_too_long')
          {
            alert('评论内容不能超过1000个字！');
          }
          else
          {
            $('#project_comments').hide();
            $('#add_comment_form').hide();
            $('#book_comment_text_id').attr('value', '');
            $('#book_comment_list').html(msg);
            tb_init('a.thickbox, area.thickbox, input.thickbox');
          }
        }
      });
    }
  }

  function find_bookcomment_page(index)
  {
    var regex = /^[0-9]*[1-9][0-9]*$/;
    var flag = regex.test( $.trim(''+index) );

    if ( !flag )
    {
      alert('数量必须是大于0的整数');
      $('#index_id').focus();
    }
    else
    {
      $.ajax({
        url:"/book/bookMgt/find_book_comment_pagination",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          book_id: $('#book_id_id').val(),
          current_page_id: index,
          page_size: $('#bookcomment_page_size_id').val()
        },
        success: function(msg) {
          $('#project_comments').hide();
          $('#add_comment_form').hide();
          $('#book_comment_list').html(msg);
          tb_init('a.thickbox, area.thickbox, input.thickbox');
        }
      });
    }
  }

  function add_rate(book_id)
  {
    $.ajax({
      url:"/book/bookMgt/add_rate",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id
      },
      success: function(msg) {
        $('#add_rate_ref_id').hide();
        $('#rating_stars').html(msg);
      }
    });
  }

  function collect_book(book_id)
  {
    var url = "/book/shelfMgt/collect_book";

    $.ajax({
      url:url,
      type:"post",
      dataType:"html",
      timeout:5000,
      data: {
        book_id: book_id
      },
      success: function(msg) {
        if ( msg=='session_is_null' )
        {
          alert( '登录之后才能收藏书籍, 谢谢！' );
        }
        else if ( msg=='book_not_exist' )
        {
          alert( '该书不存在！' );
        }
        else
        {
          alert( '已经收藏该书籍！' );
        }
       }
    });
  }

  function generate_book_cover_image(book_id, book_cover_image_id)
  {
    var url = "/book/bookMgt/generate_book_cover_image";

    $.ajax({
      url:url,
      type:"post",
      async: false,
      dataType:"html",
      timeout:10000,
      data: {
        book_id: book_id
      },
      success: function(msg) {
        $('#'+book_cover_image_id).attr('src', msg);
      },
      error: function(obj, msg, ex) {
        alert(ex);
      }
    });
  }

  function delete_comment(comment_id)
  {
    if ( confirm('确定要删除这条评论?')==true )
    {
      var url = "/book/bookMgt/delete_comment";

      $.ajax({
        url:url,
        type:"post",
        dataType:"html",
        timeout:5000,
        data: {
          book_id: $('#book_id_id').val(),
          comment_id: comment_id
        },
        success: function(msg) {
          $('#book_comment_list').html(msg);
        }
      });
    }
    else
    {
      return;
    }
  }

  function addRemoveFriend(userId)
  {
  }

  function selectFriend(userId)
  {
    if ( !$('#user_'+userId).disabled )
    {
      toggleFriendLabel(userId);
    }
  }

  function toggleFriendLabel(userId)
  {
    if ( $('#user_'+userId).val()=='1' )
    {
      $('#label_'+userId).removeClass('friends_select');
      $('#user_'+userId).attr('value', '0');
    }
    else
    {
      $('#label_'+userId).addClass('friends_select');
      $('#user_'+userId).attr('value', '1');
    }
  }

  function selectAllFriends(check)
  {
		var allInputs = document.getElementsByTagName('input');
		for(i=0;i<allInputs.length;i++)
		{
			if(allInputs[i].name=='contributor_friends')
			{
				allInputs[i].checked=check;
			}
		}
  }

  function contributor_list()
  {
    var friendStr = '';

		var friendNames = document.getElementsByTagName('input');
		for (i=0; i<friendNames.length; i++)
		{
			if(friendNames[i].name=='contributor_friends' && friendNames[i].checked)
			{
        var userId = friendNames[i].value;
        friendStr += userId;
        friendStr += ':';

        var d = document.getElementsByName('contributor_radio_name_'+userId);
        for (j=0; j<d.length; j++)
        {
          if ( d[j].checked)
          {
            if ( d[j].id=='contributor_read_'+userId )
              friendStr = friendStr + d[j].value + '0';
            else
              friendStr = friendStr + '0' + d[j].value;

            if ( document.getElementById('print_allowed_'+userId).checked )
              friendStr = friendStr + document.getElementById('print_allowed_'+userId).value;
            else
              friendStr = friendStr + '0';
          }
        }

        friendStr += ';';
      }
		}

    return friendStr;
  }

  function set_contributor(book_id)
  {
    var contributor_list_str = contributor_list();

    $.ajax({
      url:"/book/bookMgt/set_contributor",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id,
        contributor_list_str: contributor_list_str
      },
      success: function(msg) {
        $('#book_contribute_id').html(msg);
        $('#set_contributor_id').show();
      }
    });
  }

  function find_contributor_page(page_id)
  {
    $.ajax({
      url:"/userFunction/findContributorPagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: $('#contributor_page_size_id').val()
      },
      success: function(msg) {
        $('#request_pagination_id').html(msg);
      }
    });
  }

  function add_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 = "/book/bookMgt/add_contributor";
    document.addContributorForm.submit();
  }

  function ignore_contributor(contributor_id)
  {
    $.ajax({
      url:"/userFunction/ignore_contributor",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        contributor_id: contributor_id,
        current_page_id: $('#contributor_current_page_id_id').val(),
        page_size: $('#contributor_page_size_id').val()
      },
      success: function(msg) {
        $('#request_pagination_id').html(msg);
      }
    });
  }

  function public_book(book_id)
  {
    $.ajax({
      url:"/book/bookMgt/public_book",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id
      },
      success: function(msg) {
        $('#handle_book_message_id').html(msg);
        $('#handle_book_id').show();
      }
    });
  }

  function order_view(book_id)
  {
    $('<form action="/book/bookMgt/editBook" id="bookSubmitFormId" name="bookSubmitForm" method="POST"> <input type="hidden" name="book_id" value="'+book_id+'" /> </form>').appendTo('#content');

    document.bookSubmitForm.action = "/orderMgt";
    document.bookSubmitForm.submit();
  }

  function find_hot_book_pagination(current_page_id)
  {
    $.ajax({
      url:"/userLogin/find_hot_book_pagination",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: current_page_id
      },
      success: function(msg) {
        $('#hot_book_id').html(msg);
      }
    });
  }

  function show_shelf_information(b_id, book_image_id)
  {
    var pos = getElementPos(book_image_id);
    var left_pos = pos['x']-50;
    var top_pos= pos['y']-50;
    $('#'+b_id).css('top', top_pos+'px');
    $('#'+b_id).css('left', left_pos+'px');
    $('#'+b_id).show();
  }

  function find_relative_books(page_id)
  {
    $.ajax({
      url:"/book/bookMgt/find_relative_books",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        current_page_id: page_id,
        page_size: $('#book_page_size_id').val(),
        book_id: $('#book_id_id').val(),
        from: $('#from_id').val()
      },
      success: function(msg) {
        $('#relative_book_id').html(msg);
      }
    });
  }

  function show_comment_form()
  {
    $.ajax({
      url:"/book/bookMgt/show_comment_form",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: $('#book_id_id').val()
      },
      success: function(msg) {
        if (msg=='session_is_null')
        {
          alert('请您在登录之后再发表评论，谢谢！');
        }
        else if(msg=='permit_from_comment')
        {
          alert('用户已经被禁止发表评论！');
        }
        else
        {
          $('#add_comment_form').show();
        }
      }
    });
  }

  function selected_user_list()
  {
    var friendStr = '';

		var friendNames = document.getElementsByTagName('input');
		for (i=0; i<friendNames.length; i++)
		{
			if(friendNames[i].name=='contributor_friends')
			{
        var userId = friendNames[i].value;
        friendStr += userId;
        friendStr += ':';
      }
		}

    return friendStr;
  }

  function selected_group_list()
  {
    var groupStr = '';

		var allInputs = document.getElementsByTagName('input');
		for (i=0; i<allInputs.length; i++)
		{
			if(allInputs[i].name=='groups')
			{
        groupStr += allInputs[i].value;
        groupStr += ':';
      }
		}

    return groupStr;
  }

  function select_group(group_id, book_id)
  {
    var selected_group = selected_group_list();

    if (group_id=='0')
    {
      return;
    }
    else
    {
      $.ajax({
        url:"/groups/groupMgt/select_group",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          group_id: group_id,
          book_id: book_id,
          selected_group: selected_group
        },
        success: function(msg) {
          if ( msg=='yes' )
            alert('该用户已经添加到合作者列表！');
          else
            $(msg).appendTo('#group_listing_id');
        }
      });
    }
  }

  function select_user(user_id, book_id)
  {
    var selected_user = selected_user_list();

    if (user_id=='0')
    {
      return;
    }
    else
    {
      $.ajax({
        url:"/friend/friendMgt/select_user",
        type:"post",
        dataType:"html",
        timeout:20000,
        data: {
          user_id: user_id,
          book_id: book_id,
          selected_user: selected_user
        },
        success: function(msg) {
          if ( msg=='yes' )
            alert('该用户已经添加到合作者列表！');
          else
            $(msg).appendTo('#contribute_listing_id');
        }
      });
    }
  }

  function copy_book(book_id, book_query_type)
  {
    $('#copy_book_id').show();
    $.ajax({
      url:"/book/bookMgt/copy_book",
      type:"post",
      dataType:"html",
      timeout:20000,
      data: {
        book_id: book_id,
        book_query_type: book_query_type
      },
      success: function(msg) {
        if ( book_query_type == '0' )
        {
          $('#copy_book_id').hide();
          $('#book_pagination_id0').html(msg);
          clear_slider_style(1);
        }
        else
        {
          $('#copy_book_message_id').html(msg);
        }
      }
    });
  }

  function clear_slider_style(v)
  {
    var Tags=document.getElementById('NewsTop_tit').getElementsByTagName('p');
    var TagsCnt=document.getElementById('NewsTop_cnt').getElementsByTagName('font');
    var len=Tags.length;
    for(i=1; i<len; i++)
    {
      Tags[i].className='topC0';
      TagsCnt[i].className='undis';
    }

    flag=v;
    Tags[v].className='topC1';
    TagsCnt[v].className='dis';
  }

