<html>
<head>
<script language="JavaScript" src="<%html_url%>/fileman.js"></script>
<script>
var fm_commandbar, fm_command;
var ie = (document.all)? true:false;
var url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?<%if url_opts%><%url_opts%><%endif%>';
var workPath = '';
var Root;

function isMainForm(main_screen) {
    var main_form = window.top.mainfrm.document.frm_main;
    if (main_screen) {
      if (typeof(window.top.mainfrm.frm_main) == 'unknown' || typeof(main_form) == 'undefined' || typeof(main_form.main_screen) == 'undefined') {
          alert("Please return to main screen and execute the command again");
          return false;
      }
    }
    else {
      if (typeof(window.top.mainfrm.frm_main) == 'unknown' || typeof(main_form) == 'undefined') {
          alert("Please return to main screen and execute the command again");
          return false;
      }
    }
    return true;
}

function loadStatus (msg) {
    var status = (msg != "") ? msg : window.top.mainfrm.document.frm_main.status.value;
    var html   = "<table border='0' cellpadding='3' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:&nbsp;</font></td><td><%font%>" + status + "</font></td></tr></table>\n";

    if (fm_command) fm_command.innerHTML = html;
}

function wasDownload() {
    if (ie && typeof(window.top.mainfrm.document) == "unknown" ) {
        if (workPath && !Root) url += "work_path=" + workPath;
        alert("Due to security permissions in Internet Explorer, your browser must be reloaded before you can continue.");
        window.location.reload(url);
        return true;
    }
}

function regex() {
    var foo = top.bottomfrm.document.frm_footer
    if (foo.c_regex.checked)
        foo.c_content.checked = true
}

function js_open_link(action, frame, file_name, root) {
    Root = root;
    if (wasDownload()) return;
    var main_form   = window.top.mainfrm.document.frm_main;
    var work_path 
    if (typeof(main_form) != 'undefined') work_path = main_form.work_path.value;

    if (root) {
        if (typeof (window.top.bottomfrm.document.frm_footer) != 'undefined' && typeof(window.top.bottomfrm.document.frm_footer.p_username) != "undefined" && url.search("show_passwd") == -1) eval("window.top." + frame).location = url + ';show_passwd=1;fdo=' + action;
        else eval("window.top." + frame).location = url + ";fdo=" + action;
    }
    else {
        if (file_name) eval("window.top." + frame).location = url + ";fdo=" + action + ";page=" + file_name + ';work_path=' + work_path;
        else eval("window.top." + frame).location = url + ";fdo=" + action + ";work_path=" + work_path;
    }
}

function js_download(file_name) {
    if (wasDownload()) return;
    var main_form = window.top.mainfrm.document.frm_main;
    var work_path = main_form.work_path.value;
    window.top.mainfrm.location = url + ";fdo=cmd_download;c_edit=" + file_name + ";work_path=" + work_path;
}

function js_cmd_multi_upload() {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    main_form.cmd_do.value = "cmd_show";
    main_form.page.value   = "multi_upload.html";
    main_form.submit();
    return;
}

function js_progress_bar(action, msg) {
    if (wasDownload()) return;

    var doc = top.bottomfrm.document ;
    var html = "<table><tr><td><%font%>\n" +
      "<span id='msg'><%font%>Uncompress: " + msg + "</font></span>\n" +
      "</td></tr></table>\n" +
      "<table><tr><td><table width='500' border='0' style='border:1px solid #A1A576' cellspacing='0' cellpadding='0' bgcolor='#E6E6E6' height=18>\n" +
      "<tr><td><table border='0' cellspacing='0' cellpadding='0' bgcolor='#999999'>\n" +
      "<tr><td><img src='<%html_url%>/icons/1pixel.gif' id=progress name=progress height=15 width=0></td></tr></table></td></tr></table></td>\n" +
      "<td align=left><%font%><span id='percent'>0%</span></font>\n" +
      "</td></tr></table>\n";
    if (fm_command) fm_command.innerHTML = html;
}

