<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog/DialogMaster.Master" AutoEventWireup="true"
    CodeBehind="UploadPic.aspx.cs" Inherits="OAWeb.crm.promote.UploadPic" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function closeDialog(path) {
            // 返回数据给页面
            art.dialog.data('departValue', path); // 存储Value数据
            art.dialog.close();
        }
    </script>
    <div class="form" style="width: 500px;">
        <div class="tabs">
            <div class="tab_handles">
                <span class="current">我的电脑</span> <span>网上图片</span>
            </div>
        </div>
        <table cellpadding="0" cellspacing="0" border="0" class="table_form">
            <tr class="index_1">
                <td style="padding-left: 10px; border-bottom: solid #cccccc 1px;">
                    选择本地图片:
                    <input name="file_uploader" type="file" />
                    <input id="btnUpload" type="button" value=" 添加 " class="btn_77px" />
                </td>
            </tr>
            <tr class="index_2 hide">
                <td style="padding-left: 10px; border-bottom: solid #cccccc 1px;">
                    输入图片地址:<asp:TextBox ID="txtPicPath" CssClass="text width200 " runat="server"></asp:TextBox>
                    <input id="btnAdd" type="button" value=" 添加 " class="btn_77px" />
                </td>
            </tr>
            <tr>
                <td style="height: 100px; text-align: center">
                    <img style="display: none;" src="" height="50px" width="50px" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center">
                    <input id="hidPath" type="hidden" />
                    <input id="btnInnert" type="button" value=" 插入图片 " class="btn_77px" onclick="closeDialog($('#hidPath').val())" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {            
            $("#btnUpload").click(function () {                
                $("#aspnetForm").ajaxSubmit({
                    url: "/crm/promote/UploadPic.aspx?op=UploadFile&r=" + Math.random(),
                    success: function (result) {
                        if (result.indexOf("ok:") > -1) {
                            $("#hidPath").val(result.replace("ok:", ""));
                            $("img").show();
                            $("img").attr("src", $("#hidPath").val());
                        } else {
                            alert(result);
                        }
                    }
                });
                return false;
            })
            $(".tab_handles span").click(function () {
                var hideIndex = $(".tab_handles .current").index();
                $(".tab_handles span").removeClass("current");
                $(this).addClass("current");
                if (hideIndex == 0) {
                    $(".index_1").hide();
                    $(".index_2").show();
                } else {
                    $(".index_1").show();
                    $(".index_2").hide();
                }
            })
            $("#btnAdd").click(function () {
                var p = $('#<%=txtPicPath.ClientID %>').val();
                if (p == "") { alert('请输入图片地址'); return false; }
                $('#hidPath').val(p);
                $("img").show();
                $("img").attr("src", p);
            })
        });
    </script>
</asp:Content>
