<!--
var newLine = '\n';

/*****************************************************************************
*        File: cal.js
* Description: General code for the website
*****************************************************************************/
var subHilite = 'AAAAAA';
var subNormal = 'EEEEEE';
var viewVisible = 'visible';
var viewHidden = 'hidden';

/*****************************************************************************
*    Function: monthName
* Description: Generate the name of the month from the month number.
*  Parameters: monthNo - The number of the month to get the name for. 0 =
*                        January
*****************************************************************************/
function monthName(monthNo) {

    if (monthNo == 0)
        return 'January';
    else if (monthNo == 1)
        return 'February';
    else if (monthNo == 2)
        return 'March';
    else if (monthNo == 3)
        return 'April';
    else if (monthNo == 4)
        return 'May';
    else if (monthNo == 5)
        return 'June';
    else if (monthNo == 6)
        return 'July';
    else if (monthNo == 7)
        return 'August';
    else if (monthNo == 8)
        return 'September';
    else if (monthNo == 9)
        return 'October';
    else if (monthNo == 10)
        return 'November';
    else if (monthNo == 11)
        return 'December';
    else
        return 'Unknown';

}

/*****************************************************************************
*    Function: getSearchValue
* Description: Determine the value of a parameter that was passed in the
*              location.search
*  Parameters: parm - The parameter to get the value of
*              search - location.search
*****************************************************************************/
function getSearchValue(parm, search) {
    var startPos = search.indexOf(parm + '=');
    var endPos;
    var rtn = '';

    if (startPos >= 0) {
        startPos += parm.length  + 1;
        endPos = search.indexOf('&', startPos);

        if (endPos < 0)
            endPos = search.length;

        rtn = unescape(search.substring(startPos, endPos));
    }

    return rtn;

}

/*****************************************************************************
*    Function: getSearchParms
* Description: Determine the parameters passed in the location.search
*  Parameters: search - The string to search for query parameters
*     Returns: Array of search string parameters
*****************************************************************************/
function getSearchParms(search) {
    var aParms = new Array();
    var s = 0;
    var e = 0;

    while (s < search.length) {
        if (s <= 0)
            s = search.indexOf('?', s);
        else
            s = search.indexOf('&', s);

        if (s >= 0) {
            s++;  // Skip past the ? or &
            e = search.indexOf('=', s);

            if (e > s) {
                aParms.push(search.substring(s, e));
                s = e++;  // Move the next start to after the last end
            }
            else
                s = search.length;

        }
        else
            s = search.length;

    }

    return aParms;

}

/*****************************************************************************
*    Function: imageVette
* Description: Class to hold data to build an image
*  Parameters: source - The name of the file to be displayed
*              alt - The value to place in the alt parameter of the IMG tag
*              width - The desired width of the image
*              height - The desired height of the image
*     Returns: Nothing
*****************************************************************************/
function imageVette(source, alt, width, height) {

    this.source = source;
    this.alt = alt;
    this.width = width;
    this.height = height;

}

/*****************************************************************************
*    Function: indexVette
* Description: Determine the image to display on the main page
*  Parameters: None
*     Returns: An image tag with the selected image
*****************************************************************************/
function indexVette() {
    var images = new Array();
    var sp = showSponsors();
    var imagePos

    // Build the array of images
    images.push(new imageVette('56V.png',
                               '56V.png (20817 bytes)',
                               '300',
                               '139'));

    images.push(new imageVette('63C.png',
                               '63C.png (17527 bytes)',
                               '300',
                               '165'));

    images.push(new imageVette('67V.png',
                               '67V.png (14644 bytes)',
                               '300',
                               '151'));

    images.push(new imageVette('72V.png',
                               '72V.png (14803 bytes)',
                               '300',
                               '126'));

    images.push(new imageVette('75C.png',
                               '75C.png (11671 bytes)',
                               '300',
                               '125'));

    images.push(new imageVette('89V.png',
                               '89V.png (14771 bytes)',
                               '300',
                               '121'));

    images.push(new imageVette('93C.png',
                               '93C.png (16497 bytes)',
                               '300',
                               '153'));

    images.push(new imageVette('newcorvette.gif',
                               'newcorvette.jpg (8272 bytes)',
                               '300',
                               '131'));

    images.push(new imageVette('01V.png',
                               '01V.png (17720 bytes)',
                               '300',
                               '142'));

    images.push(new imageVette('05C.png',
                               '05C.png (16423 bytes)',
                               '300',
                               '131'));

    // Determine which image to use
    imagePos = (new Date().getMilliseconds()) % images.length;

    // Build the IMG tag
    return sp[0] + "&nbsp;&nbsp;" +
           "<img src='images/" + images[imagePos].source + "' " +
           "alt='" + images[imagePos].alt + "' " +
           "width='" + images[imagePos].width + "' " +
           "height='" + images[imagePos].height + "' class='homeSponsor'>" +
           "&nbsp;&nbsp;" + sp[1];

}

