var CurrentMonth; // Public variable used in the "script_Calendar.js" file when viewing the Calendar.

// Note: Java interprets relative paths as relative to the caller. Therefore, if functionA
//   is called from pageA, all relativity is with respect to pageA. If pageB exists in a different
//   path than pageA, then relative paths on pageA will not be the same as those on pageB.

function writeRelativePath(endLocation)
{
    var s = new String;
    
    s = "";
    s = rootPath + endLocation
}

// This function will disable the right-click feature across the board for all pages with the
// body tag containing this call for the onmousedown event.
// ** This operation is only handled for IE - it does not work reliably for other browsers
function disableRightClick()
{
    var disable = new Boolean;
    
    // Set the flag for global allow or disallow of right click
    disable = false; // true = NOT Allowed (disable right click), false = Allowed (do NOT disable right click)
    
    if(disable)
    {
        alert("Not available");
    }
}

// The '\' character is necessary  before all internal '"' marks of a string.
// Anywhere a quotation mark must show in the html being written in the string,
// the '\' character must preceed it. This is a switch to allow the quotation mark
// to transfer literally. Otherwise, it would be interpreted as an end-of-string.

// This function creates and returns the current date in the following format:
// dayofweek(string), monthname(string) day(number), year(4-digit)
function displayDate()
{
    CurrentMonth = new String();
    CurrentMonth = "";
    
    var months = new Array(12);
    months[0]  = "January";
    months[1]  = "February";
    months[2]  = "March";
    months[3]  = "April";
    months[4]  = "May";
    months[5]  = "June";
    months[6]  = "July";
    months[7]  = "August";
    months[8]  = "September";
    months[9]  = "October";
    months[10] = "November";
    months[11] = "December";
   
    var daysOfWeek = new Array(7);
    daysOfWeek[0]  = "Sunday";
    daysOfWeek[1]  = "Monday";
    daysOfWeek[2]  = "Tuesday";
    daysOfWeek[3]  = "Wednesday";
    daysOfWeek[4]  = "Thursday";
    daysOfWeek[5]  = "Friday";
    daysOfWeek[6]  = "Saturday";
    
    var dateString;
    var now = new Date(); // Get the current date from the local computer
    var weekDay = now.getDay(); // Get the number of the current day-of-the-week
    var day = now.getDate(); // Get the number of the day in the month
    var month = now.getMonth(); // Get the number of the month in the year
    var year = now.getYear(); // Get the number of the year
    
    // Assemble the string containing the full date
    // Get the day-of-the-week and the month name using an array lookup.
    dateString = daysOfWeek[weekDay] + ", " + months[month] + " " + day + ", " + year;
    
    CurrentMonth = months[month];
    
    return dateString; // return the string to the caller
}

// Function for creating the Header bar
// The folderLevel argument is used to determine the appropiate relative paths for the images.
// folderLevel = 0  :  This assumes that the calling page is at the root level of the site.
// folderLevel = 1  :  This assumes that the calling page is contained within a folder in the root.

