<%@ page language="C#" autoeventwireup="true" inherits="admin_common_swfupload_default, DianCMS" enableviewstatemac="false" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<!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>
    <link href="css/default.css" rel="stylesheet" type="text/css" />

    <script src="../../../js/Common.js" language="javascript" type="text/javascript"></script>

    <script type="text/javascript" src="swfupload/swfupload.js"></script>

    <script type="text/javascript" src="js/handlers.js"></script>

    <script type="text/javascript">
        var swfu;
        var api = frameElement.api, W = api.opener;
        window.onload = function()
        {
            swfu = new SWFUpload({
                // Backend Settings
                upload_url: "upload.aspx",
                post_params: {
                    "ASPSESSID": "<%=Session.SessionID %>",
                    "FilePicPath": "" + DianCMS_$("FilePicPath").value + "",
                    "AdminCookies": "" + getCookie("DianCMSAdmin") + "",
                    "FieldId":"<%=FieldId %>"
                },

                // File Upload Settings
                file_size_limit: "2 MB",
                file_types: "*.jpg;*.gif;*.png;*.bmp",
                file_types_description: "JPG Images",
                file_upload_limit: "0",    // Zero means unlimited

                // Event Handler Settings - these functions as defined in Handlers.js
                //  The handlers are not part of SWFUpload but are part of my website and control how
                //  my website reacts to the SWFUpload events.
                file_queue_error_handler: fileQueueError,
                file_dialog_complete_handler: fileDialogComplete,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: uploadSuccess,
                upload_complete_handler: uploadComplete,

                // Button settings
                button_image_url: "images/XPButtonNoText_160x22.png",
                button_placeholder_id: "spanButtonPlaceholder",
                button_width: 160,
                button_height: 22,
                button_text: '<input style="margin-left:10px;float:left">选择需要上传的文件</input>',
                //button_text_style: 'margin-left:10px;',
                button_text_top_padding: 1,
                button_text_left_padding: 5,

                // Flash Settings
                flash_url: "swfupload/swfupload.swf", // Relative to this file

                custom_settings: {
                    upload_target: "divFileProgressContainer"
                },

                // Debug Settings
                debug: false
            });
        }
        
        function getCookie(name)
        {
            var arg = name + "=";
            var alen = arg.length;
            var clen = document.cookie.length;
            var i = 0;
            while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
            }
            return null;
        }

        function getCookieVal(offset)
        {
            var endstr = document.cookie.indexOf(";", offset);
            if (endstr == -1) endstr = document.cookie.length;
            return document.cookie.substring(offset, endstr);
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="content">
        <div id="swfu_container" style="margin: 0px 10px;">
            <div id="divFileProgressContainer" style="height: 75px;">
            </div>
            <div id="thumbnails">
            </div>
        </div>
    </div>
    <div id="footer"><div><asp:TextBox ID="FilePicPath" runat="server" style="display:none"></asp:TextBox>
        <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="保存已选择的图片"
            Width="150px" style="float:right;"/><span id="spanButtonPlaceholder" style="float:left;margin:10px"></span></div>
        
    </div>

    <script>
        DianCMS_$('FilePicPath').value = W.document.getElementById('FilePicPath').value;
    </script>
    </form>
</body>
</html>