/*****************************************************************************
*    Function: showSponsors
* Description: Place the sponsor logos randomly
*  Parameters: None
*     Returns: An array containing the sponsor logos
*****************************************************************************/
function showSponsors()
{
    var sp1 = '<a href="http://www.davegill.com" target="_blank"><img src="images/davegill.png" alt="Dave Gill Logo" width="185" height="55" class="homeSponsor"></a>';
    var sp2 = '<a href="http://www.bobmcdormanchevrolet.com" target="_blank"><img src="images/bobmcdorman.png" alt="Bob McDorman Logo" width="185" height="99" class="homeSponsor"></a>';
    var order = (new Date().getMilliseconds()) % 2;
    var sponsors = new Array(2);

    if (order == 0)
    {
        sponsors[0] = sp1;
        sponsors[1] = sp2;
    }
    else
    {
        sponsors[0] = sp2;
        sponsors[1] = sp1;
    }

    return sponsors;

}

/* Begin Code to operate the side and sub-menu system */
/*****************************************************************************
*    Function: showSubMenu
* Description: Display a popup menu
*  Parameters: menuName - Name of the menu to display
*              leftPos - Position of the left edge of the menu
*              topPos - Position of the top of the menu
*****************************************************************************/
function showSubMenu(menuName, leftPos, topPos) {

    if (document.getElementById(menuName)) {

        with (document.getElementById(menuName).style) {
            if (leftPos > 0 && topPos > 0) {
                left = leftPos;
                top = topPos;
            }

            visibility = viewVisible;
        }

    }

}

/*****************************************************************************
*    Function: hideSubMenu
* Description: Hide a popup menu
*  Parameters: menuName - Name of the menu to hide
*****************************************************************************/
function hideSubMenu(menuName) {

    if (document.getElementById(menuName))
        document.getElementById(menuName).style.visibility = viewHidden;

}

/*****************************************************************************
*    Function: hiliteSubMenu
* Description: Hilite/dehilite a menu item
*  Parameters: itemName - Name of the menu item to hilite
*              hilite - Ttrue to hilite the item, false to de-hilite
*****************************************************************************/
function hiliteSubMenu(itemName, hilite) {

    if (hilite)
        document.getElementById(itemName).style.backgroundColor = subHilite;
    else
        document.getElementById(itemName).style.backgroundColor = subNormal;

}

/*****************************************************************************
*    Function: findXPos
* Description: Return the window position of the left edge of the object
*  Parameters: obj - The object to find the left position of
*****************************************************************************/
function findXPos(obj) {
    var curPos = 0;

    while (obj.offsetParent) {
        curPos += obj.offsetLeft
        obj = obj.offsetParent;
    }

    return curPos;
}

/*****************************************************************************
*    Function: findXPosRight
* Description: Return the window position of the right edge of the object
*  Parameters: obj - The object to find the right position of
*     Returns: The offset to the right edge of the object
*****************************************************************************/
function findXPosRight(obj) {

    return findXPos(obj) + obj.offsetWidth;

}

/*****************************************************************************
*    Function: findYPos
* Description: Return the window position of the top edge of the object
*  Parameters: obj - The object to find the top position of
*****************************************************************************/
function findYPos(obj) {
    var curPos = 0;

    while (obj.offsetParent) {
        curPos += obj.offsetTop
        obj = obj.offsetParent;
    }

    return curPos;
}

/*****************************************************************************
*    Function: createSubMenu
* Description: Generate a submenu
*  Parameters: subMenuName - Name of the new menu
*              aMenuItems - Text that is to appear in the menu
*              aMenuLinks - Link to associate with the menu item
*****************************************************************************/
function createSubMenu(subMenuName, aMenuItems, aMenuLinks) {
    var subMenuClass = 'subMenu1a';
    var menu = '';
    var i;

    menu += '<div id=\'' + subMenuName + '\' class=\'subMenu1\' ' +
            'onMouseOver=\"javascript: showSubMenu(\'' + subMenuName + '\', -1, -1);\" ' +
            'onMouseOut=\"javascript: hideSubMenu(\'' + subMenuName + '\');\">';
    menu += '<table class=\'subMenu1\'>';

    for (i = 0; i < aMenuItems.length; i++) {
        menu += '<tr>';

        if (i >= aMenuItems.length - 1)
            subMenuClass = 'subMenu1b';

        menu += '<td class=\'' + subMenuClass + '\' id=\'' + subMenuName + i + '\' ' +
                'name=\'' + subMenuName + i + '\' ' +
                'onMouseOver=\"javascript: hiliteSubMenu(\'' + subMenuName + i + '\', true);\" ' +
                'onMouseOut=\"javascript: hiliteSubMenu(\'' + subMenuName + i + '\', false);\">';
        menu += '<a href=\'' + aMenuLinks[i] + '\' class=\'subMenu1\'>' + aMenuItems[i] + '</a>';
        menu += '</td>';
        menu += '</tr>';

    }

    menu += '</table>';
    menu += '</div>';

    return menu;

}