// Further levels can be added with the addition of subsequent "if" statements to assign the correct relative path.
// When adding deeper levels, a variable must be created and used for each level off the root.
function createHeader(folderLevel)
{   
    var s = new String;

    s = "";
        
    s += "<div class=\"centered\">";
        s += "<table class=\"header\" cellspacing=\"0\" cellpadding=\"0\">";
        s += "<tbody>";
            s += "<tr valign=\"top\">";
            // This section of code simply checks to determine the sub-folder level specified
            // in the "folderLevel" variable. It then places the proper path prefix in the string
            // to keep proper relative paths for the page. This checking is also contained in the
            // sitemenu.js file for the java menu.
            
            // Check for the subfolder level.
            if( folderLevel == 0 )
            {
                // Calling page is at the root level
                
                // Cell containing the left-hand image [Size: height=80px width=200px ( the width is a static size)]
                s += "<td style=\"width:200px;\" align=\"left\">";
                    s += "<img src=\"common_images/baybridge_80x160.jpg\" alt=\"Picture\" />"
                s += "</td>";
                
                // Cell containing the ANSA heading text [Size: height=80px width=auto (the width
                //  (will grow or shrink to the available space in the window)]
                s += "<td style=\"width:auto;\" align=\"center\">";
                    s += "<img src=\"common_images/HeaderText.jpg\" alt=\"ANSA\" />";
                s += "</td>";
                
                // Cell containing Burgee [Size: height=80px width=150px (the width is a static size)]
                s += "<td style=\"width:150px;\" align=\"center\">";
                    s += "<img src=\"common_images/Burgee.gif\" alt=\"ANSA Burgee\" />";
                s += "</td>";    
            }
            else
            {
                // Calling page is at one level below the root.
                
                // Currently only two levels of folders exist. This can easily be extended further
                // by adding "else if" statements and testing for lower levels and creating another
                // variable to contain the proper path.
                s += "<td style=\"width:200px;\" align=\"left\">";
                    s += "<img src=\"" + rootPath + "common_images/baybridge_80x160.jpg\" alt=\"Picture\" />"
                s += "</td>";
                s += "<td style=\"width:auto;\" align=\"center\">";
                    s += "<img src=\"" + rootPath + "common_images/HeaderText.jpg\" alt=\"ANSA\" />";
                s += "</td>";
                s += "<td style=\"width:150px;\" align=\"center\">";
                    s += "<img src=\"" + rootPath + "common_images/Burgee.gif\" alt=\"ANSA Burgee\" />";
                s += "</td>";    
            }
            
            s += "</tr>";
        s += "</tbody>";
        s += "</table>";
    s += "</div>";
        
    document.write(s);
}

function createHorizontalMenu(sectionNumber)
{
    var s = new String;
    
    s = "";
    
    s += "<div>";
        s += "<p class=\"menu\">";
        
            if( sectionNumber == "home" ) // Main index page
            {
                s += "<a class=\"menu\" href=\"index.html\"><span class=\"selected\">Home</span></a> | ";
                s += "<a class=\"menu\" href=\"aboutANSA/index_aboutANSA.html\">About ANSA</a> | ";
                s += "<a class=\"menu\" href=\"aboutANSA/page_MembershipCriteria.html\">Join ANSA</a> | ";
                s += "<a class=\"menu\" href=\"chandlery/index_chandlery.html\">Chandlery</a> | ";
                s += "<a class=\"menu\" href=\"activities/index_activities.html\">Activities</a> | ";
                s += "<a class=\"menu\" href=\"training/index_training.html\">Training</a> | ";
                s += "<a class=\"menu\" href=\"pictures/index_pictures.html\">Pictures</a> | ";
                s += "<a class=\"menu\" href=\"ketchall/index_ketchall.html\">Ketchall</a> | ";
                s += "<a class=\"menu\" href=\"associated_clubs/index_AssociatedClubs.html\">Associated Clubs</a> | ";
                s += "<a class=\"menu\" href=\"links/index_Links.html\">Links</a>";
            }
            else
            {
                s += "<a class=\"menu\" href=\"../index.html\">Home</a> | ";
                
                // About ANSA page
                s += "<a class=\"menu\" href=\"../aboutANSA/index_aboutANSA.html\"><span class=\"";
                
                if( sectionNumber == "about" ) s += "selected\""; else s += "menu\"";
                
                s += ">About ANSA</span></a> | ";
                
                // Membership page
                s += "<a class=\"menu\" href=\"../aboutANSA/page_MembershipCriteria.html\"><span class=\"";
                
                if( sectionNumber == "membership" ) s += "selected\""; else s += "menu\"";
                
                s += ">Join ANSA</span></a> | ";
                
                // Chandlery Page
                s += "<a class=\"menu\" href=\"../chandlery/index_chandlery.html\"><span class=\"";
                
                if( sectionNumber == "chandlery" ) s += "selected\""; else s+= "menu\"";
                
                s += ">Chandlery</span></a> | ";

                // Activities page
                s += "<a class=\"menu\" href=\"../activities/index_activities.html\"><span class=\"";
                
                if( sectionNumber == "calendar" ) s += "selected\""; else s += "menu\"";

                s += ">Activities</span></a> | ";
                
                // Training page
                s += "<a class=\"menu\" href=\"../training/index_training.html\"><span class=\"";
                
                if( sectionNumber == "training" ) s += "selected\""; else s += "menu\"";

                s += ">Training</span></a> | ";
                
                // Pictures page
                s += "<a class=\"menu\" href=\"../pictures/index_pictures.html\"><span class=\"";
                
                if( sectionNumber == "pictures" ) s += "selected\""; else s += "menu\"";

                s += ">Pictures</span></a> | ";
                                
                // Ketchall page
                s += "<a class=\"menu\" href=\"../ketchall/index_ketchall.html\"><span class=\"";
                
                if( sectionNumber == "ketchall" ) s += "selected\""; else s += "menu\"";

                s += ">Ketchall</span></a> | ";
                                
                // Associated Clubs page
                s += "<a class=\"menu\" href=\"../associated_clubs/index_AssociatedClubs.html\"><span class=\"";
                
                if( sectionNumber == "associations" ) s += "selected\""; else s += "menu\"";

                s += ">Associated Clubs</span></a> | ";
                                
                // Other Links page
                s += "<a class=\"menu\" href=\"../links/index_Links.html\"><span class=\"";
                
                if( sectionNumber == "links" ) s += "selected\""; else s += "menu\"";

                s += ">Links</span></a>"
            }
                        
        s += "</p>";
    s += "</div>";
    
    document.write(s);
}

