<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="editor.aspx.cs" Inherits="MYAPP.KREditor.editor" %>
<%@ Register Assembly="ComponentArt.Web.UI" Namespace="ComponentArt.Web.UI" TagPrefix="ComponentArt" %>

<!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>
<style>
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.textarea {
	width: 99%;
	height: 500px;
}
</style>
<link href="/CSS/main.css" rel="stylesheet" type="text/css" />
<link href="splitterStyle.css" type="text/css" rel="stylesheet" />
<link href="treeStyle.css" type="text/css" rel="stylesheet" />
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript" src="Scripts/common.Js"></script>
<script language="JavaScript" type="text/javascript" >
    var oWindow = window.opener;
    var _Value;
    function resizeTree(DomElementId, NewPaneHeight, NewPaneWidth) {
        TV_Tree.Render();
    }
    function nodeSelect(node) {
        _Value = node.GetProperty('Value');
        _Target = node.GetProperty('Target');
        if (_Value != null) {
            $('intro').innerHTML = _Value;
        }
        else {
            $('intro').innerHTML = "";
        }
        $("posteditor_textarea").focus();
        storeCaret($("posteditor_textarea"));
    }
	
	function getParam(paramName)
	{
			paramValue = "";
			isFound = false;
			if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=")>1)
			{
				arrSource = unescape(this.location.search).substring(1,this.location.search.length).split("&");
				i = 0;
				while (i < arrSource.length && !isFound)
				{
					if (arrSource[i].indexOf("=") > 0)
					{
						 if (arrSource[i].split("=")[0].toLowerCase()==paramName.toLowerCase())
						 {
							paramValue = arrSource[i].split("=")[1];
							isFound = true;
						 }
					}
					i++;
				}   
			}
	   return paramValue;
	}

    function doit() {
        if (_Value != null) {
            if (_Target != null) {
                insertAtCaret($('posteditor_textarea'), decodeURI(_Value));
            }
            else {
                var val = window.showModalDialog("Window.aspx?Tour_ID="+getParam("Tour_ID")+"&action=" + _Value, target = "blank", "dialogWidth=400px;dialogHeight=300px;status:no;edge:raised ");
                var value = val;
                if (value == undefined) {
                    value = null;
                }
                else {
                    insertAtCaret($('posteditor_textarea'), val);
                }
            }
        }
		else
		{
			alert("请选择制定函数");
		}
    }

        function init() {
            $("posteditor_textarea").value = oWindow.$('<%=Request.QueryString["ID"]%>').value;
        }
        function returnvalue() {
            try {
                oWindow.$('<%=Request.QueryString["ID"]%>').value = $("posteditor_textarea").value;
                window.close();
            } catch (exception) { }
        }
    self.focus();
</script>
</head>
<body style="margin:0px; padding:0px; overflow-y:hidden; overflow-x:hidden" scroll="no" onload="init();">
<form id="theform" runat="server">
  <table width="100%" height="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC"
            class="board_kong">
    <tr>
      <td valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
          <tr>
            <td style="border-bottom: #CCCCCC 1px solid; height: 24px"><table class="title_table">
                <tr>
                  <td width="200" class="l_title">[脚本事件编辑器]</td>
                  <td class="l_title"><table width="100%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#EBEBEB"
                                                class="board_kong">
                      <tr>
                        <td align="center" nowrap="nowrap" class="left_title"><input type="button" class="width80px" value="添　　加" onclick="doit();" /></td>
                        <td><div id="intro" style="color:#360"></div></td>
                      </tr>
                    </table></td>
                  <td width="120" align="center"><input type="button" class="width80px"  onclick="returnvalue();" value="确定返回"/></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td valign="top"><table width="100%" height="100%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#EBEBEB"
                                                class="board_kong">
                <tr>
                  <td><ComponentArt:Splitter runat="server" ID="sp" FillHeight="true" FillWidth="true"
                                    ImagesBaseUrl="images/Splitter/">
                      <Layouts>
                        <ComponentArt:SplitterLayout>
                          <Panes Orientation="Horizontal" SplitterBarCssClass="HorizontalSplitterBar" SplitterBarActiveCssClass="ActiveSplitterBar"
                                                SplitterBarWidth="5">
                            <ComponentArt:SplitterPane PaneContentId="TreeViewContent" Width="200" MinWidth="0"
                                                    ClientSideOnResize="resizeTree" CssClass="SplitterPane" />
                            <ComponentArt:SplitterPane>
                            <panes orientation="Vertical" splitterbarcollapseimageurl="splitter_verCol.gif" splitterbarcollapsehoverimageurl="splitter_verColHover.gif"
                                                        splitterbarexpandimageurl="splitter_verExp.gif" splitterbarexpandhoverimageurl="splitter_verExpHover.gif"
                                                        splitterbarcollapseimagewidth="116" splitterbarcollapseimageheight="5" splitterbarcssclass="VerticalSplitterBar"
                                                        splitterbarcollapsedcssclass="CollapsedVerticalSplitterBar" splitterbaractivecssclass="ActiveSplitterBar"
                                                        splitterbarwidth="5">
                              <ComponentArt:SplitterPane PaneContentId="MainContent" CssClass="SplitterPane" />
                            </panes>
                            </ComponentArt:SplitterPane>
                          </Panes>
                        </ComponentArt:SplitterLayout>
                      </Layouts>
                      <Content>
                        <ComponentArt:SplitterPaneContent id="TreeViewContent">
                          <ComponentArt:TreeView ID="TV_Tree" Height="100%" Width="100%" EnableViewState="false"
                                                ClientSideOnNodeSelect="nodeSelect" KeyboardEnabled="false" ShowLines="true"
                                                DisplayMargin="false" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode"
                                                MultipleSelectedNodeCssClass="MultipleSelectedTreeNode" HoverNodeCssClass="HoverTreeNode"
                                                NodeEditCssClass="NodeEdit" CutNodeCssClass="CutTreeNode" MarginWidth="20" DefaultMarginImageWidth="24"
                                                DefaultMarginImageHeight="20" LineImageWidth="19" LineImageHeight="20" NodeLabelPadding="3"
                                                ParentNodeImageUrl="folders.gif" LeafNodeImageUrl="folder.gif" CollapseImageUrl="exp.gif"
                                                ExpandImageUrl="col.gif" ExpandCollapseImageWidth="19" ExpandCollapseImageHeight="20"
                                                ImagesBaseUrl="images/tree/" LineImagesFolderUrl="images/lines/" runat="server" CausesValidation="False" CollapseNodeOnSelect="False" MultipleSelectEnabled="False" ViewStateMode="Disabled" ExpandNodeOnSelect="False" ExpandSelectedPath="False"> </ComponentArt:TreeView>
                        </ComponentArt:SplitterPaneContent>
                        <ComponentArt:SplitterPaneContent id="MainContent">
                          <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td valign="top"><textarea name="message" rows="10" cols="60" style="width:98%; height:700px" tabindex="100" id="posteditor_textarea" onselect="javascript: storeCaret(this);" onclick="javascript: storeCaret(this);" onkeyup="javascript:storeCaret(this);" ></textarea></td>
                            </tr>
                          </table>
                        </ComponentArt:SplitterPaneContent>
                      </Content>
                    </ComponentArt:Splitter></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
</body>
</html>