<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Ban_Edit.aspx.cs" Inherits="TotCms.Web.Admin.NewsPaper.Ban_Edit" ValidateRequest="false" %>
<!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 id="Head1" runat="server">
    <title>期刊编辑</title>
    <link href="../style/global.css" rel="stylesheet" type="text/css" />
    <script src="../js/common.js" type="text/javascript"></script>
    <script src="../../ckeditor/ckeditor.js" type="text/javascript"></script>
    <link href="../../swfupload/swfupload.css" rel="stylesheet" type="text/css" />
    <script src="../../swfupload/swfupload.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/handlers_ban.js"></script>
    <script src="../../js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-ui-1.8.10/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-ui-1.8.10/js/i18n/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
    <link href="../../js/jquery-ui-1.8.10/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      var swfu;
      $(function () {
        $(".dates").datepicker({
          changeMonth: true,
          changeYear: true,
          regional: 'zh-CN'
        });
        $("#dialog:ui-dialog").dialog("destroy");
        $("#dialog-win").dialog({
          autoOpen: false,
          height: 350,
          width: 400,
          modal: true,
          buttons: {
            "确定": function () {
              $(this).dialog("close");
            },
            "取消": function () {
              $(this).dialog("close");
            }
          },
          close: function () {

          }
        });

        $("#selclass").click(function () {
          $("#dialog-win").dialog("open");
        });

        //swf upload
        swfu = new SWFUpload({
          // Backend Settings
          upload_url: "../UploadFace/UploadImg.aspx?issmall=0",
          post_params: {
            "ASPSESSID": "<%=Session.SessionID %>"
          },

          // File Upload Settings
          file_size_limit: "200 MB",
          file_types: "*.*",
          file_types_description: "files",
          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: "../UploadFace/Images/XPButtonUploadText_61x22.png",
          button_placeholder_id: "spanButtonPlaceholder",
          button_width: 61,
          button_height: 22,
          button_text: '<span class="button"></span>',
          button_text_style: '.button { font-family: 宋体; font-size: 14px; } .buttonSmall { font-size: 12px; }',
          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",
            upload_returnobjid: "Photo"
          },

          // Debug Settings
          debug: false
        });
      });
      function CloseFrame() {
        $("#dialog-win").dialog("close");
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <table style="width:100%;" border="0" cellpadding="0" cellspacing="1" 
      class="black_border">
      <tr class="suphead">
        <td colspan="2">
            添加版面
          </td>
    </tr>
    <tr>
      <td class="fields_text" width="100">
          图片：</td>
      <td class="fields_input">
      <asp:TextBox ID="Photo" runat="server"></asp:TextBox>
        <span id="spanButtonPlaceholder"></span>
        <div id="divFileProgressContainer"></div>
        </td>
    </tr>
    <tr>
      <td class="fields_text" width="100">
          名称：</td>
      <td class="fields_input">        
        <asp:DropDownList ID="ddClass" runat="server">
        </asp:DropDownList>    
        <a href="../Sources.aspx?stype=newspaper&title=期刊类别">类别管理</a>    
        </td>
    </tr>
    <tr>
      <td class="fields_text" width="100">
          &nbsp;</td>
      <td class="fields_input">
      <input id="Button2" type="button" value="新建区域" onclick="newMap()" />
      <iframe id="mapIframe" width="100%" scrolling="yes" height="444"></iframe>
      <iframe id="imgframe" width="1" height="1" frameborder="0" scrolling="yes"></iframe>
      <a href="javascript:PlusF()">[+]</a>&nbsp;<a href="javascript:MinusF()">[-]</a>
        <asp:TextBox ID="TbContent" runat="server" CssClass="hidden"></asp:TextBox>
        <asp:TextBox ID="HTitles" runat="server" CssClass="hidden"></asp:TextBox>
        <asp:TextBox ID="HUrls" runat="server" CssClass="hidden"></asp:TextBox>
        <asp:TextBox ID="TbImgs" runat="server" CssClass="hidden"></asp:TextBox>
      </td>
    </tr>   
    <tr>
      <td align="center" colspan="2">
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="确 定" 
                      onclientclick="GetMapValue()" />
                    &nbsp;</td>
    </tr>
    </table>
    </form>
    <script language="JavaScript">
      function PlusF() {
        var h = document.getElementById('mapIframe').height;
        h = parseInt(h);
        document.getElementById('mapIframe').height = h + 100;
      }
      function MinusF() {
        var h = document.getElementById('mapIframe').height;
        h = parseInt(h);
        document.getElementById('mapIframe').height = h - 100;
      }
      var oControl;
      var oSeletion;
      var sRangeType;
      var oMap = null;
      var sSrc = "";
      var sUseMap = "";
      var sWidth = "";
      var sHeight = "";
      var aHref = new Array();
      var aTarget = new Array();
      var aCoords = new Array();
      var aLeft = new Array();
      var aTop = new Array();
      var aWidth = new Array();
      var aHeight = new Array();
      var aMapName = new Array();
      var sBody = "";
      // 初始化
      function doInit(){
        sSrc = document.getElementById('Photo').value;
	      sBody = "<img id='SOURCEIMAGE' border='0' src='"+sSrc+"' />";
	      ////////////////////////////
	      imgframe.document.open();
	      imgframe.document.write("<head><style>body,a,table,td {margin:0px; padding:0px;font-size:12px;Color:#000000;}</style></head><body MONOSPACE>");
	      imgframe.document.body.innerHTML = document.getElementById('TbImgs').value;
	      imgframe.document.close();
	      var oAllMap = imgframe.document.body.getElementsByTagName("MAP");
	      oMap = oAllMap[0];
	      if (oMap){
	        for (var i=0; i<oMap.areas.length; i++){
		        aHref[i] = oMap.areas(i).href;
		        aTarget[i] = oMap.areas(i).title;
		        aCoords[i] = oMap.areas(i).coords;
		        var a = aCoords[i].split(",");
		        aLeft[i] = parseInt(a[0]);
		        aTop[i] = parseInt(a[1]);
		        aWidth[i] = parseInt(a[2])-aLeft[i];
		        aHeight[i] = parseInt(a[3])-aTop[i];
		        sBody += "<img id='myIMAGE"+i+"' style='border:1px dashed #ff0000;' src='../images/space.gif' style='position:absolute;left:"+aLeft[i]+"px;top:"+aTop[i]+"px;width:"+aWidth[i]+"px;height:"+aHeight[i]+"px;zIndex:"+(i+1)+"'>";
	        }
	        ///////////////////////////////////////////
	        mapIframe.document.designMode="On";
	        mapIframe.document.open();
	        mapIframe.document.write("<head><style>body,a,table,td {margin:0px; padding:0px;font-size:12px;Color:#000000;}</style></head><body MONOSPACE>");
	        mapIframe.document.body.innerHTML = sBody;
	        mapIframe.document.body.contentEditable = "true";
	        mapIframe.document.ondblclick=new Function("return dblClick(mapIframe.event);");	
	        mapIframe.document.execCommand("2D-Position",true,true);
	        //mapIframe.document.execCommand("MultipleSelection", true, true);
	        mapIframe.document.execCommand("LiveResize", true, true);
	        mapIframe.document.close();	
        }
      }

      // 双击修改链接属性
      function dblClick(event) {
        var e = event.srcElement;
        if (e) {
          if ((e.tagName == "IMG") && (e.id != "SOURCEIMAGE")) {
            var sID = e.id;
            var nID = parseInt(sID.substr(7));
            var a = new Array();
            a[0] = aHref[nID];
            a[1] = aTarget[nID];
            var arr = showModalDialog("hyperlink.htm?action=other", a, "dialogWidth:350px;dialogHeight:140px;help:no;scroll:no;status:no");
            if (arr) {
              aHref[nID] = arr[0];
              aTarget[nID] = arr[1];
            }
          }
        }
        return false;
      }

      // 取所有的锚
      function getAnchors() {
        var allLinks = opener.eWebEditor.document.body.getElementsByTagName("A");
        for (a = 0; a < allLinks.length; a++) {
          if (allLinks[a].href.toUpperCase() == "") {
            document.write("<option value=#" + allLinks[a].name + ">" + allLinks[a].name + "</option>")
          }
        }
      }

      // 新建热点链接
      function newMap() {
        var n = aHref.length;
        aHref[n] = "";
        aTarget[n] = "";
        var ctop = mapIframe.document.documentElement.scrollTop ? mapIframe.document.documentElement.scrollTop : mapIframe.document.body.scrollTop;
        var cleft = mapIframe.document.documentElement.scrollLeft ? mapIframe.document.documentElement.scrollLeft : mapIframe.document.body.scrollLeft;
        mapIframe.document.body.innerHTML += "<img id='myIMAGE" + n + "' style='border:1px dashed #ff0000' src='../images/space.gif' style='position:absolute;zIndex:" + (n + 1) + ";width:20;height:20;left:" + cleft + ";top:" + ctop + "'>";
        //mapIframe.scrollBy(0,0);
        //mapIframe.focus();
      }

      function GetMapValue() {
        var b = false;
        for (var i = 0; i < aHref.length; i++) {
          var obj = mapIframe.document.getElementById("myIMAGE" + i);
          if (obj) {
            b = true;
          }
        }
        if (b) {
          var html = "";
          var htitle = "";
          var hurl = "";
          for (var i = 0; i < aHref.length; i++) {
            var obj = mapIframe.document.getElementById("myIMAGE" + i);
            if (obj) {
              var nLeft = parseInt(obj.style.left);
              var nTop = parseInt(obj.style.top);
              var nWidth = parseInt(obj.style.width);
              var nHeight = parseInt(obj.style.height);
              var nRight = nLeft + nWidth;
              var nBottom = nTop + nHeight;
              html += "<area shape='rect' href='" + aHref[i] + "' target='show_frmae' title='" + aTarget[i] + "' onmouseover='javascript:makediv(this);' onmouseout='javascript:cleardiv();' coords='" + nLeft + "," + nTop + "," + nRight + "," + nBottom + "'>";
              htitle += aTarget[i];
              hurl += aHref[i];
              if (i < aHref.length - 1) {
                htitle += ',';
                hurl += ',';
              }
            }
          }
          sUseMap = 'custommap1';
          document.form1.TbContent.value = "<img src='" + sSrc + "' width='" + mapIframe.SOURCEIMAGE.width + "' height='" + mapIframe.SOURCEIMAGE.height + "' usemap='#" + sUseMap + "' /><map name='" + sUseMap + "'>" + html + "</map>";
          document.form1.HTitles.value = htitle;
          document.form1.HUrls.value = hurl;
        } else {
        }
      }
      doInit();
</script>
</body>
</html>
