//
// Copyright 2004 Larry Ullom
//
// This file is part of the SIMPLE MENU package.  The javascript below
// is the SIMPLE MENU core.
//
// The following parts of SIMPLE MENU are free software; you can redistribute them
// and/or modify them under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the License,
// or (at your option) any later version.
//
// The SIMPLE MENU is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SIMPLE MENU; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//

// There are a lot of navigation menu packages out there for free use.  Most are
// more robust and user friendly than this one.  This is a simple QUICK implementation
// that was designed to be a drop in replacement for a hard coded HTML nav bar.
// It has one format, and the only real configuration that is needed is the list of
// links and the optional style tags to apply to the menu.  The entire menu is writen
// to the document, at the location of the function call, as a self contained table.
// The table uses a rollover highlight w/ a selection bullet next to the link if the
// mouse in hovering.  While hovering the status bar shows a description of the link.

// The menu is loaded with the locations in this array.  The array fomat is:
// MenuSelections[selectionNumber] = [MenuItemName, MenuItemDescription, MenuItemLink]
// MenuItemName = Text that will be displayed in the nav menu cell for this link
// MenuItemDescription = Text that will be displayed in the Status bar when the link is hovered
// MenuItemLink = URL of the page to open when the link is clicked
var MenuSelections = new Array();
MenuSelections[MenuSelections.length] = new Array('Home','Site Entry Page','index.html');
MenuSelections[MenuSelections.length] = new Array("Location","How To Find Us","location.html");
MenuSelections[MenuSelections.length] = new Array("History","A Brief History of Our Church","history.html");
//MenuSelections[MenuSelections.length] = new Array("Programs","Our Ministry Oportunities","ministries.html");
MenuSelections[MenuSelections.length] = new Array("Calendar","Calendar of events for this month","calendar.html");
MenuSelections[MenuSelections.length] = new Array("Facilities","Tour The Facilities","facilities.html");
//MenuSelections[MenuSelections.length] = new Array("Officers","Meet our Officers","officers.html");
MenuSelections[MenuSelections.length] = new Array("Beliefs","What We Believe","belief.html");
MenuSelections[MenuSelections.length] = new Array("Other Sites","External Links & Misc Information","favorites.html");
//MenuSelections[MenuSelections.length] = new Array("Gallery","Photos of past events","gallery.html");
/*
 *  This script highlights an element by changing the background
 *  color of the element.  The 'div' variable is the ID of the elelment.
 *  The 'color' is the name or numeric representation of the new
 *  background color.  This script can be called from the onmouseover
 *  event handler and the onmouseout handler to highlight then unhighlight
 *  text in a rollover type menu, without the image download overhead.
 */

// The document from which this is called must include set the is_nav, is_ie,
// and is_gecko variables based on the browser in which it's being rendered.

function ChangeBckGrnd(div,color){
    if (is_nav && !is_gecko) {
        layerRef="document.layers.";
        styleRef="";
        bgRef=".bgColor"
    } else {
        if (is_ie || is_other) {
            layerRef="document.all.";
            styleRef=".style";
            bgRef=".backgroundColor"
        } else {
            if (is_gecko) {
                layerRef=document.getElementById(div);
                layerRef.style.backgroundColor=color;
                return;
            } else {
                return;
            }
        }
    }
    eval(layerRef+div+styleRef+bgRef+'="'+color+'"');
}

function HighLight(elid,forColor,backColor){
    element=elid;
    if (is_nav) {
        element.bgColor=backColor;
        element.color=forColor;
    } else {
        element.backgroundColor=backColor;
        element.color=forColor;
    }
}

function navMenuClass(tableStyle, cellStyle, curentLocationStyle, curentLocation, blankBulletSource, hoverBulletSource, initialBulletURL){
    this.navTableStyle = tableStyle;
    this.navCellStyle = cellStyle;
    this.navCurLocStyle = curentLocationStyle;
    this.navCurLoc = curentLocation;
    this.navBlankBullet = blankBulletSource;
    this.navHoverBullet = hoverBulletSource;
    this.navInitBullet = initialBulletURL;
    this.bgOffColor = "#0000FF";
    this.bgOvrColor = "#800080";
    this.linkOffColor = "#FFFFFF";
    this.linkOvrColor = "#0000FF";

    this.showMenu = showMenu;
    this.showLinks = showLinks;
}

function showMenu(){
    document.writeln("<TABLE class='"+this.navTableStyle+"' dir='ltr' width='100%' summary='Site Vertical Navigation Links'>");
    document.writeln("<TBODY>");
    for (menuItem=0;menuItem<MenuSelections.length;menuItem++){
        var itemID = MenuSelections[menuItem][0].toLowerCase().replace(/ /gi,"_");
        document.writeln("<TR><TD class='"+this.navCellStyle+"' id='"+itemID+"' onMouseOver=\"ChangeBckGrnd('"+itemID+"','"+this.bgOvrColor+"')\" onMouseOut=\"ChangeBckGrnd('"+itemID+"','"+this.bgOffColor+"')\">");
        document.writeln("<img src="+this.navInitBullet+" alt='blank bullet' border='0' align='middle' name='page"+menuItem+"bullet'>&nbsp;<A class='"+this.navCellStyle+"' href='"+MenuSelections[menuItem][2]+"' id=page"+menuItem+"link onMouseOver=\"HighLight('page"+menuItem+"link','"+this.linkOvrColor+"','"+this.bgOvrColor+"');document.page"+menuItem+"bullet.src="+this.navHoverBullet+";window.status='"+MenuSelections[menuItem][1]+"';return true\" onMouseOut=\"HighLight('page"+menuItem+"link','"+this.linkOffColor+"','"+this.bgOffColor+"');document.page"+menuItem+"bullet.src="+this.navBlankBullet+";window.status='';return true\">"+MenuSelections[menuItem][0]+"</A>");
        document.writeln("</TD></TR>");
    }
    document.writeln("</TBODY></TABLE>");
}

function showLinks(){
    document.writeln("<table dir='ltr' width='80%' summary='Site Navigation Horizontal Links'><tr align='center'>");
    for (menuItem=0;menuItem<MenuSelections.length;menuItem++){
        document.writeln("<TD align='center'>&nbsp;<A href='"+MenuSelections[menuItem][2]+"' onMouseOver=\"window.status='"+MenuSelections[menuItem][1]+"';return true\" onMouseOut=\"window.status='';return true\">"+MenuSelections[menuItem][0]+"</A>&nbsp;</TD>");
        if ((menuItem+1)%5==0){
            document.writeln("</tr><tr>");
        }
    }
    document.writeln("</tr></table>");
}

function openEmails()
{
    EmailInfoWin = window.open('email_list.html','emails','toolbar=no,status=yes,scrollbars=yes,location=no,menubar=no,directories=no,width=500,height=350');
}