function createFrames() {
    window.status = "File Manager - Gossamer Threads Inc.";
    var bottom_doc = top.bottomfrm.document;
    var top_doc    = top.topfrm.document;

// Create top frame    
    if (top_doc.getElementById("fm_toolbar")) {
      var html = "<table border='1' cellpadding='3' cellspacing='0' width='100%'>\n" +
        "<tr><td width='20' align='right'><%font%><b>Fileman:</b></font></td>\n" +
        "<td><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td><nobr>\n" +
        "<form name='frmroot' action='fileman.cgi' method=post target='_top' style='margin:0px'>\n" +
        "<%if root_select%><%root_select%><%endif%><%font%><span id='current_path'><%if string%><%string%><%else%><a href = \"javascript:top.js_open_link('cmd_main_display','mainfrm','',1)\">root</a>:<%endif%></span></font>\n" +
        "<input type=hidden name=do value='fileman'>\n" +
        "<%ifnot user_sessions%><input type=hidden name=session_id value='<%if session_id%><%session_id%><%endif%>'><%endif%></form></td>\n" +
        "<td align='right'><nobr><form name='frm_top' action='<%http_ref%>' method=post target='mainfrm' onsubmit='return check_input();' style='margin:0px'>\n" +
        "<%font%><b>Directory:</b></font><input type=hidden name=cmd_do value='cmd_cd'>\n" +
        "<%if root_selected%><input type=hidden name='root_selected' value='<%root_selected%>'><%endif%>\n" +
        "<input type=hidden name='work_path' value='<%if work_path%><%work_path%><%endif%>'>\n" +
        "<input name='txt_input' value='' size='20' class='object'>\n" +
        "<input type=hidden name=do value='fileman'>\n" +
        "<input type=submit value='Go' class='submit'></form>\n" +
        "</td></tr></table></td>\n" +
        "<td rowspan='2' width='90'><a target=_blank href= 'http://www.gossamer-threads.com/scripts/fileman/'><img src='<%html_url%>/icons/fileman_logo.gif' border=0 hspace='2'></a></td></tr>\n" +
        "<tr><td align='right'><%font%><b>Tools:</b></font></td>\n" +
        "<td><%font%>" + html_top(<%if show_all%>'all'<%endif%>) + "</font></td></tr></table>";

      top_doc.getElementById("fm_toolbar").innerHTML = html;
      setFocus(top_doc.frm_top.txt_input);
    }
    
// Create bottom frame
    fm_commandbar = bottom_doc.getElementById("fm_commandbar");
    fm_command    = bottom_doc.getElementById("fm_command");
    if (fm_commandbar && fm_command) {
      fm_commandbar.innerHTML = html_bottom();
      <%if show_all or $cmd_search%>
        fm_command.innerHTML = html_search();
      <%else%>
        loadStatus("Welcome to File Manager is provided by <a href='http://www.gossamer-threads.com/scripts/fileman/index.htm' target='_top'>Gossamer Threads Inc.</a>");
      <%endif%>      
    }    
}

function html_top(show) {
  if (show == 'all')
    return "<a href='javascript:top.js_cmd_search()'>Search</a> | \n" +
      "<a href='javascript:top.js_cmd_replace()'>Replace</a> | \n" +
      "<a href='javascript:top.js_cmd_command(1)'>Command</a> | \n" +
      "<a href='javascript:top.js_cmd_upload(1)'>Upload</a> | \n" +
      "<a href='javascript:top.js_open_link(\"cmd_show\",\"mainfrm\",\"file_editor.html\")'>New File</a> | \n" +
      "<a href='javascript:top.js_cmd_makedir(1)'>New Dir</a> | \n" +
      "<a href='javascript:top.js_open_link(\"cmd_show_passwd\",\"mainfrm\")'>Protect</a> | \n" +
      "<a href='javascript:top.js_open_link(\"cmd_show\",\"mainfrm\",\"preferences.html\")'>Prefs</a>";
  else
    return "<%if cmd_search%><a href='javascript:top.js_cmd_search()'>Search</a><%endif%>\n" +
    "<%if cmd_replace%> | <a href='javascript:top.js_cmd_replace()'>Replace</a><%endif%>\n" +
    "<%if cmd_command%> | <a href='javascript:top.js_cmd_command(1)'>Command</a><%endif%>\n" +
    "<%if cmd_upload%> | <a href='javascript:top.js_cmd_upload(1)'>Upload</a><%endif%>\n" +
    "<%if cmd_editor%> | <a href='javascript:top.js_open_link(\"cmd_show\",\"mainfrm\",\"file_editor.html\")'>New File</a><%endif%>\n" +
    "<%if cmd_makedir%> | <a href='javascript:top.js_cmd_makedir(1)'>New Dir</a><%endif%>\n" +
    "<%ifnot srv_soft%><%if cmd_passwd%> | <a href='javascript:top.js_open_link(\"cmd_show_passwd\",\"mainfrm\")'>Protect</a><%endif%><%endif%>\n" +
    "<%if cmd_preferences%> | <a href='javascript:top.js_open_link(\"cmd_show\",\"mainfrm\",\"preferences.html\")'>Prefs</a><%endif%>\n" +
    "<%if multi or single%><%if cmd_admin%>\n" +
    "| <a href='javascript:top.js_open_link(\"user_form\",\"mainfrm\")'>Password</a><%endif%>\n" +
    "| <a href='<%http_ref%>?<%if multi%>do=log_off<%else%>fdo=log_off<%endif%>&<%url_opts%>' target=_top>Sign Out</a>\n" +
    "<%endif%>";
}