/*****************************************************************************
*    Function: loadSubMenu1
* Description: Generate the driveline sub-menu
*  Parameters: None
*****************************************************************************/
function loadSubMenu1() {
    var menuItems = new Array('Intro',
                              'President\'s Page',
                              'Secretary\'s Report',
                              'Treasurer\'s Report',
                              'Membership List',
                              'Birthdays');
    var menuLinks = new Array('driveline.htm',
                              'driveline.htm?article=artPP0',
                              'driveline.htm?article=artSR0',
                              'driveline.htm?article=artTR',
                              'driveline.htm?article=artML',
                              'driveline.htm?article=artBD');

    return createSubMenu('driveline', menuItems, menuLinks);

}

/*****************************************************************************
*    Function: loadSubMenu2
* Description: Generate the calendar sub-menu
*  Parameters: None
*****************************************************************************/
function loadSubMenu2() {
    var menuItems = new Array('Event List',
                              new Date().getFullYear() + ' Calendar');
    var menuLinks = new Array('calendar.htm',
                              'calendar.htm#calendar');

    return createSubMenu('calmenu', menuItems, menuLinks);

}

/*****************************************************************************
*    Function: loadSubMenu3
* Description: Generate the More Info sub-menu
*  Parameters: None
*****************************************************************************/
function loadSubMenu3() {
    var menuItems = new Array('Monthly Events',
                              'Club Meetings',
                              'Driveline Newsletter',
                              'And More',
                              'The History',
                              'Bylaws',
                              'Past Officers',
                              'CIP Judging Form',
                              'About this Site');
    var menuLinks = new Array('morecccc.htm#MONTHLYEVENTS',
                              'morecccc.htm#CLUBMEETINGS',
                              'morecccc.htm#DRIVELINENEWSLETTER',
                              'morecccc.htm#ANDMORE',
                              'morecccc.htm#THEHISTORY',
                              'Bylaws.htm',
                              'OfficerHist.htm',
                              'CIPJudge.htm',
                              'about.htm');

    return createSubMenu('more', menuItems, menuLinks);

}

/*****************************************************************************
*    Function: loadSubMenu4
* Description: Generate the photos sub-menu
*  Parameters: None
*****************************************************************************/
function loadSubMenu4() {
    var menuItems = new Array('Event Photos',
                              'New Member Photos');
    var menuLinks = new Array('picture.htm',
                              'nm.htm');

    return createSubMenu('picmenu', menuItems, menuLinks);

}

/*****************************************************************************
*    Function: loadSubMenuAll
* Description: Generate all of the sub-menus
*  Parameters: None
*****************************************************************************/
function loadSubMenuAll() {

    return loadSubMenu1() +
           loadSubMenu2() +
           loadSubMenu3()
           //loadSubMenu4();

}

/*****************************************************************************
*    Function: menuItem
* Description: Class to hold information about a menu item
*  Parameters: link - The url of the link's destination
*              item - The string to display in the link
*              submenu - The name of the submenu to display on a mouse over.
*                        Null if no submenu
*              style - The name of the stylesheet class to use when
*                      generating the anchor
*     Returns: Nothing
*****************************************************************************/
function menuItem(link, item, submenu, style) {

    this.link = link;
    this.item = item;
    this.submenu = submenu;
    this.style = style;
    this.generate = makeMenuItem;

}

/*****************************************************************************
*    Function: makeMenuItem
* Description: Generate a menu item for the main menu
*  Parameters: None
*     Returns: A formatted anchor for use in the main menu
*****************************************************************************/
function makeMenuItem() {
    var anchor = "<a href='" + this.link + "' class='" + this.style + "'";

    if (this.submenu != null) {
        anchor += " onMouseOver=\"javascript: showSubMenu('" + this.submenu +
                  "', findXPosRight(this) - 1, findYPos(this));\"";

        anchor += " onMouseOut=\"javascript: hideSubMenu('" + this.submenu + "');\"";
    }

    anchor += '>' + this.item + '</a><br>';

    return anchor;

}

