<%@ page language="C#" autoeventwireup="true" inherits="user_common_UpLoadPic, 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/css.css" type="text/css" rel="stylesheet" />
    <script src="../../js/Common.js" type="text/javascript"></script>
    <script type="text/javascript">
        var api = frameElement.api, W = api.opener;
    </script>
    <script src="../../js/ImagePreview.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Exists()
        {
            if (DianCMS_$("File1").value.length == 0 && DianCMS_$("txtWebUrl").value.replace("http://","").length == 0) {
                alert("请选择图片！");
                return false;
            }
            return true;
        }
    </script>
    <style type="text/css">
        fieldset
        {
            padding: 5px;
            border: 1px solid #999999;
            width: 100%;
        }
        #divPreview, #divPreviewNew
        {
            width: 180px;
            height: 180px;
        }
    </style>

    <script>
        function UpLoadType(val) {
            switch (val) {
                case "upload1":
                    DianCMS_$("File1").disabled = false;
                    DianCMS_$("txtbrowseserver").disabled = true;
                    DianCMS_$("txtWebUrl").disabled = true;
                    DianCMS_$("Button2").disabled = true;
                    DianCMS_$("DownLoadPic").disabled = true;
                    break;
                case "upload2":
                    DianCMS_$("File1").disabled = true;
                    DianCMS_$("txtbrowseserver").disabled = false;
                    DianCMS_$("txtWebUrl").disabled = true;
                    DianCMS_$("Button2").disabled = false;
                    DianCMS_$("DownLoadPic").disabled = true;
                    break;
                case "upload3":
                    DianCMS_$("File1").disabled = true;
                    DianCMS_$("txtbrowseserver").disabled = true;
                    DianCMS_$("txtWebUrl").disabled = false;
                    DianCMS_$("Button2").disabled = true;
                    DianCMS_$("DownLoadPic").disabled = false;
                    break;
            }
        }

        function SelectTextBox(object) {
            document.getElementById(object.id).select();
        }

        function PreviewImg(v, a) {
            DianCMS_$("imgHeadPhoto").src = v;
        }
    </script>

</head>
<body onload="UpLoadType('upload1')">
    <form id="form1" runat="server">
    <table cellpadding="2" cellspacing="0" border="0" width="600" align="center">
        <tr>
            <td>
                <asp:TextBox ID="FilePicPath" runat="server" Style="display: none"></asp:TextBox>
                <table width="590" align="center" cellpadding="0" cellspacing="0" border="0" id="Upload">
                    <tr>
                        <td valign="top">
                            <fieldset style="width:320px;">
                                <legend>图片来源</legend>
                                <table cellpadding="3" cellspacing="0" border="0" align="left">
                                    <tr>
                                        <td>
                                            <asp:RadioButton ID="upload1" Checked="true" GroupName="UpLoad" runat="server" Text="上传："
                                                onclick="UpLoadType(this.id)" />
                                        </td>
                                        <td>
                                            <input id="File1" type="file" runat="server" onchange="PreviewImage(this,'imgHeadPhoto','divPreview')" />
                                        </td>
                                    </tr>
                                    <tr style="display: none">
                                        <td>
                                            <asp:RadioButton ID="upload2" runat="server" GroupName="UpLoad" Text="选择：" onclick="UpLoadType(this.id)" />
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtbrowseserver" runat="server" onchange="javascript:PreviewImg(this.value,2);"
                                                onclick="SelectTextBox(this)" CssClass="in1"></asp:TextBox><input id="Button2" type="button"
                                                    value="浏览服务器" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:RadioButton ID="upload3" GroupName="UpLoad" runat="server" Text="网络：" onclick="UpLoadType(this.id)" />
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtWebUrl" runat="server" Columns="32" onchange="javascript:PreviewImg(this.value);"
                                                onclick="SelectTextBox(this)" CssClass="in1">http://</asp:TextBox><asp:CheckBox ID="DownLoadPic"
                                                    runat="server" Checked="true" Style="display: none" Text="下载到本地" />
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                            <fieldset style="width:320px;">
                                <legend>设置图片</legend>
                                <table cellpadding="3" cellspacing="0" border="0" align="left">
                                    <tr>
                                        <td><asp:TextBox ID="txtAutoSmall" runat="server" style="display:none"></asp:TextBox>
                                            <div style="float: left">
                                                <asp:CheckBox ID="WaterMark" runat="server" Text="水印" /></div>
                                            <div id="ajax" style="float: left">
                                                <asp:CheckBox ID="NewSize" runat="server" Text="等比例大小" onClick="chooseOne(this,'ajax');" /><asp:CheckBox
                                                    ID="Fastness" runat="server" Text="固定大小" onClick="chooseOne(this,'ajax');" /></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left">
                                            <asp:RadioButton ID="newsize1" runat="server" GroupName="NewSizeType" Text="按比例缩放：" /><asp:TextBox
                                                ID="txtBiLi" runat="server" Columns="4" onclick="SelectTextBox(this)" CssClass="in1">50</asp:TextBox>%
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left">
                                            <asp:RadioButton ID="newsize2" runat="server" GroupName="NewSizeType" Text="按设置缩放：" />
                                            宽<asp:TextBox ID="txtWidth" runat="server" Columns="3" onclick="SelectTextBox(this)"
                                                CssClass="in1">200</asp:TextBox>
                                            高<asp:TextBox ID="txtHeight" runat="server" Columns="3" onclick="SelectTextBox(this)"
                                                CssClass="in1">200</asp:TextBox>
                                            单位：px
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                            <fieldset style="width:320px;">
                                <legend>确认提交</legend>
                                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                    <tr>
                                        <td align="center" height="50">
                                            <asp:Button ID="Button1" runat="server" Text=" 确定 " OnClick="Button1_Click" OnClientClick="return Exists();" CssClass="btn"
                                                Style="margin-left: 60px;" />
                                            <input id="Button3" type="button" value=" 取消 " onclick="api.close();" class="btn"
                                                style="margin-left: 20px" />
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </td>
                        <td style="padding-left: 6px" valign="top">
                            <fieldset style="width:220px;">
                                <legend>预览图像</legend>
                                <table cellpadding="2" cellspacing="0" border="0" width="220">
                                    <tr>
                                        <td align="center" height="240">
                                            <div id="divPreview">
                                                <img id="imgHeadPhoto" src="../../images/noimage.gif" onload="DrawImage(this)" height="180" width="180" style="border: solid 1px #d2e2e2;"
                                                    alt="" /></div>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

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

    </form>
</body>
</html>