function html_bottom() {
    var num_objects,total_space;
    var main_form = window.top.mainfrm.document.frm_main;
    if (typeof(main_form) != "undefined" && typeof(main_form.num_objects) != "undefined")
        num_objects = main_form.num_objects.value;

    if (typeof(main_form) != "undefined" && typeof(main_form.total_space) != "undefined")
        total_space = main_form.total_space.value;

    var html = "<table border='1' bgcolor='#E9E9E9' cellpadding='0' cellspacing='0' width=100%><tr><td>\n" +
      "<table border='0' cellpadding='0' cellspacing='0' width=100%>\n" +
      "<tr height='22'>";
    <%if show_all%>
      html += "<td width='73%' valign='top'>&nbsp;<%font%><a href='javascript:top.js_cmd_edit()'>Edit</a> | \n" +
        "<a href='javascript:top.js_cmd_download(1)'>Download</a> | \n" +
        "<a href='javascript:top.js_cmd_copy(1)'>Copy</a> | \n" +
        "<a href='javascript:top.js_cmd_delete()'>Delete</a> | \n" +
        "<a href='javascript:top.js_cmd_move(1)'>Move</a> | \n" +
        "<a href='javascript:top.js_cmd_chmod(1)'>Chmod</a> | \n" +
        "<a href='javascript:top.js_cmd_tail(1)'>Tail</a> | \n" +
        "<a href='javascript:top.js_cmd_perl(1)'>Perl</a> | \n" +
        "<a href='javascript:top.js_cmd_diff(1)'>Diff</a> | \n" +
        "<a href='javascript:top.js_cmd_tar(1)'><%if have_azip%>Compress<%else%>Tar<%endif%></a>\n" +
        " | <a href='javascript:top.js_cmd_print()'>Print</a> | <a href='javascript:top.js_cmd_help()'>Help</a></font></td>\n";
    <%else%>
      html += "<td width='73%' valign='top'>&nbsp;<%font%><%if cmd_edit%><a href='javascript:top.js_cmd_edit()'>Edit</a><%endif%>\n" +
        "<%if cmd_download%> | <a href='javascript:top.js_cmd_download(1)'>Download</a><%endif%>\n" +
        "<%if cmd_copy%> | <a href='javascript:top.js_cmd_copy(1)'>Copy</a><%endif%>\n" +
        "<%if cmd_delete%> | <a href='javascript:top.js_cmd_delete()'>Delete</a><%endif%>\n" +
        "<%if cmd_move%> | <a href='javascript:top.js_cmd_move(1)'>Move</a><%endif%>\n" +
        "<%if cmd_chmod%> | <a href='javascript:top.js_cmd_chmod(1)'>Chmod</a><%endif%>\n" +
        "<%if cmd_tail%> | <a href='javascript:top.js_cmd_tail(1)'>Tail</a><%endif%>\n" +
        "<%if cmd_perl%> | <a href='javascript:top.js_cmd_perl(1)'>Perl</a><%endif%>\n" +
        "<%if cmd_diff%> | <a href='javascript:top.js_cmd_diff(1)'>Diff</a><%endif%>\n" +
        "<%if cmd_tar%> | <a href='javascript:top.js_cmd_tar(1)'><%if have_azip%>Compress<%else%>Tar<%endif%></a><%endif%>\n" +
        " | <a href='javascript:top.js_cmd_print()'>Print</a>\n" +
        " | <a href='javascript:top.js_cmd_help()'>Help</a></font></td>\n";
    <%endif%>
    html += "<td width='27%' align=right><nobr><%font%>\n";
    if (typeof(total_space) != "undefined" && typeof(num_objects) != "undefined")
      html += "<%font%><font size=1><span id='d_msg'><b>0</b> of <b>" + print_filesize(total_space) + "</b> in <b>0</b> of <b>" + num_objects + "</b> files selected&nbsp;</font></font></span>";

    html += "</font></td></tr></tr></table></td></tr></table>";
    return html;
}

