var Menu = {};

Menu.JSON = {
  settings: {
    general: {
      activatemenu: "mouseover",
      spacedepth: 8,
      borderStyle: "solid 1px gold"
    },
    mainmenu: {
      "style": {
        "font": "bold 10pt verdana",
        "height": "18px",
        "background-color": "white",
        "color": "#0f3e5b"
      },
      "event": {
        "color_mouseover": "#ffc82e",
        "color_mouseout": "#0f3e5b",
        "background_mouseover": "white",
        "background_mouseout": "white"
      }
    },
    submenu: {
      "style": {
        "font": "bold 8pt tahoma",
        "height": "20px",
        "padding-top": "1px",
        "padding-right": "5px",
        "padding-bottom": "2px",
        "padding-left": "5px",
        "background-color": "#396e8e",
        "color": "white"
      },
      "event": {
        "color_mouseover": "#ffc82e",
        "color_mouseout": "white",
        "background_mouseover": "#517b97",
        "background_mouseout": "#396e8e"
      }
    }
  },
  menus: {
    "Customer Service": {
      "Customer Service": "location='[docroot]bin-htm/custServ.html?intro'",
      "On-line Registration": "location='[docroot]ordering/bin-php/application.php'",
      "Service Request Form": "location='[docroot]bin-php/cust_serv_form.php'",
      "Your Account": "location='[docroot]administrator/programs/customer/login_customer.html'",
      "Service Terms": "location='[docroot]bin-htm/custServ.html?service'",
      "<hr>": "",
      "Our Surveys": {
        js: "location='[docroot]bin-htm/fullsurvey.html?fullSurveyForm'",
        "Full Survey": "location='[docroot]bin-htm/fullsurvey.html?fullSurveyForm'",
        "Shopping Survey": "location='[docroot]ordering/bin-php/survey.php'",
        "<space>": ""
      },
      "<space>": ""
    },
    "On-Line Products": {
      "Desking": {
        js: "location='[docroot]catalogs/bin-html/onlineProds.html?desks;all'",
        "Double Pedestal": "location='[docroot]catalogs/bin-html/onlineProds.html?desks;double Pedestal Desks'",
        "Single Pedestal": "location='[docroot]catalogs/bin-html/onlineProds.html?desks;single Pedestal Desks'",
        "Credenzas": "location='[docroot]catalogs/bin-html/onlineProds.html?desks;credenzas'",
        "Workstations": "location='[docroot]catalogs/bin-html/onlineProds.html?desks;workstations'",
        "Dormitory Desks": "location='[docroot]catalogs/bin-html/onlineProds.html?desks;dormitory Desks'",
        "<space>": ""
      },
      "Dormitory Items": {
        js: "location='[docroot]manufacturers/furniture/dormitory.html?dormitory;all'",
        "Dormitory Desks": "location='[docroot]manufacturers/furniture/dormitory.html?dormitory;dormitory Desks'",
        "Dormitory Wardrobes": "location='[docroot]manufacturers/furniture/dormitory.html?dormitory;wardrobes'"
      },
      "Files &amp; Storage": {
        js: "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;all'",
        "Bookcases": "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;bookcases'",
        "Cabinets": "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;cabinets'",
        "Lateral Files": "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;lateral'",
        "Pedestal Files": "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;pedestal'",
        "Vertical Files": "location='[docroot]catalogs/bin-html/onlineProds.html?filing/Storage;vertical'",
        "<space>": ""
      },

      "Seating / Chairs": {
        js: "location='[docroot]catalogs/bin-html/onlineProds.html?seating;office'",
        "Office": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;office'",
        "Side &amp; Visitor": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;side/Visitor'",
        "Stacking": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;stacking Chairs'",
        "Stool": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;stools'",
        "Classroom": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;classroom Chairs'",
        "Lounge Seating": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;lounge Seating'",
        "Discontinued": "location='[docroot]catalogs/bin-html/onlineProds.html?seating;dis'",

        "<space>": ""
      },
      "Tables ": {
        js: "location='[docroot]catalogs/bin-html/onlineProds.html?tables;all'",
        "Adjustable Tables": "location='[docroot]catalogs/bin-html/onlineProds.html?tables;adjustable'",
        "Computer Tables": "location='[docroot]catalogs/bin-html/onlineProds.html?tables;computer Tables'",
        "Conference Tables": "location='[docroot]catalogs/bin-html/onlineProds.html?tables;conference Tables'",
        "Corner Tables": "location='[docroot]catalogs/bin-html/onlineProds.html?tables;corner'",
        "Reception Tables": "location='[docroot]catalogs/bin-html/onlineProds.html?tables;reception/Occasional'",
        "<space>": ""
      },
      "Product Accessories": "location='[docroot]catalogs/bin-html/accessories.html?5259;Single Pedestal Desks'",
      "Apparel & Textile": {
        js: "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;all'",
        "Mattresses & Pillows": "location='[docroot]catalogs/bin-html/onlineProds.html?bedding;bedding'",
        "Linens": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;linen'",
        "DOC BDUs": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;DOC BDUs'",
        "Flags": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;flags'",
        "Tote Bags": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;Tote bags'",
        "Inmate Clothing": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;inmate clothing'",
        "Work Clothes": "location='[docroot]catalogs/bin-html/onlineProds.html?apparel;work clothing'",
        "<space>": ""
      },
      "Air Filtration": {
        js: "location='[docroot]manufacturers/filters/index.html?all'",
        "Air &amp; Grease": "location='[docroot]manufacturers/filters/index.html?grease'",
        "Disposable": "location='[docroot]manufacturers/filters/index.html?disposable'",
        "High Efficiency": "location='[docroot]manufacturers/filters/index.html?extended'",
        "Media Rolls": "location='[docroot]manufacturers/filters/index.html?rolls'",
        "Media Pads": "location='[docroot]manufacturers/filters/index.html?pads'",
        "Mini Pleat": "location='[docroot]manufacturers/filters/index.html?mini'",
        "M3 Panel": "location='[docroot]manufacturers/filters/index.html?m3'",
        "Pleated": "location='[docroot]manufacturers/filters/index.html?pleated'",
        "Pocket": "location='[docroot]manufacturers/filters/index.html?pocket'",
        "3-Ply Panel": "location='[docroot]manufacturers/filters/index.html?ply3'",
        "<space>": ""
      },
      "Plastic Bags": "location='[docroot]manufacturers/bags/index.html?all'",
      "Computer Accessories": "location='[docroot]catalogs/bin-html/onlineProds.html?computer accessories;keyboards'",

      "Rod Shop": {
        js: "location='[docroot]manufacturers/rodshop/index.html?all'",
        "Bass": "location='[docroot]manufacturers/rodshop/index.html?bass'",
        "Crank": "location='[docroot]manufacturers/rodshop/index.html?crank'",
        "Fly": "location='[docroot]manufacturers/rodshop/index.html?flyrods'",
        "Salmon": "location='[docroot]manufacturers/rodshop/index.html?salmon'",
        "Spin": "location='[docroot]manufacturers/rodshop/index.html?spin'",
        "<space>": ""
      },

      "<space>": ""
    },
    "Manufacturers": {
      "Apparel": {
        js: "location='[docroot]manufacturers/apparel/index.html?apparel;all'",
        "Flag Care": "location='[docroot]manufacturers/apparel/index.html?careandwarranty'",
        "<space>": ""
      },
      "Air Filtration": "location='[docroot]manufacturers/filters/index.html?all'",
      "Denver Showroom": "location='[docroot]/bin-cgi/inventorySales.cgi?special'",
      "Furniture": {
        js: "location='[docroot]manufacturers/furniture/office.html?office;all'",
        "Dormitory Furniture": "location='[docroot]manufacturers/furniture/dormitory.html?dormitory;all'",
        "Lounge  Furniture": "location='[docroot]manufacturers/furniture/lounge.html?lounge;all'",
        "Office  Furniture": "location='[docroot]manufacturers/furniture/office.html?office;all'",
        //"Bid Request Form": "location='[docroot]manufacturers/furniture/bin-cgi/bidrequestinfoform.cgi'",
        "<space>": ""
      },

      "Ink/Toner Cartridges": "location='[docroot]bin-htm/greenInk.html?intro'",
      "Leather": "location='[docroot]manufacturers/leather/index.html?intro'",
      "Metal": "location='[docroot]manufacturers/metal/index.html?intro'",
      "Files &amp; Storage": "location='[docroot]manufacturers/files/index.html?filing/storage;all'",
      "Modular Office Systems": {
        js: "location='[docroot]manufacturers/mos/index.html?mos;all'",
        "Completed Projects": "location='[docroot]bin-htm/comProjects.html?intro_album'",
        "C.A.D. Drawing fees": "location='[docroot]serviceproviders/cad/index.html?additionalFees'",
        "<space>": ""
      },
      "Plastic Bag Plant": "location='[docroot]manufacturers/bags/index.html?all'",
      "Rod Shop": "location='[docroot]manufacturers/rodshop/index.html?all'",
      "Seating": "location='[docroot]manufacturers/seating/index.html?seating;all'",
      "Specialty Items": "location='[docroot]manufacturers/show/index.html?intro'",
      "Project Products": "location='[docroot]manufacturers/amc/index.html?intro'",

      "<space>": ""
    },
    "Services": {
      "CAD Designs": {
        js: "location='[docroot]serviceproviders/cad/index.html?intro'",
        "Pricing": "location='[docroot]serviceproviders/cad/index.html?additionalFees'",
        "MOS Drawings": "location='[docroot]serviceproviders/mosprojects/index.html'",
        "Special Projects": "location='[docroot]serviceproviders/mosprojects/specialProjects/bin-cgi/login.cgi'",
        "<space>": ""
      },
      "Canteen Services": "location='http://www.doccanteen.com'",
      "Finger Printing": "location='[docroot]manufacturers/stateForms/index.html?finger'",
      "General Services": "location='[docroot]serviceproviders/genser/index.html?intro'",
      "Heavy Equipment": "location='[docroot]serviceproviders/construction/index.html?intro'",
      "Dog Program": {
        js: "location='[docroot]serviceproviders/puppy/index.html?intro'",
        "Available Pets": "location='[docroot]serviceproviders/puppy/index.html?companion'",
        "Assistance Dogs": "location='[docroot]serviceproviders/puppy/index.html?working'",
        "Pet Doors": "location='[docroot]serviceproviders/puppy/index.html?petdoor'",
        "<space>": ""
      },
      "Print Services": "location='[docroot]serviceproviders/print/index.html?intro'",
      "Sign Shop": "location='[docroot]manufacturers/sign/index.html?intro'",
      "State Forms": {
        js: "location='[docroot]manufacturers/stateForms/index.html?intro'",
        "Finger Printing": "location='[docroot]manufacturers/stateForms/index.html?finger'",
        "<space>": ""
      },
      "SWIFT": {
        js: "location='[docroot]serviceproviders/swift/index.html?intro'",
        "Fire Info": "location='[docroot]serviceproviders/swift/index.html?fires'",
        "<space>": ""
      },
      "State Surplus Property": "location='[docroot]serviceproviders/surplus/stateSurp.html?intro'",
      "Federal Surplus Property": "location='[docroot]serviceproviders/surplus/federalSurp.html?intro'",
      "Transportation": "location='[docroot]serviceproviders/transport/index.html?intro'",
      "Web Department": {
        js: "location='[docroot]serviceproviders/web/index.html?intro'",
        "Pricing": "location='[docroot]serviceproviders/web/index.html?pricing'",
        "<space>": ""
      },
      "WHIP": {
        js: "location='[docroot]serviceproviders/whip/index.html?intro'",
        "Adoption Schedule": "location='[docroot]serviceproviders/whip/index.html?schedule'",
        "Saddle Trained": "location='[docroot]serviceproviders/whip/index.html?saddle'",
        "Halter Trained": "location='[docroot]serviceproviders/whip/index.html?halter'",
        "<space>": ""
      },
      "<space>": ""
    },
    "Help &amp; Info": {
      "General Info": {
        js: "location='[docroot]bin-htm/generalinfo.html?intro'",
        "Ordering": "location='[docroot]bin-htm/generalinfo.html?ordering'",
        "DOC Orders": "location='[docroot]bin-htm/generalinfo.html?docOrders'",
        "Return Policy": "location='[docroot]bin-htm/generalinfo.html?returns'",
        "<space>": ""
      },
      "Help": "location='[docroot]bin-htm/help.html?intro'",
      "Plug-ins": "location='[docroot]bin-htm/plugupgrade.htm?intro'",
      "State Awards": "location='[docroot]bin-htm/stateAgreement.html?mos'",
      "Mailing List": "location='[docroot]bin-php/mailinglist.php'",
      "Fabrics/Finishes": {
        js: "location='[docroot]catalogs/bin-html/fabricFinish.html?intro'",
        "Apparel": "location='[docroot]catalogs/bin-html/fabricFinish.html?5459|apparel'",
        "Furniture": "location='[docroot]catalogs/bin-html/fabricFinish.html?5259|furniture'",
        "Metal": "location='[docroot]catalogs/bin-html/fabricFinish.html?5559|metal'",
        "MOS": "location='[docroot]catalogs/bin-html/fabricFinish.html?5255|mos'",
        "Seating": "location='[docroot]catalogs/bin-html/fabricFinish.html?5955|seating'",
        "<space>": ""
      },
      "Green Policies": {
        js: "location='[docroot]manufacturers/greenpolicies/index.html?intro'",
        "Green Mission": "location='[docroot]manufacturers/greenpolicies/index.html?ccimission'",
        "<space>": ""
      },
      "Ergonomic Rating": {
        js: "location='[docroot]bin-htm/ergo.html?intro'",
        "Star Rating": "location='[docroot]bin-htm/ergo.html?star'",
        "Product Ratings": "location='[docroot]bin-htm/ergo.html?model'",
        "<space>": ""
      },
      "Personnel": "location='[docroot]bin-htm/personnel.html?intro'",
      "FAQ": "location='[docroot]bin-php/faq.php'",
      "<space>": ""
    },
    "Agriculture": {
      "Agriculture": "location='[docroot]manufacturers/agriculture/index.html?intro'",
      "Dairy": "location='[docroot]manufacturers/agriculture/dairy.html?intro'",
      "Farming": "location='[docroot]manufacturers/agriculture/farming.html?intro'",
      "Fishery": "location='[docroot]manufacturers/agriculture/fishery.html?intro'",
      "Goat Dairy": "location='[docroot]manufacturers/agriculture/goats.html?intro'",
      "Greenhouse": "location='[docroot]manufacturers/agriculture/greenhouse.html?intro'",
      "Honey": "location='[docroot]manufacturers/agriculture/honey.html?intro'",
      "Recycling": "location='[docroot]manufacturers/agriculture/recycling.html?intro'",
      "Vineyard": "location='[docroot]manufacturers/agriculture/vineyard.html?intro'",
      "<space>": ""
    },
    "Contact Us": "location='[docroot]bin-php/directory.php'"
  }
};

