﻿
var elem = document.getElementById("eventTable");

if (elem) {
    var rows = elem.getElementsByTagName("tr");
    var nextYearDate = new Date("Dec 31, 2011");

    for (var i = 1, ii = rows.length; i < ii; i += 2) {
        rows[i].className = "altRow";
    }
    
    for (i = 1, ii = rows.length; i < ii; i++) {

        var tdItem = $(rows[i]).children().first();     //get the TD

        var sEventDate = tdItem.html();               //get the HTML

        if ((new Date(sEventDate)) > nextYearDate) {
            targetTR = rows[i];
            $('<tr><td><span>2012</span><td><td><td><td></td></td></td></td></td></tr>').insertBefore(targetTR).addClass('dateSeparator');
            break;
        }
    }
    
}

// Add 2012 to the list of events ***********************
var aItems = $(".year2012");
var targetTR = aItems[0].parentNode.parentNode;     //grab the first 2011 events grandparent (TR)
$('<tr><td><span>2012</span></td></tr>').insertBefore(targetTR).addClass('dateSeparator');

//Highlite the next event
var aItems = $(".nextEvent");
var targetTD = $(aItems[0]).children().first();      //grab the first next event's TD element
$('<span>NEXT</span>').insertAfter(targetTD).addClass('nextEventFirst');

//set up the nav functions
var site = function() {
    this.navLi = $('#nav li').children('ul').hide().end();
    this.init();
};

site.prototype = {

    init: function() {
        this.setMenu();
    },

    // Enables the slidedown menu, and adds support for IE6

    setMenu: function() {

        $.each(this.navLi, function() {
            if ($(this).children('ul')[0]) {
                $(this).append('<span class="hasChildren" />');
            }
        });

        this.navLi.hover(function() {
            // mouseover
            $(this).find('> ul').stop(true, true).slideDown('fast');
        }, function() {
            // mouseout
            $(this).find('> ul').stop(true, true).hide();
        });

    }

}


new site();