function html_search(work_path) {
    if (typeof(work_path) == "undefined") work_path = "Root";
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px' onSubmit='return top.checkCommand(top.checkSearch());'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr height='28'><td><%font%>Search:</font></td><td valign='bottom'>\n" +
      "&nbsp;<select class='object' name=scope><option value=1>All of " + work_path + "<option value=2>Selected Files</select>\n" +
      "<input name=txt_input size=50 class='object'> <input type='submit' class='submit' name=submit value='Search'></td></tr>\n" +
      "<tr><td><%font%>Options:</td>\n" +
      "<td valign='bottom'><%font%><input name='c_case' type=checkbox value=1 >Case Sensitive\n" +
      "&nbsp;<input name='c_content' type=checkbox value=1 >Search Contents\n" +
      "&nbsp;<input name='c_regex' type=checkbox value=1 onclick='top.regex()'>Expression</font></td></tr>\n" +
      "</table><input type=hidden name=work_path value='" + work_path +"'>\n" +
      "<input type=hidden name=cmd_do value='cmd_search'></form></body>\n";
    return html;
}

function html_replace(work_path) {
    if (typeof(work_path) == "undefined")
      work_path = "Root";

    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px' onsubmit='return top.checkCommand(top.checkReplace());'>\n" +
      "<table border='0' cellpadding='2' cellspacing='1'>\n" +
      "<tr height='28'><td><%font%>Replace:</font></td><td valign='bottom'><%font%>\n" +
      "&nbsp;<select name=scope class='object'><option value=1>All of "+ work_path +"<option value=2>Selected Files</select>\n" +
      "<input name=txt_input class='object' size=25> with <input name=txt_with class='object'size=25>\n" +
      "<input type=submit class='submit' name=submit value='Replace'></td></tr>\n" +
      "<tr><td><%font%>Options:</font></td>\n" +
      "<td valign='bottom'><%font%><input name='c_case' type=checkbox value=1>Case Sensitive\n" +
      "<input name='c_regex' type=checkbox value=1 >Expression\n" +
      "<input name='c_word' type=checkbox value=1 >Whole word\n" +
      "<input name='c_bak' type=checkbox value=1 >Create .bak</td></tr>\n" +
      "</table><input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_replace'></form>\n";
  return html;
}

function html_command(status, work_path) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onSubmit='return top.checkCommand(top.checkFMCommand(\"Please enter the command you wish to execute\"), true)'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0' >\n" +
      "<tr><td><%font%>Status:</td><td><%font%>" + status + "</font></td><td><%font%><input type=checkbox name='long'>Long Running</font></td></tr>\n" +
      "<tr><td ><%font%>Command:</font></td><td><%font%>\n" +
      "<input name=txt_input class='object' size=50>&nbsp;<input type=submit class='submit' name=submit value='Execute'>&nbsp;</td><td><input type=button class='submit' name='runfile' value='Run selected file' onclick='return top.checkCommand()'></td></tr></table>\n" +
      "<input type=hidden name=work_path value='"+ work_path +"'>\n" +
      "<input type=hidden name=cmd_do value='cmd_command'></form>\n";
    return html;
}

