<script language="JavaScript" src="<%static_url%>/js/overlib_mini.js"><!-- overLIB (c) Erik Bosrup --></script>
<script>
function switch_wrap() {
    if (document.myform.tpl_text.wrap == 'off') {
        document.myform.tpl_text.wrap = 'soft';
        document.myform.bswitch.value = 'Enable Wrap ';
    }
    else {
        document.myform.tpl_text.wrap = 'off';
        document.myform.bswitch.value = 'Disable Wrap';
    }
}

function resize() {
    var obj  = document.myform.tpl_text;
    var rows = document.myform.nrows.value;
    var cols = document.myform.ncols.value;
    if ( isNaN(rows) || isNaN(cols) ||  rows < 0 || cols < 0 ) {
        alert("Rows and Cols should be greater than 0")
        return;
    }
    obj.cols = cols;
    obj.rows = rows;
}

function gotoLine() {
    var obj  = document.myform.tpl_text;
    var line = document.myform.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!')
}    
</script>
<%GList::Tools::template_editor%>
<%if readme%><p class=body><%readme%></p><%endif%>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000; width:500px"></div>
<table border="0" cellPadding="1" cellSpacing="1" valign="top" align=center>
    <tr class=body>
        <td class=body colspan="2"><br />
            <%if message%><%message%><%else%>From here you can quickly edit any of your user or admin templates.<%endif%><br /><br />
        </td>
    </tr>
    <tr class=body>
        <td class=body width=20%>Template Set:</td>
        <td colspan=2>
            <%dir_select%>                          
            <input type="submit" value="Change" name="bchange" class=button />             
        </td>
    </tr>
    <tr class=body>
        <td class=body width=20%>Available templates:</td>
        <td colspan=2><%file_select%>
            <input type="submit" value="Load" name="load" class=button /> <br />
            (* denotes a modified or non-standard template)
        </td>
    </tr>
    <%if tpl_name%>    
    <tr class="body">
      <td class="body">Currently working on:</td>
      <td class="body" colspan="2">
        <a href="javascript:void(0)" onmouseover="return overlib(' \
          <table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bgcolor=&quot;#256A19&quot; border=&quot;0&quot; width=&quot;100%&quot;><tr><td> \
            <table border=&quot;0&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; width=&quot;500&quot;> \
              <tr> \
                <td colspan=&quot;2&quot; class=&quot;body&quot;><font color=&quot;white&quot;><b><u>File information:</u></b></font></td> \
              </tr> \
              <tr> \
                <td bgcolor=&quot;#CCCCCC&quot; width=&quot;1%&quot; class=&quot;body&quot;>Template&nbsp;path:</td> \
                <td bgcolor=&quot;white&quot; class=&quot;body&quot;><%file_path%></td> \
              </tr> \
              <tr> \
                <td bgcolor=&quot;#CCCCCC&quot; class=&quot;body&quot;>File&nbsp;size:</td> \
                <td bgcolor=&quot;white&quot; class=&quot;body&quot;><%file_size%></td> \
              </tr> \
              <tr> \
                <td bgcolor=&quot;#CCCCCC&quot; class=&quot;body&quot;>Status:</td> \
                <td bgcolor=&quot;white&quot; class=&quot;body&quot;><%if file_restore%>Modified from system default<%elseif file_local%>Custom template<%else%>System default<%endif%></td> \
              </tr> \
              <tr> \
                <td bgcolor=&quot;#CCCCCC&quot; class=&quot;body&quot;>Last&nbsp;modified:</td> \
                <td bgcolor=&quot;white&quot; class=&quot;body&quot;><%file_mod_time%></td> \
              </tr> \
            </table> \
        ', FULLHTML, WIDTH, 300<%-- This doesn't actually affect the display with, but does affect the positioning --%>, CENTER);" onmouseout="return nd();"><%tpl_name%></a>
        <%if file_local%><input type="submit" class="button" <%if file_restore%>value="Restore" name="restore=<%tpl_name%>"<%else%>value="Delete" name="delete=<%tpl_name%>"<%endif%> /><%endif%>
      </td>
    </tr>
    <%endif%>    
    <tr class=body>
        <td class=body>Save template as:</td>
        <td colspan=2>
            <input type="text" name="tpl_name" value="<%tpl_name%>" size="40" class=object />            
            <input type="submit" value="Save" name="saveas" class=button />
        </td>
    </tr>
    <tr>
        <td colspan=3>
            <%if is_ie or is_mozilla%>
            <textarea rows="<%if is_ie%>22<%else%>15<%endif%>" name="tpl_text" cols="<%if is_ie%>120<%else%>100<%endif%>" class=object wrap='soft'><%tpl_text%></textarea><br /><br />
            <%else%> <!-- Your browser is Netscape -->
            <textarea rows="<%if rows%><%rows%><%else%>18<%endif%>" name="tpl_text" cols="<%if cols%><%cols%><%else%>90<%endif%>" wrap='on'><%tpl_text%></textarea><br /><br />
            <%endif%>
        </td>
    </tr>    
    <tr class=body>
        <td colspan=3>
            <table width=100% border=0 cellPadding="0" cellSpacing="0">
                <tr class=body>
                    <td class=body>
                        <%if is_ie or is_mozilla%>
                        <input type=button class=button name=bswitch value="Enable Wrap" onclick="switch_wrap()" />
                        <input type=button class=button name=bresize value="Resize" onclick="resize()" />
                        <input type="text" name="nrows" value="<%if is_ie%>22<%else%>15<%endif%>" size="3" maxlength=3 class=object /> rows
                        <input type="text" name="ncols" value="<%if is_ie%>120<%else%>100<%endif%>" size="3" maxlength=3 class=object /> cols
                        <%else%>
                        <input type=submit class=button name=bresize value="Resize" />
                        <input type="text" name="nrows" value="<%if rows%><%rows%><%else%>18<%endif%>" size="3" maxlength=3 class=object /> rows
                        <input type="text" name="ncols" value="<%if cols%><%cols%><%else%>90<%endif%>" size="3" maxlength=3 class=object /> cols
                        <%endif%>
                     </td>
                     <td align=right class=body>
                        <%if is_ie%>
                         <script>                        
                            document.write("Line:<input name='line' size=3 maxlength=4 class='object' /> <input name=goto value=' Go ' type=button onclick='gotoLine()' class=button />") 
                        </script>
                     <%endif%>                    
                     </td>
                </tr>
            </table>
         </td>
     </tr> 
 </table>
</div>
 