// function for creating the Time and Weather Conditions bar
function createTimeAndConditions()
{
    var s = new String;
    
    s = "";
    
    s += "<table class=\"conditions\" cellpadding=\"0\" cellspacing=\"0\">";
        s += "<tr>";
        s += "<td style=\"width:30%; padding-left:5px;\" align=\"left\">";
            // Get the current date
            s += displayDate();
        s += "</td>";
        s += "<td style=\"width:30%; padding-right:5px\" align=\"right\">";
	    //s += "<a class=\"conditions\" href=\"http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/an/anz532.txt">Annapolis Maritime Conditions</a>";	
            s+= "<a class=\"conditions\" href=\"http://forecast.weather.gov/MapClick.php?CityName=Annapolis&state=MD&site=LWX&textField1=38.9716&textField2=-76.503&e=1\" target=\"_blank\">Annapolis Weather Conditions</a>";
            // Get current conditions
            //getConditions(); //Not yet written will replace following "table" code
        s += "</td>";
        s += "</tr>";
    s += "</table>";
    
    document.write(s);
}

// function for creating the footer of the page
function createFooter()
{
    var s = new String;
    
    s = "";
    
    s += "<table class=\"pagefooter\" cellpadding=\"0\" cellspacing=\"0\">";
        s += "<tbody>";
        s += "<tr>";
        s += "<td style=\"width:260px; padding-left:3px;\" align=\"left\">";
            s += "© Copyright 2010 ANSA";
        s += "</td>";
        s += "<td style=\"width:auto;\" align=\"center\">";
            s += "Contact: ";
            s += "<a class=\"webmaster\" href=\"mailto:webmaster@ansa.org\">webmaster@ansa.org</a>";
        s += "</td>";
        s += "<td style=\"width:260px; padding-right:3px;\" align=\"right\">";
            s += "Last Updated: Jan 2010";
        s += "</td>";
        s += "</tr>";
        s += "</tbody>";
    s += "</table>";
    
    document.write(s);
}