function html_upload(status, work_path) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' enctype='multipart/form-data' style='margin:0px' onsubmit='return top.checkUpload()'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%>" +
      "<span id='d_status'>" + status + "</font></span></td>\n" +
      "<td><%font%><input name=overwrite type=checkbox value='1'>Overwrite &nbsp;<a href='javascript:top.js_cmd_multi_upload()'>Multiple Upload</a></td></tr>\n" +
      "<tr><td><%font%>File:</font></td><td><%font%><select name='type' class='object'><option value='ascii'>Ascii</option><option value='binary'>Binary</option><option value='auto' selected>Auto</option></select><input name=txt_input class='object' type=file size=30>\n" +
      "<input type=submit class='submit' name=Upload value='Upload'></font></td><td><%font%>&nbsp;File name as <select name='name' class='object'><option value='default'>default</option><option value='uppercase'>uppercase</option><option value='lowercase'>lowercase</option></select></font>\n" +
      "</td></tr></table>\n" +
      "<input type=hidden name=work_path value=" + work_path + "><input type=hidden name=cmd_do value='cmd_upload'>\n" +
      "<input type=hidden name=do value='fileman'>\n" +
      "<%ifnot user_sessions%><input type=hidden name=session_id value='<%if session_id%><%session_id%><%endif%>'><%endif%>\n" +
      "<%if root_selected%><input type=hidden name=root_selected value='<%root_selected%>'><%endif%>\n" +
      "</form></body>\n";
    return html;
}

function html_makedir(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onSubmit='return top.checkCommand(top.checkFMCommand(\"Please enter the name of the directory you wish to create\"))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td>\n" +
      "<%font%><span id='d_status'>" + status + "</font></span>\n" +
      "</font></td></tr><tr><td><%font%>Directory:</font></td><td>\n" +
      "<input name=txt_input class='object' size=50> <input type='submit' class='submit' name=submit value=' Create '></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_makedir'></form>\n";
    return html;
}

function html_download(status) {
    var html = "<body><form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px' onsubmit='return top.checkDownload(<%if srv_soft%>1<%endif%>)'>\n" +
      "<table border='0' cellpadding='2' cellspacing='2'>\n" +
      "<tr><td width='9%'><%font%>Status:</font></td><td><%font%>" + status + "</td></tr>\n" +
      "<tr><td><%font%>Options:</font></td><td><%font%><select name='type' class='object'><option value='ascii'>Ascii</option><option value='binary' selected>Binary</option><option value='auto'>Auto</option></select>\n" +
      "&nbsp;&nbsp;&nbsp;&nbsp;Compressed type: <select name='zip_type' class='object'><option value=0 selected>None ( a file )</option><option value='1'>.tar</option>\n" +
      "<%if have_gzip%><option value=2>.tar.gz</option><%endif%><%if have_azip%><option value='3'>.zip</option><%endif%></select></font>\n" +
      "&nbsp;&nbsp;<input type=submit class='submit' name=Upload value='Download'></font>\n" +
      "</td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'><input type=hidden name=cmd_do value='cmd_download'>\n" +
      "<input type=hidden name=do value='fileman'>\n" +
      "<%ifnot user_sessions%><input type=hidden name=session_id value='<%if session_id%><%session_id%><%endif%>'><%endif%>\n" +
      "<%if root_selected%><input type=hidden name=root_selected value='<%root_selected%>'><%endif%>\n" +
      "</form></body>";
    return html;
}

function html_copy(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onsubmit='return top.checkCommand(top.checkFMCommand(\"Please enter where you would like to copy the files.\"))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%><span id='d_status'>" + status + "</font></span></td></tr>\n" +
      "<tr><td><%font%>Directory:</font></td><td><%font%>\n" +
      "<input name=txt_input class='object' size=50 value=''> <input type=submit class='submit' name=submit value='  Copy  '></font></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_copy'></form>\n";
    return html;
}

function html_move(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onSubmit='return top.checkCommand(top.checkFMCommand(\"Please enter where you would like to move the files.\"))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%><span id='d_status'>" + status + "</font></span></td></tr>\n" +
      "<tr><td><%font%>Directory:</font></td><td><%font%>\n" +
      "<input name=txt_input class='object' size=50> <input type='submit' class='submit' name=submit value='  Move  '></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_move'></form>\n";
    return html;
}

