<%@ Page CodeBehind="pick.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Webdisk.pick" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>提取文件</title>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
</head>
<body style="overflow:hidden; padding:0px">
    <form runat="server">
    <div id="content">
        <div class="inside" style="overflow:hidden">
            <div class="place">
                <p>
                    <a href="Index.aspx">首页</a> >> 提取文件</p>
            </div>
            <div class="center" >
                <div class="Draw">
                    <p>
                        <a href="javascript:history.go(-1);">返回</a></p>
                    <div>
                        <b class="Draw_input">
                            <input id="code" class="kuan" type="text" name="code" runat="server" /></b>
                        <input class="Draw_submit" style="color: #FFF; text-decoration: none;" id="btnPick"
                            type="button" value="提取文件"  runat="server"  onclick="btnPick_click()"  />
                    </div>
                    
                </div>
                 
            </div>
            <div>
               
            </div>
        </div>
    </div>
    </form>
    <script type="text/javascript">
        window.onload = function () {
          //  reHeight()
            window.onresize = function () {
               // reHeight()
            }
        }
        function reHeight() {
            var height = document.getElementsByTagName("body")[0].offsetHeight;
            window.parent.document.getElementById("content").style.height = height + "px";
        }

        $(function () {
            var code =$.trim("<% if(Request["code"]!=null) Response.Write(Request["code"].ToString()); %>");
           
            if ( code != "undefined" && code != "" ) {
                CheckCode(code);
                $("#code").val(code);
            }
        });

        //提取文件按钮事件
        function btnPick_click() {
            var code=$("#code").val();
            if (code == undefined || code == "undefined" || code == "") {
                alert("请输入提取码！");
                return false;
            }
            CheckCode(code);
        }
        //检查提取码是否有效
        function CheckCode(code) {
            $.ajax({
                type: "post",
				cache:false,
                contentType: "application/json;utf-8",
                url: "FileSpaceHandler.ashx?cmd=ExistsFileByPickCode&pickcode=" + code,
                success: function (data) {
                    if (data == "true") {
                        window.open("IndexPage1.aspx?p=PickResult.aspx?pickcode=" + code);
                    }
                    else if (data == "false") {
                        alert("提取码已过期或文件不存在！");
                        return false;
                    }
                    else {
                        alert("文件不存在！");
                        return false;
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("错误:" + XMLHttpRequest.responseText);
                    return false;
                }
            });
        }
    </script>
</body>
</html>
