<%@ Page CodeBehind="search_userPath.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Webdisk.search_userPath" %>
<% @ Import Namespace="Webdisk" %>
    <link href="<%=xml.GetStyle()%>" type="text/css" rel="Stylesheet"/>
    <link rel="stylesheet" href="js/artDialog/css/ui-dialog.css" />
    <link href="css/common.css" rel="stylesheet" type="text/css" />
		<link href="css/webdialog.css" type=text/css rel=stylesheet>
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/artDialog/dist/dialog-plus.js" type="text/javascript"></script>
    <script src="js/jquery.pagination.js" type="text/javascript"></script>
    <form id="form1" runat="server">
    <div  class="menuBlock" runat="server" id="divList">
        <div class="menuHead" style="overflow: hidden; border-bottom: 1px dashed #cfcfcf;">
            <h2 style="font-size: 18px; color: #1EA7DF;">
                <img src="pics/menu_file_cut.gif" align="absMiddle">
                查找用户</h2>
        </div>
        <table class="form-table">
			<tr><td class="label" style="width:100px;"> 过滤显示：</td>
			<td> <asp:DropDownList id="dept" runat="server" >
				</asp:DropDownList></td></tr>
            <tr><td class="label">
                    查找用户：</td><td>
                    <input class="input3" id="key" name="key" runat="server" style="width:200px;">
					（请输入用户名或真实姓名） <asp:CheckBox ID="chkLike" runat="server" Text="模糊查找"></asp:CheckBox>
					<span id="keyError" style="color:#f00;"></span>
                    <input class="but1 floatR" id="btnSearch" type="button" value=" 查 找 " name="submit2" runat="server">
                    </td></tr>
        </table>
		<div class="menubox">
			<INPUT class="but5 addUser" type="button" value="添加勾选的用户" id="Button1" name="Button1" runat="server" style="display:none;">
			</div>
     <div class="mListT">
        <span class="l5">目录</span> 
        <span class="l3">用户名</span> 
        <span class="l3">真实姓名</span>
        <span class="l3">班级</span>
        </div>
        <div id="ListContent"></div> 
		<div class="pageList" id="page"></div>
    </div>
	<input type="hidden" id="hiddenUser" runat="server" value />
    </form>
	<script type="text/javascript">
    var SearchUserPath = {};
    SearchUserPath.init = function () {
        this.addEvent();
        this.ListEvent();
        this.page();
    }
    SearchUserPath.addEvent = function () {
	    var that = this;
	    //全选反选
	    $("#codeCheckAll").click(function(){
		    var checked = this.checked ;
		    $(".checkItem").each(function(){
			    this.checked = checked ;
			    $(this).parents("li")[checked? "addClass":"removeClass"]("checked");
		    });
	    });
	    $("#dept").change(function(){
		    that.page();
	    });
	    $("#btnSearch").click(function(){
		    var _key = $.trim($("#key").val()) ;
		    var error = $("#keyError").html("");
		    if(_key == ""){
			    error.html("您没有输入用户名");
			    return false ;
		    }
		    that.page();
	    });
	    $("#Button1").click(function(){
	
	    });
	    $("#butfriend").click(function(){
		    var checked = [];
		    $(".checkItem:checked").each(function(){
			    checked.push(this.value);
		    });
		    if(checked.length == 0 ){
			    var d = dialog();
			    d.content("您没有选择任何用户!");
			    d.showModal();
			    that.autoClose(d);
		    }else{
			    that.addFriend(checked);
		    }
	    });
    }
SearchUserPath.ListEvent = function () {
	
//	$(".checkItem").click(function(){
//		var flag = $(".checkItem").size() == $(".checkItem:checked").size() ;
//		var checked = this.checked ;
//		$(this).parents("li")[checked ? "addClass":"removeClass"]("checked");
//		$("#codeCheckAll")[0].checked = flag ;
//	});
//	$("#SearchUserList li").click(function(event){
//		if(event.target.nodeName.toLowerCase() != "input"){
//			$(this).find(".checkItem")[0].click();
//		}
//	});
}
SearchUserPath.autoClose = function (d) {
	setTimeout(function(){
		d.close().remove();
	},2000);
}
SearchUserPath.page = function () {
	var that = this ;
	var tag = $("#ListContent");
	$("#keyError").html("");
	function ajax(page,callback){
	var d = dialog();
		var _data = {pageIndex:encodeURI(page),dept:encodeURI($("#dept").val()),key:encodeURI($.trim($("#key").val())),islike:encodeURI(($("#chkLike").is(":checked")? 1: 0))}
		$('input[name="type"]').size()>0 && (_data[type] = encodeURI($('input[name="type"]:checked').val()));
		$.ajax({
			url :"userPathList.aspx",
			data : _data,
			dataType : "html",
			cache:false,
			type : "POST",
			beforeSend : function(){
				d.showModal();
			},
			success : function(data){
				d.close().remove();
				tag.empty().append(data);
				that.ListEvent();
				typeof callback == "function" && callback();
			}
		});
	}
	ajax(0,function(){
		var maxlength =parseInt($("#H_itemtCount").val());
		$("#page").pagination(maxlength, {
			prev_text: '< 上一页',
			next_text: '下一页 >',
			items_per_page: parseInt($("#H_pagesize").val()),
			num_display_entries: 5,
			current_page: 0,
			num_edge_entries: 2,
			link_to: "javascript:void(0);",
			callback: function (page_id, panel) {
				var self = this;
				ajax(page_id, function () {
					self.maxentries = parseInt($("#H_itemtCount").val());
				});
			}
		});
	});
}
SearchUserPath.init();
function setvalue(str) {
    window.opener.setvalue(str);
    window.opener = null;
    window.close();
}
</script>