function html_chmod(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px' onsubmit='return top.checkCommand(top.checkFMCommand(\"Please enter the permission.\", true))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td colspan=3>\n" +
      "<table border='0' width='90%' cellpadding='0' cellspacing='0'>\n" +
      "<tr><td><%font%><span id='d_status'>" + status + "</font></span></td>\n" +
      "<td align='right'><%font%><input name='recursive' value='1' type='checkbox' align='middle'>Recursive</font></td></tr>\n" +
      "</table></td></tr>\n" +
      "<tr><td><%font%>Permission:</font></td><td>\n" +
      "<input name=txt_input class='object' size=3 maxlength=4><%font%> as numerical or </font></td>\n" +
      "<td><table border='0' cellpadding='1' cellspacing='1' bgcolor=#999999>\n" +
      "<td bgcolor=#D6D6D6><%font%>&nbsp;r:<input type=checkbox name=ar value=1 onclick='top.init_chmod()'> w:<input type=checkbox name=aw value=1 onclick='top.init_chmod()'>  x:<input type=checkbox name=ax value=1 onclick='top.init_chmod()'></td>\n" +
      "<td bgcolor=#D6D6D6><%font%>&nbsp;r:<input type=checkbox name=ur value=1 onclick='top.init_chmod()'> w:<input type=checkbox name=uw value=1 onclick='top.init_chmod()'>  x:<input type=checkbox name=ux value=1 onclick='top.init_chmod()'></td>\n" +
      "<td bgcolor=#D6D6D6><%font%>&nbsp;r:<input type=checkbox name=gr value=1 onclick='top.init_chmod()'>  w:<input type=checkbox name=gw value=1 onclick='top.init_chmod()'>  x:<input type=checkbox name=gx value=1 onclick='top.init_chmod()'></td>\n" +
      "<td bgcolor=#D6D6D6><%font%>&nbsp;r:<input type=checkbox name=wr value=1 onclick='top.init_chmod()'>  w:<input type=checkbox name=ww value=1 onclick='top.init_chmod()'>  x:<input type=checkbox name=wx value=1 onclick='top.init_chmod()'></td></tr></table></td>\n" +
      "<td><input type='submit' class='submit' name=submit value='Chmod'></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_chmod'></form>\n";
    return html;
}

function html_tail(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onsubmit='return top.checkCommand(top.checkFMCommand(\"Please select how many lines you would like to see.\", true))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%><span id='d_status'>" + status + "</font></span></td></tr>\n" +
      "<tr><td><%font%>Command:</font></td><td><%font%>\n" +
      "<input name=txt_input class='object' size=10 value='25'> <input type='submit' class='submit' name=submit value='  Tail  '>&nbsp;&nbsp;Refresh options:&nbsp;\n" +
      "<select name=retime class='object'><option selected><option value=2>2<option value=5>5<option value=10>10<option value=30 >30<option value=60>60</select> seconds</font></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_tail'></form>";
    return html;
}

function html_perl(status, work_path) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onsubmit='return top.checkCommand()'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%><span id='d_status'>" + status + "</font></span>\n" +
      "<input name=txt_input type=hidden><input type=submit class='submit' name=submit value='  Check  '></font></td></tr></table>\n" +
      "<input type=hidden name=work_path value='"+ work_path +"'>\n" +
      "<input type=hidden name=cmd_do value='cmd_perl'></form>\n";
    return html;
}

function html_diff(status) {
    var html = "<form name='frm_footer' action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onSubmit='return top.checkCommand(top.checkFMCommand(\"Please enter path to the file you would like diff with this file.\"))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%>" + status + "</font></td></tr>\n" +
      "<tr><td><%font%>Command:</font></td><td><%font%>\n" +
      "<input name='txt_input' class='object' size=50> <input type=submit class='submit' name=submit value='  Diff  ' ></font></td></tr></table>\n" +
      "<input type='hidden' name='work_path' value='<%work_path%>'>\n" +
      "<input type='hidden' name='cmd_do' value='cmd_diff'></form>\n";
    return html;
}

function html_tar(status) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px'  onsubmit='return top.checkCommand(top.checkFMCommand(\"Please enter where you would like to save the tar file.\"))'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td width='9%'><%font%>Status:</font></td><td><%font%>" + status + "</font></td></tr>\n" +
      "<tr><td><%font%>File name:</font></td><td>\n" +
      "<select name='archive_type' class='object'><option value='0'>.tar</option><%if have_gzip%><option value='1'>.tar.gz</option><%endif%><%if have_azip%><option value='2'>.zip</option><%endif%></select>\n" +
      "<input name=txt_input class='object' size=50 value=''> <input type=submit class='submit' name=submit value='Create File'></td></tr></table>\n" +
      "<input type=hidden name=work_path value='<%work_path%>'>\n" +
      "<input type=hidden name=cmd_do value='cmd_tar'></form>";
    return html;
}

function js_cmd_search() {
    if (wasDownload()) return;
    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var work_path = main_form.work_path.value;

    if (work_path == "")
        work_path = "Root";

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");

    if (fm_command) fm_command.innerHTML = html_search(work_path);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_replace () {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var work_path = main_form.work_path.value;
    if (work_path == "")
        work_path = "Root";

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_replace(work_path);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_command (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var work_path;
    if (typeof(main_form.work_path) != "undefined") {
        work_path = main_form.work_path.value
    }
    work_path = (work_path == "") ? ("Root") : (work_path);

    var status = (type) ? "Please enter the command you wish to execute" : main_form.status.value;

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_command(status, work_path);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_upload (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var status, work_path;
    if (typeof(main_form.work_path) != "undefined") {
        work_path = main_form.work_path.value
    }
    if (type) {
        work_path = (work_path == "") ? ("Root") : ("/" + work_path);
        status = "Upload a file into <b><span id='span_path'>" + work_path + "</span></b> directory";
    }
    else {
        status = main_form.status.value
    }

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_upload(status, work_path);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_makedir (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var status;
    if (type) {
        var work_path = main_form.work_path.value;
        work_path = (work_path == "") ? ("Root") : ("/" + work_path);
        status = "Create New directory inside of <b><span id='span_path'>" + work_path + "</span></b> directory";
    }
    else {
        status = main_form.status.value
    }

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_makedir(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_protect (html) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html;
    setFocus(window.top.bottomfrm.document.frm_footer.p_username);

}

function js_cmd_download (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var status = (type) ? "Pick files and directories to download" : status = main_form.status.value;
    if (fm_command) fm_command.innerHTML = html_download(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_copy(type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var status = (type) ? "Please enter where you would like to copy the files" : main_form.status.value;

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_copy(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_move (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(false)) return;

    var status = (type) ? "Please enter where you would like to move the files" : main_form.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_move(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_chmod (type) {
    if (wasDownload()) return;

    var frmMain = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var status = (type) ? "Please select the permissions you would like to set" : frmMain.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_chmod(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_tail (type) {
    if (wasDownload()) return;

    var frmMain = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var status = (type) ? "Please select how many lines you would like to see" : frmMain.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_tail(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_perl (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var work_path = main_form.work_path.value;
    work_path = (work_path == '') ? ('Root') : ('/' + work_path);

    var status = (type) ? "This will syntax check the perl file" : main_form.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");

    if (fm_command) fm_command.innerHTML = html_perl(status, work_path);
}

function js_cmd_edit() {
    var main_form = top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var msg = checkSelected(false)
    if (msg) {
        alert(msg)
        return
    }
    main_form.cmd_do.value = 'cmd_edit';
    main_form.submit();
}

function js_cmd_delete() {
    if (wasDownload()) return;

    var main_form = top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var msg = checkSelected(true);
    if (msg) {
        alert(msg);
        return
    }
    if (confirm('Do you really want to delete the selected files and directories?')) {
        main_form.cmd_do.value = 'cmd_delete';
        main_form.submit();
    }
}

function js_cmd_diff (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var status = (type) ? "Enter path to the file to diff with " : main_form.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");

    if (fm_command) fm_command.innerHTML = html_diff(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_tar (type) {
    if (wasDownload()) return;

    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    var status = (type) ? "Please enter where you would like to save the tar file" : main_form.status.value;
    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html_tar(status);
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_untar(status, work_path) {
    var html = "<form name=frm_footer action='<%http_ref%>' method=post target='mainfrm' style='margin:0px' onsubmit='return top.checkCommand()'>\n" +
      "<table border='0' cellpadding='2' cellspacing='0'>\n" +
      "<tr><td><%font%>Status:</font></td><td><%font%>" + status + "</font></td><td></tr>\n" +
      "<tr><td><%font%>Uncompress:</font></td><td colspan=2>\n" +
      "<select name='uncom_option' class='object'><option value='0'>All</option><option value='1'>Current page</option></select>\n" +
      "<input name=txt_input class='object' size=50 value=''> <input type='submit' class='submit' name=submit value='  Go  '></td></tr></table>\n" +
      "<input type=hidden name=work_path value='" + work_path + "'>\n" +
      "<input type=hidden name=cmd_do value='cmd_uncompress'></form>\n";

    fm_commandbar = top.bottomfrm.document.getElementById("fm_commandbar");
    fm_command    = top.bottomfrm.document.getElementById("fm_command");
    if (fm_command) fm_command.innerHTML = html;
    setFocus(window.top.bottomfrm.document.frm_footer.txt_input);
}

function js_cmd_help() {
    if (wasDownload()) return;
    var frmMain   = window.top.mainfrm.document.frm_main;
    var frmFooter = top.bottomfrm.document.frm_footer;
    var anchor;
    if (typeof(frmFooter) != 'undefined'){
        anchor = frmFooter.cmd_do.value;
    }
    else if (typeof(frmMain.cmd_do) != 'undefined'){
        anchor = frmMain.cmd_do.value;
    }
    var help_url = url + '&fdo=cmd_show&page=help_fileman.html#' + anchor;
    var day = new Date();
    var id = day.getTime();
        rs("Help", help_url, 600, 450, 350, 100,'Yes')
}

function js_cmd_print() {
    var main_form = window.top.mainfrm.document.frm_main;
    if (!isMainForm(true)) return;

    if ( typeof(main_form.view_file) == 'undefined' ) {
        var msg = checkSelected(true)
        if (msg) {
            alert("Please select file(s) to print");
            return
        }
    }
    var count = 0;
    for (var i=0; i< main_form.elements.length; i++) {
        var e = main_form.elements[i];
        if ((e.name != 'allbox') && (e.type=='checkbox')&& (e.checked)) {
            _checked = true;
            count++;
        }
        if ( count>1 ) break;
    }

    if (count > 1) {
        if (confirm("You've selected multiple files. Do you want to print all as one file ? Otherwise, click Cancel to print each file individually")) {
            main_form.print_all.value = 1;
        }
        else {
            main_form.print_all.value = '';
        }
    }
    var url = "<%http_ref%>?fdo=cmd_show&page=blank.html";
    rs("cmd_print", url, 550, 450, 450, 100,'Yes')
    main_form.cmd_do.value = 'cmd_print';
    main_form.target = "cmd_print";
    main_form.submit();
}
</script>
<title>Gossamer Threads - File Manager</title>
</head>
<frameset rows="68,*,85" frameborder="YES" border="<%if is_ie%>0<%else%>1<%endif%>" onload="createFrames()">
  <frame name="topfrm" src="<%http_ref%>?fdo=cmd_show&page=top_frame.html&<%url_opts%>" scrolling="no" noresize frameborder="0" target="mainfrm" marginwidth="5" marginheight="3">
  <frame name="mainfrm" src="<%http_ref%>?fdo=cmd_main_display&def_load=1&<%url_opts%><%if work_path%>&work_path=<%work_path%><%endif%>" frameborder="1" bordercolor='EEEEEE' marginwidth="5" marginheight="3">
  <frame name="bottomfrm" src="<%http_ref%>?fdo=cmd_show&page=bottom_frame.html&<%url_opts%>" frameborder="0" scrolling="no" noresize target="mainfrm" bordercolor="#CCCCCC" marginwidth="5" marginheight="3">
  <noframes>
  <body bgcolor="#FFFFFF">
  <p>Fileman requires you to use a frames enabled browser..</p>
  </body>
  </noframes>
</frameset>
</html>

