<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="shareout.aspx.cs" Inherits="Webdisk.shareout" %>
<HTML>
  <HEAD>
		<% @ Import Namespace="Webdisk" %>
		<link href="<%=xml.GetStyle()%>" type=text/css rel=stylesheet>
		<link href="css/webdialog.css" type=text/css rel=stylesheet>
	<link rel="stylesheet" href="demo.css" type="text/css">
	<link rel="stylesheet" href="zTreeStyle/zTreeStyle.css" type="text/css">
        <link rel="stylesheet" href="js/artDialog/css/ui-dialog.css" />
	<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="js/artDialog/dist/dialog-plus.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery.ztree.core-3.5.min.js"></script>
			<script language="javascript">
			    function AddRemoveValues(oChk) {
			        if (oChk.checked)
			            document.all.HdnSelectedValues.value += oChk.value + ",";
			        else
			            document.all.HdnSelectedValues.value = document.all.HdnSelectedValues.value.replace(oChk.value + ",", "");
			    }
			    function shareuser(url) {
			        window.open(url, '', 'scrollbars=yes,resizable=no,status=no,toolbar=no,menubar=no,location=no,width=700,height=500');
			    }
			    function EditOpt() {
			        Webdisk.share.EditOpt(document.all.overshare.checked);
			    }
			    function Result() {
			        var kind = document.getElementById("kind1");
			        if (kind.value == '不指定') {
			            document.all("kind2").length = 0;
			            document.all("kind2").options.add(new Option('0', '其它类型'));
			        }
			        else Webdisk.share.GetKind2All(kind.value, get_Result_CallBack);
			    }

			    function get_Result_CallBack(response) {
			        if (response.value != null) {
			            document.all("kind2").length = 0;
			            var ds = response.value;
			            if (ds != null && typeof (ds) == "object" && ds.Tables != null) {
			                for (var i = 0; i < ds.Tables[0].Rows.length; i++) {
			                    var name = ds.Tables[0].Rows[i].rootkind1;
			                    var id = ds.Tables[0].Rows[i].rootkind3;
			                    document.all("kind2").options.add(new Option(name, id));
			                }
			                if (document.all("kind2").options.length == 0) document.all("kind2").options.add(new Option("默认类别", "0"));
			                document.all.hidkind.value = document.all.kind2.value;
			            }
			        }
			        return
			    }
			    function closeWindow(flag) {
			        if (window.top.closeWindow) {
			            if (flag) {
							
			                window.top.closeWindow(flag);
			            } else {
			                window.top.closeWindow();
			            }
			        } else {
			            history.go(-1)
			        }
			    }
				function shareSucc(flag){
					 dialog({align: 'top left',quickClose: true,content:"<span style='color: #1DA7DD;'>发布成功</span>"}).show(document.getElementById("btnfinish"));
					setTimeout(function(){closeWindow(flag)},2000);
				}
            </script>

<SCRIPT type="text/javascript">
		<!--
    var setting = {
        view: {
            dblClickExpand: false
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: beforeClick,
            onClick: onClick
        }
    };

    var zNodes = [
			<%=zylist %>
		 ];

    function beforeClick(treeId, treeNode) {
        var check = (treeNode && !treeNode.isParent);
        if (!check) alert("只能选择最末级...");
        return check;
    }

    function onClick(e, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getSelectedNodes(),
			v = "",v1="";
        nodes.sort(function compare(a, b) { return a.id - b.id; });
        for (var i = 0, l = nodes.length; i < l; i++) {
            v += nodes[i].name + ",";
            v1 += nodes[i].id + ",";
        }
        if (v.length > 0) v = v.substring(0, v.length - 1);
        if (v1.length > 0) v1 = v1.substring(0, v1.length - 1);
        var cityObj = $("#zykind1");
        var cityObj1 = $("#zykind");
        cityObj.attr("value", v);
        cityObj1.attr("value", v1);
    }

    function showMenu() {
        var cityObj = $("#zykind1");
        var cityOffset = $("#zykind1").offset();
        $("#menuContent").css({ left: cityOffset.left + "px", top: cityOffset.top + cityObj.outerHeight() + "px" }).slideDown("fast");

        $("body").bind("mousedown", onBodyDown);
    }
    function hideMenu() {
        $("#menuContent").fadeOut("fast");
        $("body").unbind("mousedown", onBodyDown);
    }
    function onBodyDown(event) {
        if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length > 0)) {
            hideMenu();
        }
    }

    $(document).ready(function () {
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
    });
		//-->
	</SCRIPT>
    <style type="text/css">
            html,body{overflow:hidden; height:100%;}
            form
            {
                overflow-y:auto;overflow-x:hidden;height:100%;}
            </style>
