<%@ Page Language="C#" AutoEventWireup="true" Inherits="PowerEasy.Module.General.WebSite.User.Accessories.FloatingFileUpload"
    CodeBehind="FloatingFileUpload.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        /***********文件上传***********/
        body
        {
            font: 12px '宋体' , arial, helvetica, sans-serif;
        }
        .type-file-box
        {
            position: relative;
        }
        .type-file-text
        {
            height: 20px;
            line-height: 20px;
            border: 1px solid #ccc;
            margin: 0px 0px;
            padding: 1px 0px;
        }
        .type-file-button
        {
            background-color: #FFF;
            border: 1px solid #CDCDCD;
            height: 24px;
            width: 69px;
        }
        .type-file-file
        {
            position: absolute;
            top: 0;
            left: 0;
            height: 24px;
            filter: alpha(opacity:0);
            opacity: 0;
            width: 200px;
        }
        input
        {
            vertical-align: middle;
        }
    </style>
</head>
<script type="text/javascript" src="<%=ResolveClientUrl("~/JS/Silverlight.js")%>"></script>
<script type="text/javascript" src="<%=ResolveClientUrl("~/JS/jquery.pack.js")%>"></script>
<script type="text/javascript">
    var checkInstall = false;
    function onSilverlightError(sender, args) {
        if (checkInstall) {
            document.getElementById("Upload").style.display = "";
            document.getElementById("silverlightControlHost").style.display = "none";
            document.getElementById("errorLocation").innerHTML = "很抱歉，使用Silverlight上传的时候出错，请使用普通方式上传。";
            document.getElementById("errorLocation").style.display = "block";
        }
    }
    function CheckSilverLight() {
        checkInstall = true;
        if (Silverlight.isInstalled(null)) {
            document.getElementById("Upload").style.display = "none";
        }
    }
    $(function () {
        var textButton = "<input type='text' name='textfield' id='textfield' class='type-file-text' style='width:<%= Width-146 %>px;' />&nbsp;<input type='button' name='button' id='button' value='浏览...' class='type-file-button' />"
        $(textButton).insertBefore("#<%= FupFile.ClientID %>");
        $("#<%= FupFile.ClientID %>").change(function () {
            $("#textfield").val($("#<%= FupFile.ClientID %>").val());
        });
        $("#<%= FupFile.ClientID %>").bind("onkeyup", function () {
            $("#textfield").val($("#<%= FupFile.ClientID %>").val());
        });
    });
</script>
<body class="floatingIframe">
    <form id="form1" runat="server" enctype="multipart/form-data">
    <table cellpadding="0" cellspacing="0" border="0" style="height: 100%; width: 100%;
        padding: 1px 0 0 0;" id="Upload">
        <tr>
            <td valign="top">
                <asp:FileUpload ID="FupFile" runat="server" onpropertychange="$('#textfield').val($(this).val());"
                    CssClass="type-file-file" />&nbsp;<asp:Button ID="BtnUpload" CssClass="type-file-button"
                        runat="server" Text="<%$ Res: User_Accessories_FileUpload_BtnUpload,上传 %>" OnClick="BtnUpload_Click" /><pe:RequiredFieldValidator
                            ID="ValFile" runat="server" RequiredText="" ErrorMessage="<%$ Res: User_Accessories_FileUpload_ValFile,请选择上传路径 %>"
                            ControlToValidate="FupFile"></pe:RequiredFieldValidator><asp:Label ID="LblMessage"
                                runat="server" ForeColor="red" Text=""></asp:Label>
            </td>
        </tr>
    </table>
    <div id='errorLocation' style="font-size: small; color: Gray; display: none;">
    </div>
    <div id="silverlightControlHost" class="tdbg">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="100%" height="100" class="tdbg">
            <param name="source" value="<%=ResolveClientUrl("~/ClientBin/FileUpLoad.zip")%>" />
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="Transparent" />
            <param name="wmode" value="Transparent" />
            <param name="windowless" value="true" />
            <param name="minRuntimeVersion" value="2.0.31005.0" />
            <param name="autoUpgrade" value="true" />
            <param name="initParams" value="UploadHandlerName=<%=Page.Request.Url.Scheme + "://" + Page.Request.Url.Authority + BasePath + (IsAdminManage ? "Admin" : "User")%>/Accessories/HttpUploadHandler.ashx,EnableUploadFiles=<%=EnableUploadFiles%>,CustomParam=<%=CustomParam%>,FileFilter=文件(<%=FileExtArr%>)|<%=FileExtArr%>,ReturnJSFunction=<%=ReturnJSFunction%>,CustomReturnJSFunction=<%=CustomReturnJSFunction%>" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: underline;">
                你可以点此安装SilverLight以获得更好的上传体验 </a>
        </object>
        <iframe style='visibility: hidden; height: 0; width: 0; border: 0px'></iframe>
    </div>
    </form>
</body>
</html>
