



    // load the menu images

var debugWin = null;
var d = null;

function openDebugWin()
{
//  debugWin = window.open("","DebugWindow","width=300,height=500,scrollbars,menubar,resizable");
//  d = debugWin.document;
//  d.open("text/plain");
//  d.writeln("menu debugging\n");
}
    var activePrimaryMenu = null;
    var activeSubMenuId = "";
    var activeSubMenuItem = null;


    function leaveMenu(calledFrom){
      var i;
      var imgIdStr = "";
      var imgId;
      var subMenuId;

if (calledFrom == "leaving outermostEnvelope") return;

      if (activePrimaryMenu == null) return;
      if (activeSubMenuId != ""){
        leaveSubMenu(activePrimaryMenu.subMenu);
        subMenuId = document.getElementById(activeSubMenuId);
        subMenuId.style.visibility = "hidden";
      }
      imgIdStr = "menuImg" + activePrimaryMenu.parent + activePrimaryMenu.i;
      document.getElementById(imgIdStr).src = activePrimaryMenu.mNotOver.src;
      activeSubMenuId = "";
      activePrimaryMenu = null;
      activeSubMenuItem = null;
    }


    function leaveSubMenu(subMenu)
    {
      var i;
      var imgIdStr;
      var imgId;

      for (i=0;i<subMenu.length;i++){
        imgIdStr = "menuImg" + subMenu[i].envelopeId + i;
        imgId = document.getElementById(imgIdStr);
        imgId.src = subMenu[i].mNotOver.src;
      }
    }

    function menuObj(i,w,h,mOverImg,mNotOverImg,parent,link,subMenu,menu,menuName,envelopeId)
    {
      this.i = i;
      this.w = w;
      this.h = h;
      this.mOver = new Image();
      this.mOver.src = mOverImg;
      this.mNotOver = new Image();
      this.mNotOver.src = mNotOverImg;
      this.parent = parent;
      this.link = link;
      this.subMenu = subMenu;
      this.menu = menu;
	  this.menuName = menuName;
      this.envelopeId = envelopeId;
    }




    var mainMenu = new Array();
    var servicesMenu = new Array();


    mainMenu[0] = new menuObj(0,150,10,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/trans_1x1.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/trans_1x1.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[1] = new menuObj(1,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuHomeMouseOver.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuHomeMouseNotOver.gif",
                             "","",null,mainMenu,"mainMenu","");

    mainMenu[2] = new menuObj(2,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[3] = new menuObj(3,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuObituariesMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuObituariesMouseNotOver.gif",
                              "","http://web1.lovinghonors.com/cgi-bin/CompanyInternal?stdout+115+stithfuneralhome.net+102+4+9105:Lcgi_html/",null,mainMenu,"mainMenu","");

    mainMenu[4] = new menuObj(4,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[5] = new menuObj(5,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuFacilitiesMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuFacilitiesMouseNotOver.gif",
                              "","facilities.html",null,mainMenu,"mainMenu","");

    mainMenu[6] = new menuObj(6,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[7] = new menuObj(7,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuHistoryMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuHistoryMouseNotOver.gif",
                              "","history.html", null,mainMenu,"mainMenu","");

    mainMenu[8] = new menuObj(8,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[9] = new menuObj(9,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuServicesMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuServicesMouseNotOver.gif",
                              "","javascript:void(0)",servicesMenu,mainMenu,"mainMenu","");

    mainMenu[10] = new menuObj(10,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[11] = new menuObj(11,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuStaffMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuStaffMouseNotOver.gif",
                              "","staff.html",null,mainMenu,"mainMenu","");

    mainMenu[12] = new menuObj(12,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[13] = new menuObj(13,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuGriefSupportMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuGriefSupportMouseNotOver.gif",
                              "","griefSupport.html",null,mainMenu,"mainMenu","");

    mainMenu[14] = new menuObj(14,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[15] = new menuObj(15,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuCommunityMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuCommunityMouseNotOver.gif",
                              "","community.html",null,mainMenu,"mainMenu","");

    mainMenu[16] = new menuObj(16,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[17] = new menuObj(17,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuPreplanningMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuPreplanningMouseNotOver.gif",
                              "","preplanning.html",null,mainMenu,"mainMenu","");

    mainMenu[18] = new menuObj(18,150,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuSpacer.gif",
                             "",null,null,mainMenu,"mainMenu","");

    mainMenu[19] = new menuObj(19,150,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuContactUsMouseOver.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/menuContactUsMouseNotOver.gif",
                              "","contactus.html",null,mainMenu,"mainMenu","");

    mainMenu[20] = new menuObj(20,150,152,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/contactInfo.gif",
                              "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/contactInfo.gif",
                              "",null,null,mainMenu,"mainMenu","");

    servicesMenu[0] = new menuObj(0,151,1,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/trans_1x1.gif",
                                 "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/trans_1x1.gif",
                                 "mainMenu",null,null,servicesMenu,"servicesMenu","subServicesMenu");

    servicesMenu[1] = new menuObj(1,151,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/burialMouseOver.gif",
                                 "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/burialMouseNotOver.gif",
                                 "mainMenu","burial.html",null,servicesMenu,"servicesMenu","subServicesMenu");

    servicesMenu[2] = new menuObj(2,151,16,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/subMenuSpacer.gif",
                             "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/subMenuSpacer.gif",
                             "mainMenu",null,null,servicesMenu,"servicesMenu","subServicesMenu");

    servicesMenu[3] = new menuObj(3,151,26,"http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/cremationMouseOver.gif",
                                 "http://web1.lovinghonors.com/p-t/stithfuneralhome.net/art/menu/cremationMouseNotOver.gif",
                                 "mainMenu","cremation.html",null,servicesMenu,"servicesMenu","subServicesMenu");



    function hideSubMenu(idName)
    {
      var subMenuId;

if (d != null) d.writeln("hideSubMenu");
      
	  if(idName == "") return;
	  if (idName != inSubMenuId) return;
      if (inSubMenuId == "") return;
      subMenuId = document.getElementById(idName);
	  subMenuId.style.visibility = "hidden";
    }
      

    function amplifyMenuOver(menu,i)
    {
      var imgIdStr;
      var imgId;
      var cellIdStr;
      var cellId;
      var envId;
      var outermostEnvelopeId = document.getElementById("outermostEnvelope");
      var mainMenuWidth = 153;
      var topBarHeight = 149;
      var newActivePrimaryMenu;

if (d!= null) d.writeln("amplifyMenuOver(" + menu[i].parent + "," + menu[i].envelopeId + ")");

      if (menu[i].parent == ""){
        // three possibility here:
        //   (1) We are leaving one cell of the primary menu and entering another
        //   (2) We are leaving a sub-menu and re-entering the cell that displayed the sub-menu.
        //   (3) We are entering a menu item when no menu item is active
        //
        // if the first hide any sub-menu, remove the mouse over image from the old primary menu
        // if the second change all images to the mouse not over state and return
        if (activePrimaryMenu != null){
          if (i == activePrimaryMenu.i){
            // case 2
            leaveSubMenu(activePrimaryMenu.subMenu);
            return;
          }
          // case 1
          leaveMenu("amplifyMenu: case 1");
          renderInOutMenuImage(menu[i],null);
          activePrimaryMenu = menu[i];
          if (menu[i].subMenu != null){
            cellIdStr = "menuCell" + menu[i].envelopeId + i;
            cellId = document.getElementById(cellIdStr);
            envId = document.getElementById(menu[i].subMenu[0].envelopeId);
            envId.style.top = (cellId.offsetTop + topBarHeight) + "px";
            envId.style.left = (outermostEnvelopeId.offsetLeft + mainMenuWidth - 1) + "px";
            envId.style.visibility = "visible";
            activeSubMenuId = menu[i].subMenu[0].envelopeId;
          }
          return;
        }
        // case 3
        imgIdStr = "menuImg" + menu[i].envelopeId + i;
        imgId = document.getElementById(imgIdStr);
        imgId.src = menu[i].mOver.src;
        activePrimaryMenu = menu[i];
        if (menu[i].subMenu != null){
          cellIdStr = "menuCell" + menu[i].envelopeId + i;
          cellId = document.getElementById(cellIdStr);
          envId = document.getElementById(menu[i].subMenu[0].envelopeId);
          envId.style.top = (cellId.offsetTop + topBarHeight) + "px";
          envId.style.left = (outermostEnvelopeId.offsetLeft + mainMenuWidth - 1) + "px";
          envId.style.visibility = "visible";
          activeSubMenuId = menu[i].subMenu[0].envelopeId;
        }
        return;      
      }
      // We are moving within a sub-menu
      if (activeSubMenuItem == null){
        // first entry into the sub-menu
        activeSubMenuItem = menu[i];
        renderInOutMenuImage(menu[i],null);
        return;
      }
      // first disable the currently active menu item then activate the new one
      renderInOutMenuImage(menu[i],activeSubMenuItem);
      activeSubMenuItem = menu[i];
      return;
    }



    function renderInOutMenuImage(inMenuItem,outMenuItem)
    {
      var imgStr;
      var imgId;

      if (outMenuItem != null){
        imgStr = "menuImg" + outMenuItem.envelopeId + outMenuItem.i;
        imgId = document.getElementById(imgStr);
        imgId.src = outMenuItem.mNotOver.src;
      }
      if (inMenuItem != null){
        imgStr = "menuImg" + inMenuItem.envelopeId + inMenuItem.i;
        imgId = document.getElementById(imgStr);
        imgId.src = inMenuItem.mOver.src;
      }
    }


    function renderMenu(menu){
      var i;
      var t;
      var linkHead = "";
      var linkTail = "";
      var imgId = "";
      var envelopeId = "";
      var cellId = "";
	  var mouseInRegionStr = "";
      var mouseOutRegionStr = "";



      if (menu[0].envelopeId != "") envelopeId = "id='" + menu[0].envelopeId + "'";
      mouseInRegionStr = " onMouseOver='setInSubMenu(\"" + menu[0].envelopeId + "\")'";
      mouseOutRegionStr = " onMouseOut='hideSubMenu(\"" + menu[0].envelopeId + "\")'";
      
      t = "<div " + envelopeId + " style='z-index: 5;'><table cellpadding='0' cellspacing='0'>";
      document.writeln(t);
      for (i=0;i<menu.length;i++){
        if (menu[i].envelopeId != null){
          imgId = "menuImg" + menu[i].envelopeId + i;
          cellId = "menuCell" + menu[i].envelopeId + i;
        }
        else{
          imgId = "menuImg" + i;
          cellId = "menuCell" + i;
        }
        linkHead = "";
        linkTail = "";
        if (menu[i].link != null) {
          linkHead = "<a href='" + menu[i].link + "'>";
          linkTail = "</a>";
        }
        t = "<img src='" + menu[i].mNotOver.src + "' width='" + menu[i].w + "' height='" + menu[i].h + "' border='0' id='" + imgId + "'>";
        t = "<tr><td id='" + cellId + "' onmouseover='amplifyMenuOver(" + menu[i].menuName + "," + i + ")'>" + linkHead + t + linkTail + "</td></tr>";
        document.writeln(t);
      }
/*
        if (envelopeId == ""){//main menu
        t = '<tr><td><iframe src="http://web1.lovinghonors.com/cgi-bin/CompanyInternal?stdout+115+hagerandcundifffunerals.com+SHIPPING+0+6001:Lcgi_html/inLovingMemory/+LovingMemory++" width="100%" frameborder="0" height="100%"></iframe></td></tr>';
        document.writeln(t);
      }
*/
      document.writeln("</table></div>");
    }
