//  navbar.js
//
//  This bit of JavaScript code actually fills in the standard navigation
//  bar on any page that includes it and has a <TR> element with ID equal
//  to "navbar_main".  It's a single place to maintain both the color-
//  changing code and the contents of the navigation bar itself.
//
//  (c) 2007-2009, Christopher Petersen, Crystallized Software
//
//------------------------------------------------------------------------------
//
//  Define the arrays that contain our labels and link targets
//
var  myLabels  = new Array ("Home",				//  Our main page
                            "Band History",                     //  The history of Morgantown
                            "Duane Allman Tribute",		//  The story of the tribute
                            "The Players",			//  An introduction to the band
                            "About the Songwriter",		//  More about David
                            "Listen to the Music",		//  Some of the music on-line
                            "Concert Schedule",			//  Schedule of new dates
                            "Photos",				//  Pictures from past gigs
                            "Fan Email",			//  E-mails from fans
                            "The Press",			//  Press clippings
                            "And More Press",			//  And more press clippings
                            "Contact Us",			//  Various links for contact
                            "");
var  myTargets = new Array ("/index.html",
                            "/BandHistory.html",
                            "/DuaneAllmanTribute.html",
                            "/ThePlayers.html",
                            "/Songwriter.html",
                            "/Music.html",
                            "/Schedule.html",
                            "/gigs/Gigs.html",
                            "/FanEmail.html",
                            "/ThePress.html",
                            "/MorePress.html",
                            "/ContactUs.html",
                            "");
//
//  Grab a handle to the <TD ID="navbar_main"> as our parent node
//
var  myParent  = document.getElementById ("navbar_main");
//
//  Define a prefix that we'll use to match against
//
var  myPrefix  = new String ("http://www.morgantownrocks.com");

//
//  Loop over the targets and add the prefix to each one
//
for (var x = 0; myTargets[x] != ""; x++)
{
    myTargets[x] = myPrefix + myTargets[x];
}

//
//  Loop again to add them to the <TABLE> <TR>
//
for (var x=0; myTargets[x] != ""; x++)
{
    //
    //  We always create and set up a <TD> element to tie it together
    //
    var newTD = document.createElement ("TD");
    newTD.setAttribute ("align", "center");
    newTD.setAttribute ("class", "bordered_b");

    newTD.style.borderWidth = "2px";
    newTD.style.borderStyle = "solid";
    newTD.style.borderColor = "#3b73fc";

//    newTD.style.setProperty ("border-width", "2px", "");
//    newTD.style.setProperty ("border-style", "solid", "");
//    newTD.style.setProperty ("border-color", "#3b73fc", "");

    //
    //  We always create a text element for the content
    //
    var newText  = document.createTextNode (myLabels[x]);

    //
    //  If this link points to this document, make it green text
    //
    if (document.URL == myTargets[x])
    {
        var newBold  = document.createElement ("B");
        var newSmall = document.createElement ("SMALL");

        newBold.appendChild (newText);
        newBold.style.color = "#00ff00";
        newSmall.appendChild (newBold);
        newTD.appendChild (newSmall);
    }

    //
    //  Otherwise, make it a link in the proper class
    //
    else
    {
        var newLink = document.createElement ("A");
        newLink.setAttribute ("class", "navbar");
        newLink.href  = myTargets[x];
        
        newLink.appendChild (newText);
        newTD.appendChild (newLink);
    }

    //
    //  Finally, add the new <TD> to the parent <TR>
    //
    myParent.appendChild (newTD);
}
