// JavaScript Document

$(document).ready( function() {
    intializeSubMenus();
    $("#rightColumn tr:even").css("background-color","#D1D0BD");

    $(".stateColumn a:nth-child(3)").css("border-width","0");
});

// This code runs when the IMAGES and everything else has been loaded
// Resizes the right column to have the same height as window to the left
$(window).load( function() {
    var newHeight = $("#body").height();
    newHeight = (parseInt(newHeight)+19);
    $("#rightColumn").css("min-height", newHeight);
});

function intializeSubMenus(){
    navLinks = $('#nav').children('a');
    for(var i=0; i<navLinks.length; i++){
        nextItem = $(navLinks[i]).next('div');
        if(nextItem.length > 0){
            subMenu = nextItem[0];
            linkPosition = $(navLinks[i]).position();
            linkWidth = $(navLinks[i]).width();
            
            offset = linkPosition.left + 4;
            offset += "px";
            //alert(offset);
            $(subMenu).css({'left': offset});
            subMenuHover(navLinks[i], subMenu);
        }
    }
}

function subMenuHover(mainItem, subMenu){
    $(mainItem).hover(function(){
        $(subMenu).css('display','block');
    }, function(){
        $(subMenu).css('display','none');
    });
    $(subMenu).hover(function(){
        $(subMenu).css('display','block');
    }, function(){
        $(subMenu).css('display','none');
    });
}