<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Uponepic.ascx.cs" Inherits="Mvcb2b.admin.controls.Uponepic" %>
<div ><input name="picurl_txt" id="picurl_txt" type="text" readonly="readonly" runat="server" value="" style="width:150px; background-color:#f5f5f5;" />
<span id="smalldel"></span></div>
<div id="filediv3" class="filediv3"><span></span></div>
<div id="smallpic"></div>
<script type="text/javascript">
    var editorpath2 = "<%=Webd%>editors/"
    $(document).ready(function(){ cfm3(); });
   <%-- /*
    function pdfprocess(flag) {
        try {
            if (flag == true) {
                $("#wrapshow").show();
                fileupstate = window.setInterval("getpagestate()", 2000); 
            }
            else
                $("#wrapshow").hide();
        }
        catch (err) { }
    }
    */--%>
    function cfm3() {
        var newElem = document.getElementById("filediv3");
        newElem.innerHTML = "";
        var frm = document.createElement("iframe");
        frm.setAttribute("name", "ifr3");
        frm.setAttribute("id", "ifr3");
        frm.setAttribute("src", "");
        frm.setAttribute("marginwidth", "0");
        frm.setAttribute("marginheight", "1");
        frm.setAttribute("width", "260");
        frm.setAttribute("height", "25");
        frm.setAttribute("scrolling", "no");
        frm.setAttribute("border", "0");
        frm.setAttribute("frameborder", "0");
        newElem.appendChild(frm);
        var ifr3 = window.frames['ifr3'];
        createcfm3(ifr3);
    }
    function createcfm3(ifr) {
        ifr3.document.open();
        //  ifr.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');//会提示没有权限
        ifr3.document.write('<html>\n');
        ifr3.document.write('<head>\n');
        ifr3.document.write('<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />\n');
        ifr3.document.write('<style>*{margin:0px;padding:0px;line-height:20px;}body{}</style>\n');
        ifr3.document.write('<script>function check(){if (document.form2.file3.value==""){alert("上传文件不能为空");return false;}if (window.parent.document.getElementById("<%=picurl_txt.ClientID %>").value!=""){alert("请先删除图片");return false;}}<\/script>\n');
        ifr3.document.write('</head>\n');
        ifr3.document.write('<body>\n');
        ifr3.document.write('<form id="form2" name="form2" method="post" enctype="multipart/form-data" onsubmit="return check();" action="' + editorpath2 + 'uploadinc/Uponepic.aspx?w=<%=Width%>">\n');
        ifr3.document.write('<input type="file" name="file3"  id="file3" value="" style="width:180px;line-height:20px;margin-top:2px;height:19px;" /><input style="padding-left:3px;padding-right:3px;height:21px;line-height:18px;width:73px;"  type="submit" name="Submit3" value="开始上传" /></form>');
        ifr3.document.write('</body>\n');
        ifr3.document.write('</html>');
        ifr3.document.close();
    }
    function parentcfm3(str,picid) {
        var webd = "<%=Webd%>";
        var imgstr = '<img src="' + webd + str + '"  onload="javascript:if(this.width>380){this.width=380;}"   alt="" />';
        var picsmall = "#<%=picurl_txt.ClientID %>";
        $(picsmall).val(str); //赋值完
        document.getElementById("smallpic").innerHTML = imgstr;
        document.getElementById("smalldel").innerHTML = '<a  onclick="delsmall(\'' + str + '\');" href="javascript:void(0);">删除</a>';
        cfm3(); 
    }

    function delsmall(path) {
        if (confirm('确实要删除吗?')) {
            $.ajax({
                type: "POST",
                url: "jquery/Delsmallpic.aspx",
                dataType: "html",
                data: { "p": "" + path + "" }, //p传输的参数
                success: function(html) {
                    if (html != "0") {
                        alert("图片删除成功")
                        document.getElementById("<%=picurl_txt.ClientID %>").value = "";
                        document.getElementById("smallpic").innerHTML = "";
                    }
                }, error: function(html) { alert("没有权限!"); }
            });
        }
    }

    function showsmall(str) {
        if (str != "") {
            var webd = "<%=Webd%>";
            var imgstr = '<img src="' + webd + str + '" onload="javascript:if(this.width>380){this.width=380;}"  alt="" />';
            document.getElementById("smallpic").innerHTML = imgstr;
            document.getElementById("smalldel").innerHTML = '<a  onclick="delsmall(\'' + str + '\');" href="javascript:void(0);">删除</a>';
            try{
            showpic();
            }
            catch(e)
            {
               
            }
            finally
            {
            }
        }
    }
</script>