/*****************************************************************************
*    Function: mainMenu
* Description: Generate the main menu for each web page
*  Parameters: None
*****************************************************************************/
function mainMenu() {
    var menu = '<br>' + newLine;
    var style = 'mainMenu';
    var items = new Array(new menuItem('index.html', 'Home', null, style),
                          new menuItem('driveline.htm', 'DriveLine', 'driveline', style),
                          new menuItem('clubnews.htm', 'Extra', null, style),
                          new menuItem('calendar.htm', 'Calendar', 'calmenu', style),
                          new menuItem('events.htm', 'Events', null, style),
                          new menuItem('morecccc.htm', 'More Info', 'more', style),
                          new menuItem('sponsors.htm', 'Sponsors', null, style),
                          new menuItem('links.htm', 'Links', null, style),
                          new menuItem('picture.htm', 'Photos', 'picmenu', style),
                          new menuItem('showApp.htm', 'Membership<br>Form', null, 'mainMenu2'));

    menu += "<p class='mainMenu'><br>" + newLine;

    for (var i = 0; i < items.length; i++)
        menu += items[i].generate() + newLine;

    menu += '</p>';

    return menu;

}
/* End of code to operate the side and sub-menu system */

/* Begin code to display the full size picture popup page */
/*****************************************************************************
*    Function: showForm
* Description: Display a picture in a popup window
*  Parameters: file - Name of the file that contains the image to display
*              width - Width of the image to display
*              height - Height of the image to display
*              caption - The caption to display with the image
*****************************************************************************/
function showForm(file, width, height, caption) {
    var windowName = 'ShowPicture';
    var windowParms = 'width=700,height=400,dependant=yes,scrollbars=yes,left=50,top=50,resizable=yes,location=no';

    var docWindow = window.open('DisplayDoc.htm?file=' + file + '&w=' + width + '&h=' + height + 'caption=' + caption,
                                windowName, windowParms);

}

/*****************************************************************************
*    Function: closeWindow
* Description: Close the picture popup window
*  Parameters: None
*****************************************************************************/
function closeWindow() {

    window.parent.focus();
    window.close();

}

/*****************************************************************************
*    Function: getFile
* Description: Generate the source string to use with the IMG tag
*  Parameters: parms - Relative location of the image from the website
*****************************************************************************/
function getFile(parms) {
    var parmName = 'file=';
    var fileStart = parms.indexOf(parmName);
    var fileEnd = parms.indexOf('&', fileStart);

    if (fileEnd < 0)
        fileEnd = parms.length;

    return parms.substring(fileStart + parmName.length, fileEnd);

}

/*****************************************************************************
*    Function: getWidth
* Description: Generate the width parameter for the IMG
*  Parameters: parms - Relative location of the image from the website
*****************************************************************************/
function getWidth(parms) {
    var stdW = 384;
    var parmName = 'w=';
    var wStart = parms.indexOf(parmName);
    var wEnd = parms.indexOf('&', wStart);
    var iWidth = stdW;

    if (wStart > 0) {
        if (wEnd < 0)
            wEnd = parms.length;

        iWidth = parseFloat(parms.substring(wStart + parmName.length, wEnd));

}

    return iWidth;

}

/*****************************************************************************
*    Function: getHeight
* Description: Generate the height parameter for the IMG
*  Parameters: parms - Relative location of the image from the website
*****************************************************************************/
function getHeight(parms) {
    var stdH = 256;
    var parmName = 'h=';
    var hStart = parms.indexOf(parmName);
    var hEnd = parms.indexOf('&', hStart);
    var iHeight = stdH;

    if (hStart > 0) {
        if (hEnd < 0)
            hEnd = parms.length;

        iHeight = parseFloat(parms.substring(hStart + parmName.length, hEnd));

    }

    return iHeight;

}

/*****************************************************************************
*    Function: getCaption
* Description: Get the caption to display below the picture
*  Parameters: parms - Parameters from the URL
*     Returns: String - The caption
*****************************************************************************/
function getCaption(parms) {
    var parmName = 'caption=';
    var hStart = parms.indexOf(parmName);
    var hEnd = parms.indexOf('&', hStart);
    var caption;

    if (hStart > 0) {
        if (hEnd < 0)
            hEnd = parms.length;

        caption = parms.substring(hStart + parmName.length, hEnd);

    }

    return caption;

}
/* End code to display the full size picture popup page */

