﻿/*
* jsmain.js
*/

//jQuery.noConflict();

jQuery(document).ready(function() {

    var date = new Date();
    var year = date.getFullYear();
    jQuery('#copyrightYear').html(year);

    // flip the dates on the membership page on 6/1 each year. Months begin with 0.
    var membershipDate = new Date(year, 5, 1);
    if (date < membershipDate) {
        jQuery('#ThisYearMembership').html(year - 1);
        jQuery('#NextYearMembership').html(year);
        $("a[href='PDF/GNA_Membership']").attr('href', 'PDF/GNA_Membership_' + (date.getFullYear() - 1) + '-' + year + '.pdf')
    }
    else {
        jQuery('#ThisYearMembership').html(year);
        jQuery('#NextYearMembership').html(year + 1);
        try {
            $("a[href='PDF/GNA_Membership']").attr('href', 'PDF/GNA_Membership_' + year + '-' + (year+1) + '.pdf')
        }
        catch(Error) {
        }
    }

    // find class starting with hideafter
    jQuery('[class^="hideafter"]').each(function() {
        // split off class name to get date
        var elem = this.className.split('_');

        // if it is less than or equal to 10 char, add time or it defaults to 00:00
        // this is for comparison later so item stays visible to the end of the day.
        if (elem[1].length <= 10)
            elem[1] += " 23:59:00";
        var testDate = new Date(elem[1]);
        //alert('className: ' + this.className + ' tagName: '+ this.tagName +' Date: ' + testDate.toString());
        var currentDate = new Date();
        if (currentDate > testDate) {
            $(this).hide();
        }
    });


    try {
        jQuery('.slideshow').cycle({
            fx: 'fade',
            timeout: 1000,
            speed: 3000,
            autostop: true,
            autostopCount: 100,
            pause: false,
            random: true
        });
    }
    catch (err)
    { }

    jQuery('.colorRows tr:even').addClass('evenRow');
    jQuery('.colorRows tr:odd').addClass('oddRow');

});

