<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Upmappic.ascx.cs" Inherits="Mvcb2b.admin.controls.Upmappic" %>
<div ><input name="map_txt" id="map_txt" type="text" readonly="readonly" runat="server" value="" style="width:150px; background-color:#f5f5f5;" />
<span id="mapdel"></span></div>
<div id="filedivmap"  class="filediv3"><span></span></div>
<div id="mappic"></div>
<script type="text/javascript">
    var editorpathmap = "<%=Webd%>editors/";
    $(document).ready(function () { cfmmap(); });
    function cfmmap() {
        /*newElem = document.getElementById("filedivmap");
        newElem.innerHTML = "";
        var frm = document.createElement("<iframe  name='ifrmap' id='ifrmap' src='' marginwidth='' marginheight='1' width='260' height='25' scrolling='no' border='0' frameborder='0'></iframe>");
        newElem.appendChild(frm);
        var ifrmap = window.frames['ifrmap'];
        createcfmmap(ifrmap);// chrome不支持*/
        var newElem = document.getElementById("filedivmap");
        newElem.innerHTML = "";
        var frm = document.createElement("iframe");
        frm.setAttribute("name", "ifrmap");
        frm.setAttribute("id", "ifrmap");
        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 ifrmap = window.frames['ifrmap'];
        createcfmmap(ifrmap);
    }
    function createcfmmap(ifr) {
        ifrmap.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');//会提示没有权限
        ifrmap.document.write('<html>\n');
        ifrmap.document.write('<head>\n');
        ifrmap.document.write('<meta http-equiv="Content-Type" content="text/html; charset=gb2312">\n');
        ifrmap.document.write('<style>*{margin:0px;padding:0px;line-height:20px;}body{}</style>\n');
        ifrmap.document.write('<script>function check(){if (document.form2.file3.value==""){alert("上传文件不能为空");return false;}if (window.parent.document.getElementById("<%=map_txt.ClientID %>").value!=""){alert("请先删除图片");return false;}}<\/script>\n');
        ifrmap.document.write('</head>\n');
        ifrmap.document.write('<body>\n');
        ifrmap.document.write('<form id="form2" name="form2" method="post" enctype="multipart/form-data" onsubmit="return check();" action="' + editorpathmap + 'uploadinc/Upmappic.aspx?w=<%=Width%>&sessionid=<%=Sessionid%>">\n');
        ifrmap.document.write('<input type="file" name="file3"  id="file3" value="" style="width:180px;line-height:20px;margin-top:2px;height:19px;" ><input type="hidden" name="pictype" id="pictype" value="<%=Pictype%>"  ><input style="padding-left:3px;padding-right:3px;height:21px;line-height:18px;width:73px;"  type="submit" name="Submit3" value="开始上传" ></form>');
        ifrmap.document.write('</body>\n');
        ifrmap.document.write('</html>');
        ifrmap.document.close();
    }
    function parentcfmmap(str) {
        var webd = "<%=Webd%>";
        var imgstr = '<img src="' + webd + str + '"  onload="javascript:if(this.width>380){this.width=380;}"   alt="" />';
        var picsmall = "#<%=map_txt.ClientID %>";
        $(picsmall).val(str); //赋值完
        document.getElementById("mappic").innerHTML = imgstr;
        document.getElementById("mapdel").innerHTML = '<a  onclick="delmap(\'' + str + '\');" href="javascript:void(0);">删除</a>';
        cfmmap();
    }

    function delmap(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("<%=map_txt.ClientID %>").value = "";
                        document.getElementById("mappic").innerHTML = "";
                    }
                }, error: function(html) { alert("没有权限!"); }
            });
        }
    }

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