/* Begin code to display the photo album */
/*****************************************************************************
*      Object: picture
* Description: Holds information about a picture and its related thumbnail
*  Parameters: thumb - Name of the thumbnail image
*              thumbWidth - Width to display the thumbnail
*              thumbHeight - Height to display the thumbnail
*              pName - Name of the full size photo
*              pWidth - Width to display the full size photo
*              pHeight - Height to display the full size photo
*              caption - The caption to show with the picture
*****************************************************************************/
function picture(thumb, thumbWidth, thumbHeight, pName, pWidth, pHeight, caption) {
    this.picture = pName;
    this.pwidth = pWidth;
    this.pheight = pHeight;
    this.thumb = thumb;
    this.twidth = thumbWidth;
    this.theight = thumbHeight;
    this.caption = caption;
}

/*****************************************************************************
*    Function: addPicture
* Description: Method of pictureGroup.  Adds a picture to the list in the
*              group
*  Parameters: thumb - Name of the thumbnail image
*              thumbWidth - Width to display the thumbnail
*              thumbHeight - Height to display the thumbnail
*              fullPic - Name of the full size photo
*              fullWidth - Width to display the full size photo
*              fullHeight - Height to display the full size photo
*              caption - The caption to show with the picture
*****************************************************************************/
function addPicture(thumb, thumbWidth, thumbHeight, fullPic, fullWidth, fullHeight, caption) {
    var p = new picture(thumb, thumbWidth, thumbHeight, fullPic, fullWidth, fullHeight, caption);

    this.group.push(p);

}

/*****************************************************************************
*      Object: pictureGroup
* Description: Holds information about a group of pictures and their related
*              thumbnails
*  Parameters: None
*****************************************************************************/
function pictureGroup() {
    this.group = new Array();
    this.add = addPicture;
}

/*****************************************************************************
*    Function: buildPictureGroup
* Description: Build the HTML for a picture group
*  Parameters: anchorName - Hash for the picture group
*              title - Displayed title of the group
*              pPath - Path to the pictures in the group
*              pGroup - Pictures in the group
*****************************************************************************/
function buildPictureGroup(anchorName, title, pPath, pGroup) {
    var output = '';
    var i;

    if (pPath.substr(pPath.length - 1, 1) != '/')
        pPath += '/';

    output += '<p class=\'pictures\'>';
    output += '<a name=\'' + anchorName + '\' class=\'pictures\'>' + title + '</a><br>';

    for (i = 0; i < pGroup.group.length; i++) {
        with (pGroup.group[i]) {
            output += '<a href="javascript:showForm(\'' + pPath + picture + '\', ' + pwidth + ', ' +
                      pheight + ', \'' + caption + '\');">';
            output += '<img src=\'' + pPath + thumb + '\' width=\'' + twidth + '\' height=\'' + theight + '\'>';
            output += '</a> ';
        }
    }

    output += '</p>';

    return output;
}

/*****************************************************************************
*    Function: createPictureGroup
* Description: Create a generic picture group with now exceptions
*  Parameters: first - The first picture ID to use (ie. XXX1.jpg)
*              last - The last picture ID to use (ie. XXX32.jpg)
*              pnRoot - The XXX part of the picture name that preceeds the ID
*              thumbW - Width of the thumbnails to display
*              thumbH - Height of the thumbnails to display
*              pW - Width of the full size images to display
*              pH - Height of the full size images to display
*              name - Hash used to identify the group
*              title - Displayed title of the group
*              path - Path to the pictures in the group
*              skip - A space and semicolon delimited list of IDs to skip.
*                     To skip 3 and 7 use ' 3; 7;'
*****************************************************************************/
function createPictureGroup(first, last, pnRoot, thumbW, thumbH, pW, pH, name, title, path, skip, fileType) {
    var pGroup = new pictureGroup();
    var thumbType = 'a.jpg';
    var imageType = '.jpg';
    var i;
    var is;

    if (fileType) {
        thumbType = 'a.' + fileType;
        imageType = '.' + fileType;
    }

    for (i = first; i <= last; i++)
        if (skip.indexOf(' ' + i + ';') < 0)
        {
            if (i < 10)
                is = '0' + i;
            else
                is = i;

            pGroup.add(pnRoot + is + thumbType, thumbW, thumbH, pnRoot + is + imageType, pW, pH, '');
        }

    document.writeln(buildPictureGroup(name, title, path, pGroup));

}
/* End code to display the photo album */

/*****************************************************************************
*       Class: Officer
* Description: Hold information about an officer
*  Parameters: name - Name of the officer
*              phone - Phone number of the officer
*     Returns: Nothing
*****************************************************************************/
function Officer(name, phone) {

    this.name = name;
    this.phone = phone;

}
//-->