Menu.event = {};
Menu.docroot = location.protocol+"//"+location.host+"/";
Menu.obj = function(id) {return document.getElementById(id);};
Menu.A_options = {};
Menu.tables = {};
Menu.A_click = {};
Menu.active = "";
Menu.activeLast = "";
Menu.activeNow = "";

if (location.toString().match(/intranet/i)) Menu.docroot +=""+location.pathname.split(/\//)[0]+"/";
if (location.toString().match(/92\.40\.66\.30/i)) Menu.docroot +=""+location.pathname.split(/\//)[0]+"/";
Menu.docroot = docRoot;

Menu.load = function(id) {
  Menu.id = id;
  var N_ = [];
  var N_eventsMain = [];
  var N_eventsSub = [];

  var N_mainStyle = ["cursor:pointer; width: 100%; border: none"];
  for (var STYLE in Menu.JSON.settings.mainmenu.style) {
    N_mainStyle.push(STYLE+":"+Menu.JSON.settings.mainmenu.style[STYLE]);
  }
  var mainStyle = N_mainStyle.join(";");
  var N_subStyle = ["cursor:pointer; width: 100%; border: none; text-align: left; padding: 0px"];
  for (var STYLE in Menu.JSON.settings.submenu.style) {
    N_subStyle.push(STYLE+":"+Menu.JSON.settings.submenu.style[STYLE]);
  }
  var subStyle = N_subStyle.join(";");
  var subHeight = parseInt(Menu.JSON.settings.submenu.style.height)/2;
  var childStyle = "display: none; order-collapse: collapse; position: absolute; order: solid 1px white;";
  var backColor = Menu.JSON.settings.submenu.style["background-color"];
  var spacedepth = Menu.JSON.settings.general.spacedepth;
  var mainmenuHeight = Menu.JSON.settings.mainmenu.style.height;
  var borderStyle = Menu.JSON.settings.general.borderStyle;

  N_.push("<table id='Menu_maintable' cellpadding='0' cellspacing='0' style='z-index:1000;order-collapse: collapse; width: 100%;'>");
  N_.push("  <tr>");

  var idCnt = 0;
  for (var KEY in Menu.JSON.menus) {
    var id_sub = "Menu_id_main_"+idCnt+(KEY).replace(/\W/g, '');
    idCnt++;
    var N_2 = [];
    if (typeof Menu.JSON.menus[KEY] == 'object') {
      for (var KEY2 in Menu.JSON.menus[KEY]) {
        if (KEY2 == "js") continue;
        idCnt++;
        var N_2_5 = [];
        var id_sub2 = "Menu_id_sub_"+idCnt+(KEY2).replace(/\W/g, '');
        if (typeof Menu.JSON.menus[KEY][KEY2] == 'object') {
          var N_3 = [];
          for (var KEY3 in Menu.JSON.menus[KEY][KEY2]) {
            if (KEY3 == "js") continue;
            idCnt++;
            var id_sub3 = "Menu_id_sub_"+idCnt+(KEY3).replace(/\W/g, '');
            var space = KEY3.match(/\<space/i)?"font-size:0pt;height:"+spacedepth+";":"";
            KEY3 = KEY3.replace(/\<space>/, '&nbsp;');
            N_3.push("                  <tr>");
            N_3.push("                    <td nowrap='nowrap' id='"+id_sub3+"' tabindex='1' style='"+subStyle+";"+space+";border-left:"+borderStyle+"; border-right:"+borderStyle+";'>");
            N_3.push("                      "+KEY3);
            N_3.push("                    </td>");
            N_3.push("                  </tr>");
            Menu.A_options[id_sub3] = [id_sub+"_child",id_sub2+"_child"];
            Menu.A_click[id_sub3] = Menu.JSON.menus[KEY][KEY2][KEY3];
          }
          N_2_5.push("            <td style='width: 0px'>");
          N_2_5.push("              <div style='position: relative; left: 0px; top: 0px;'>");
          if (N_3.length) {
            //N_2_5.push("                <iframe id='"+id_sub2+"_child_iframe' frameBorder='no' style='"+childStyle+"; top: -9px; left: -6px;'></iframe>");
            N_2_5.push("                <table id='"+id_sub2+"_child' cellpadding='0' cellspacing='0' style='"+childStyle+"; top: -10px; left: -6px;'>");
            N_2_5 = N_2_5.concat(N_3);
            N_2_5.push("                </table>");
          }
          N_2_5.push("              </div>");
          N_2_5.push("            </td>");
        }
        var space = KEY2.match(/\<space/i)?"font-size:0pt;height:"+spacedepth+";":"";
        KEY2 = KEY2.replace(/\<space>/, '&nbsp;');
        N_2.push("          <tr style='background-color: "+backColor+";'>");
        N_2.push("            <td nowrap='nowrap' id='"+id_sub2+"' tabindex='1' style='"+subStyle+";"+space+";border-left:"+borderStyle+";'>");
        N_2.push("              "+KEY2);
        N_2.push("            </td>");
        N_2.push("            <td id='"+id_sub2+"_td' style='"+subStyle+";"+space+";width: 20px;border-right:"+borderStyle+";'>");
        //N_2.push("            <div id='"+id_sub2+"_td' style='"+subStyle+";"+space+";width: 0px;border-right:"+borderStyle+";'>");
        if (N_2_5.length) {
          N_2.push("              &nbsp;&nbsp;>&nbsp;&nbsp;");
          N_2 = N_2.concat(N_2_5);
        }
        else {
          N_2.push("              &nbsp;");
        }
        //N_2.push("            </div>");
        N_2.push("            </td>");
        N_2.push("          </tr>");
        Menu.A_options[id_sub2] = [id_sub+"_child",id_sub2+"_child"];
        Menu.A_click[id_sub2] = Menu.JSON.menus[KEY][KEY2];
      }
    }
    N_.push("    <td valign='top' nowrap='nowrap' align='center'>");
    N_.push("      <div style='position: relative; left: 0px; top: 0px;'>");
    N_.push("        <div id='"+id_sub+"' tabindex='1' style='"+mainStyle+";'>"+KEY+"</div>");
    if (N_2.length) {
      //N_.push("        <iframe id='"+id_sub+"_child_iframe' frameBorder='no' style='"+childStyle+"; top: -9px; left: -6px;'></iframe>");
      N_.push("        <table id=\""+id_sub+"_child\" cellpadding='0' cellspacing='0' style='"+childStyle+"; top: "+mainmenuHeight+"; left: 0px; z-index: 5000 !important;'>");
      N_ = N_.concat(N_2);
      N_.push("        </table>");
    }
    N_.push("      </div>");
    N_.push("    </td>");
    Menu.A_options[id_sub] = [id_sub+"_child"];
    Menu.A_click[id_sub] = Menu.JSON.menus[KEY];
  }
  N_.push("  </tr>");
  N_.push("</table>");

  Menu.obj(Menu.id).style.position = "relative";
  Menu.obj(Menu.id).style.height = "20px";
  Menu.obj(Menu.id).innerHTML = N_.join("\r\n");

  //Menu.event.events(Menu.id, "onclick", Menu.event.showTable);
  Menu.event.events(Menu.id, "onmouseover", Menu.event.showTable);
  Menu.event.events(Menu.id, "onmouseout", Menu.event.hideTable);
  Menu.event.events(Menu.id, "onclick", Menu.event.eval);

/*
  if (specialURL == "bearVideo"){
    var O_f = document.createElement("iframe");
    O_f.setAttribute("id", "aaaaaaaaa");
    O_f.name = "aaaaaaaaa";
    //O_f.frameBorder = "no";
    //O_f.allowTransparency = true;
    with(O_f.style) {
      position = "absolute";
      top = 300;
      left = 400;
      width = 300;
      height = 300;
      zIndex = 1000;
    }
    Menu.obj('bearVideo').appendChild(O_f);
  }
  // Create and run the Flash in the <iframe>.
  var backColor = document.getElementById(id).style.backgroundColor || "white";
  var N_html = [];
  N_html.push("<html>");
  N_html.push("  <head>");
  N_html.push("    <style type='text/css'>");
  N_html.push("      body { background-color: green; margin: 0px; overflow: hidden; }");
  N_html.push("    </style>");
  N_html.push("  </head>");
  N_html.push("  <body></body>");
  N_html.push("</html>");
  frames['aaaaaaaaa'].document.write(N_html.join(""));
  */
};

Menu.event.events = function(obj, event_, callback) {
  if (!Menu.obj(obj)) return false;
  event_ = event_.replace(/^on/i, '');
  if (document.addEventListener) {
    Menu.obj(obj).addEventListener(event_, callback, false);
  }
  else {
    Menu.obj(obj).attachEvent('on'+event_, callback);
  }
};

Menu.event.eval = function(e) {
  e = e || event;
  var srcElement = e.srcElement || e.target;
  var id = srcElement.id;
  id = id.replace(/_td$/, '');
  if (!id) return;
  var str = Menu.A_click[id];
  if (!str) return false;

  if (typeof str != "string") str = str.js;
  if (str !== undefined) {
    str = str.replace(/\[docroot]/g, Menu.docroot);
    eval(str);
  }
};

Menu.event.hideTable = function(e, altID) {
  Menu.active = false;
  e = e || event;
  var srcElement = e.srcElement || e.target;
  var id = srcElement.id;
  id = id.replace(/_(td|child)$/, '');
  id = altID || id;
  if (!id || !id.match(/id_(main|sub)/)) return;

  Menu.event.highlight(id, 'off');

  var childID = id+"_child";
  if (!Menu.tables[childID]) {
    //return;
  }

  window.clearTimeout(Menu.activeSettimeout);
  Menu.activeSettimeout = window.setTimeout(
    function() {
      if (!Menu.active && Menu.activeLast) {
        var activeLast = Menu.A_options[Menu.activeLast];
        for (var i = 0; i < activeLast.length; i++) {
          Menu.event.highlight(activeLast[i].split(/_child/)[0], 'off');
          if (Menu.obj(activeLast[i])) Menu.obj(activeLast[i]).style.display = "none";
        }
      }
    }, 1000
  );
};

Menu.event.showTable = function(e) {
  Menu.active = true;
  e = e || event;
  var srcElement = e.srcElement || e.target;
  var id = srcElement.id.replace(/_(td|child)$/, '');
  if (!id || !id.match(/id_(main|sub)/)) return;
  //if (Menu.activeNow == id) return;
  //if (Menu.activeLast == id) return;

  //if (e.type.match(/mouseover/) && id.match(/_main_/)) {
  //  Menu.event.highlight(id, 'on');
  //  return false;
  //}

  Menu.activeNow = id;

  var activeLast = Menu.A_options[Menu.activeLast];
  if (activeLast) {
    for (var i = 0; i < activeLast.length; i++) {
      Menu.event.highlight(activeLast[i].split(/_child/)[0], 'off');
      if (Menu.obj(activeLast[i])) Menu.obj(activeLast[i]).style.display = "none";
    }
  }

  var activeNow = Menu.A_options[Menu.activeNow];
  for (var i = 0; i < activeNow.length; i++) {
    Menu.event.highlight(activeNow[i].split(/_child/)[0], 'on');
    if (Menu.obj(activeNow[i])) {
      Menu.obj(activeNow[i]).style.display = "";
    }
  }

  Menu.event.highlight(id, 'on');
  var childID = id+"_child";
  if (Menu.obj(childID)) {
    Menu.tables[childID] = 1;
  }
  Menu.activeLast = Menu.activeNow;
};

Menu.event.highlight = function(id, type) {
  var mainmenu = Menu.JSON.settings.mainmenu.event;
  var submenu = Menu.JSON.settings.submenu.event;
  var where = id.match(/id_main_/)?mainmenu:submenu;

  if (type == 'on') {
    Menu.obj(id).style.color = where.color_mouseover;
    Menu.obj(id).style.backgroundColor = where.background_mouseover;
    if (Menu.obj(id+'_td')) {
      Menu.obj(id+'_td').style.color = where.color_mouseover;
      Menu.obj(id+'_td').style.backgroundColor = where.background_mouseover;
    }
  }
  else {
    Menu.obj(id).style.color = where.color_mouseout;
    Menu.obj(id).style.backgroundColor = where.background_mouseout;
    if (Menu.obj(id+'_td')) {
      Menu.obj(id+'_td').style.color = where.color_mouseout;
      Menu.obj(id+'_td').style.backgroundColor = where.background_mouseout;
    }
  }
};
