<html>
<head>
<title>FileMan</title>
<link rel="stylesheet" href="<%html_url%>/<%scheme%>.css">
<script>
function detach () {
 var myrand = Math.random();
 var url = '<%http_ref%>';
 document.frm_main.switch_html.value = 1;
 window.location = 'url';

 void (0);
}

function switch_wrap() {
    if (document.frm_main.content.wrap == 'off') {
        document.frm_main.content.wrap = 'soft';
        document.frm_main.bswitch.value = 'Wrap off';
    }
    else {
        document.frm_main.content.wrap = 'off';
        document.frm_main.bswitch.value = 'Wrap on';
    }
}

function gotoLine() {
    var obj  = document.frm_main.content;
    var line = document.frm_main.line.value;
    if (obj.innerText) {
        var items = obj.innerText.split("\n");
        if ( ( isNaN(line) )|| ( line > items.length ) || ( line <=0 ) || !line) {
            alert('Please enter a number between 1 to ' + items.length);
            return;
        }
        var lineContent = items[line-1];
        var rangContent = '';
        for (var i=0; i<line; i++) rangContent += items[i];

        var items    = rangContent.split(lineContent);
        var numTimes = (items.length > 1) ? ( items.length-1 ) : 1;

        var txtRange = obj.createTextRange();
        var found    = txtRange.findText(rangContent);
        if (found) {
            var tmp = 0;
            while (txtRange.findText(lineContent)) {
                tmp++;
                if ( tmp == numTimes ) {
                    txtRange.select();
                    break;
                }
                txtRange.moveStart("character",1);
            }
            txtRange.scrollIntoView();
        }
    }
    else alert('The content is empty!')
}

function loadbody() {
  top.loadStatus("<%if filename%><%status%><%else%>Editor text file...<%endif%>");
}
</script>
</head>
<body  class="bg_main" leftmargin="5" topmargin="5" onload="loadbody()">
<table width="100%" height="100%" border="0" style="border:1px solid #326AAF" cellspacing="0" cellpadding="0" align="center" class="bg_window">
  <form name="frm_main" action='<%http_ref%>' method="post">
  <tr>
    <td valign="top" height="100%">
      <table width="100%" align=center border="0" cellspacing="0" cellpadding="0" bgcolor="#000066" height="3%">
        <tr>
          <td class="header_format" height=20 width=60%>&nbsp;<Font color=white><b>File Editor&nbsp; <%if filename%><%filename%><%endif%></b></font></td>
          <td class="header_format" height=20 width=40% align=right><a href="<%http_ref%>?fdo=cmd_main_display&work_path=<%work_path%>&<%url_opts%>"><img src="<%html_url%>/icons/close.gif" border=0></a></td>
        </tr>
      </table>
      <table width="99%"  align=center border="0" cellspacing="1" cellpadding="1" height="95%">
          <tr height=7%>
            <td>
                <table width='100%' border="0" cellspacing="1" cellpadding="1">
                    <%if old%>
                    <tr>
                     <td><%font%>
                      <%if writeable%><input type="submit" name="save" value="  Save  " class='submit'><%else%>(Not Writeable)<%endif%>&nbsp;-
                      <input type="submit" name="saveas" value="Save As ..."  class='submit'>
                      <input type="text" name="filenew" size=30 value='<%if filenew%><%filenew%><%endif%>'  class='object'>
                      <input type="hidden" name="filename" value='<%if filename%><%filename%><%endif%>'></font>
                      </td>
                    <%else%>
                    <tr>
                        <td><%font%>File name:&nbsp;
                          <input type="text" name="filenew" size=40 value='<%if filename%><%filename%><%endif%>'  class='object'>
                          <input type="submit" name="saveas" value="  Save  "  class='submit'>
                        </td>
                    <%endif%>
                    <%if ie_version >= 5.5 or mozilla_version >= 1.4%>
                        <td width="20%" align="right"><input class="submit" type=submit name="switch_edit" value="<%if use_html%>Switch to Text<%else%>Switch to HTML<%endif%>"></td>
                    <%endif%>
                    </tr>
                </table>
            </td>
          </tr>
          <%if msg%>
          <tr height=2%>
            <td><%font%><font color=red><b><%msg%></b></font></font></td>
          </tr>
          <%endif%>
         <%if use_html%>
            <tr height="100%">
                <td align="center" valign="top"><%include file_html_editor.html%><BR></td>
            </tr>
         <%else%>
            <tr>
               <td align="center" width="99%" valign="top">
                  <input type="hidden" name="use_html" value="0">
                  <textarea name="content" class="object" style="width:100%" rows="<%if rows%><%rows%><%else%>20<%endif%>" wrap='off'><%if content%><%content%><%endif%></textarea>
               </td>
            </tr>
            <tr>
              <td>
                <table  border="0" cellspacing="1" cellpadding="1" width="100%">
                    <tr>
                        <td height="35" valign="top"><%font%>
                            <%if is_ie%><input name=bswitch value='Wrap on'  class='submit' type=button onclick='javascript:switch_wrap()'><%endif%>
                            <input type="submit" name="resize" value="Resize"  class='submit'>
                            &nbsp;<input name=rows  class='object' value='<%if rows%><%rows%><%else%>20<%endif%>' size=3 maxlength=3>&nbsp;rows</font>
                        </td>
                        <%if is_ie%>
                        <td align=right>
                          <%font%>Line:<input name='line' size=3 maxlength=4 class='object'><input name=goto value=' Go ' type=button onclick='gotoLine()' class=submit></font>
                        </td>
                        <%endif%>
                    </tr>
                </table>
             </td>
           </tr>
        <%endif%>
     </table>
    </td>
  </tr>
  <input type=hidden name='fileold' value='<%if old%><%old%><%endif%>'>
  <input type=hidden name='work_path' value='<%work_path%>'>
  <input type=hidden name='cmd_do' value='cmd_editor'>
  <input type=hidden name="page" VALUE="">
  <input type=hidden name="txt_input" VALUE="">
  <input type=hidden name="status" value="<%if status%><%escape_html status%><%endif%>">
  <input type=hidden name='writeable' value='<%if writeable%><%writeable%><%endif%>'>
  <input type=hidden name=do value="fileman">

  <!--Search options-->
  <input type=hidden name="c_regex" VALUE="">
  <input type=hidden name="c_case" VALUE="">
  <input type=hidden name="c_word" VALUE="">
  <input type=hidden name="c_content" VALUE="">
  <input type=hidden name="c_bak" VALUE="">
  <input type=hidden name="scope" VALUE="">
  <input type=hidden name="txt_with" VALUE="">

  <%ifnot user_sessions%>
  <!--multi users-->
  <input type=hidden name="session_id" value="<%session_id%>">
  <%endif%>
  <%if root_selected%>
  <input type=hidden name='root_selected' value="<%root_selected%>">
  <%endif%>
  </form>
</table>
</body>
</html>
