$(document).ready(function() {
    // IE6 Goodies
    // *******************************************************
    if ($.browser.msie && $.browser.version < 7) {
        // Drop Down menu
        $('#navigation ul li.dropdown').mouseover(function () {
            $(this).children('ul').show();
            //faderIn($(this).children('ul'));
        });
        $('#navigation ul li.dropdown').mouseout(function () {
            //faderOut($(this).children('ul'));
            $(this).children('ul').hide();
        });
    }

    // Resizeable textareas
    // *******************************************************
    $("textarea").resizable({
        handles: "se"
    });

    // INITIATIVES HOVER CAPTION & MOUSE TRACKING
    // *******************************************************
    var speed = 200;
    $('#initiatives ul li').hover(
    function () {
        faderIn($(this).children().children('.overlay'));
    },
    function () {
        faderOut($(this).children().children('.overlay'));
    });
    $('#initiatives ul li').mousemove(function(e) {
        //$('p.pos').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);
        $(this).children().children('.overlay').css({left:(e.pageX - 20), top:e.pageY});
    });

    // CALENDAR HOVER CAPTION
    // *******************************************************
    $('#eventsCalendar table#calendar td.event').hover(
    function (e) {
        faderIn($(this).children().children('.overlay'));
        $(this).children().children('.overlay').css({left:(e.pageX - 20), top:e.pageY});
    },
    function () {
        faderOut($(this).children().children('.overlay'));
    });

    // FADING FUNCTION
    // *****************************************************
    function faderIn(obj){
        // prevents FF 2 rendering issues
        if($.browser.mozilla && $.browser.version.substr(0,3) == "1.8") {
            obj.show();
        } else {
            obj.fadeIn(speed);
        }
    }
    function faderOut(obj){
        // prevents FF 2 rendering issues
        if($.browser.mozilla && $.browser.version.substr(0,3) == "1.8") {
            obj.hide();
        } else {
            obj.fadeOut(speed);
        }
    }

    // GET & APPLY WIDTH TO SPONSORS CONTAINER
    // *******************************************************
    /*var theWidth = 0;
    $('#sponsors ul li img').each(function () {
        var imgWidth = $(this).width();
        theWidth += imgWidth + 10;

    });
    $('#sponsors ul').width(theWidth);*/

    // INITIALIZE MODALs
    // *******************************************************
    $('#login').click(function (e) {
        e.preventDefault();
        $('#loginForm').modal();
    });
    $('#enews').click(function (e) {
        e.preventDefault();
        $('#enewsForm').modal();
    });

    // TOOLS
    // *******************************************************
    $('a.print').click(function () {
        print();
    });

    // Increase Font Size
  $("a.larger").click(function(){
          ChangeFontSize(1.05);
        return false;
      });

  $("a.smaller").click(function(){
          ChangeFontSize(0.95);
        return false;
      });

    function ChangeFontSize(size)
    {
            $("div").each(function (i) {
            currentFontSize = $(this).css('font-size');
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var newFontSize = currentFontSizeNum*size;
            $(this).css('font-size', newFontSize + "px");
        });

    }
    // EQUAL COLUMN HEIGHTS
    // *******************************************************
    var columns = new Array()
    $('.column').each(function (i) {
        columns.push($(this).height());
        //$(this).height();
    });
    columns.sort();
    $('.column').css({'min-height':columns[1]+20});
    if ($.browser.msie && $.browser.version < 7) {
        $('.column').css({'height':columns[1]+20});
    }
});