</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<table class="wfrom-table">
				<tbody>
					<tr>
						<td colspan="2">
							<label class="input-check wtc-1EA7DE" style="float:right;">
								<input type="checkbox" checked="" id="overshare" name="overshare" runat="server" onchange="EditOpt();">覆盖子目录及文件的共享设置
							</label>
							<span class="wtc-999">以下是您共享的目录和文件：</span>
							<div class="wtips" style="max-height: 200px;overflow-y:auto;overflow-x:hidden;clear:both;margin-top:10px;"><asp:label id="Label1" runat="server"></asp:label></div>
						</td>
					</tr>
					<tr>
						<td colspan="2" >
							<span class="input-label">共享大类：</span>
							<select id="kind1" class="input-select" onchange="Result();" name="kind1" runat="server">
                            </select>
							<span class="input-label">共享小类：</span>
							<select id="kind2" class="input-select" name="kind2" runat="server" onchange="document.all.hidkind.value=this.value">
								<option value="不指定" selected="">不指定</option>
							</select>
							<input id="hidkind" style="WIDTH: 13px; HEIGHT: 22px" type="hidden" size="1" name="hidkind" runat="server">
						</td>
					</tr>
					<tr id="showb1" runat="server">
						<td colspan="2">
							<label class="input-check wtc-1EA7DE">
								<input type="checkbox" name="iszy" id="iszy" runat="server" onclick="if (this.checked) document.all.iszylist.style.display='';else document.all.iszylist.style.display='none';">
								作为资源发布
							</label>
							<div id="iszylist" style="display:none">
								<span class="input-label" style="margin-right: 10px;">资源类型：</span>
								<select class="input-select" name="zytype" runat="server" id="zytype"></select>
								<span class="input-label">教材版本：</span>
								<select class="input-select" name="jcvar" runat="server" id="jcvar"></select>
								<span class="input-label">年级：</span>
								<select class="input-select" name="nj" runat="server" id="nj"></select>
								<span class="input-label">科目：</span>
								<select class="input-select" name="km" runat="server" id="km"></select>
							</div>
						</td>
					</tr>
					<tr>
						<td colspan="2" >
								<span class="input-label">资源分类：</span>
							<input id="zykind" type="hidden" runat="server" value="0">
							<input id="zykind1" type="text" class="input-text" readonly="" value="" style="width:120px;" runat="server" onclick="showMenu(); return false;">  
							<%--<a id="menuBtn" class="wbtn-4" onclick="showMenu(); return false;" style="vertical-align:bottom;*vertical-align:bottom;">选择</a>--%>
			 
							<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
								<ul id="treeDemo" class="wztree ztree" style="margin-top:0; width:160px;"></ul>
							</div>
						</td>
					</tr>
					<tr>
						<td colspan="2" >
						
							<input class="wbtn-1" id="btnfinish" type="button" value="完成设置" name="btnfinish" runat="server" onserverclick="btnfinish_ServerClick">    
							<asp:button id="btnremove" runat="server" text="删除共享" cssclass="wbtn-2" onclick="btnremove_Click"></asp:button>
							<input class="wbtn-2" type="button" value="取消" name="btnreturn" id="btnreturn" onclick="closeWindow();">
                            <label id="notice" runat="server" style="color:Red">您所使用的角色在发布资源后需进行后台审核</label>
							<input id="hidcompany" style="WIDTH: 23px; HEIGHT: 22px" type="hidden" size="1" name="hidcompany" runat="server">
							<input id="hiddept" style="WIDTH: 23px; HEIGHT: 22px" type="hidden" size="1" name="hiddept" runat="server">
							<input id="hidworkgroup" style="WIDTH: 23px; HEIGHT: 22px" type="hidden" size="1" name="hidworkgroup" runat="server">
							<input id="hiduser" style="WIDTH: 23px; HEIGHT: 22px" type="hidden" size="1" name="hiduser" runat="server">
							<input id="type" style="WIDTH: 23px; HEIGHT: 22px" type="hidden" size="1" name="type" runat="server">
							<input id="HdnSelectedValues" type="hidden" name="HdnSelectedValues" runat="server">
							
						</td>
					</tr>
				</tbody>
			</table>			

		</form>
	</body>
</HTML>
<script>
    if (document.all.iszy.checked) document.all.iszylist.style.display = '';
</script>