﻿$(document).ready(function () {
    var curPage = 1; // Starting point
    var maxPage = $('ul.month').size(); // Grab how many months there are
    var width = 700; // width of calendar month = amount to slide

    // Set the previous link as disabled by default
    $('.prev').addClass('off');

    // Previous click 
    //$('.prev').click(function () {
    //    clearOverlay();
    //    curPage -= 1;
    //    LoadNewBanner();
    //    return false;
    //});

    // Next click
    //$('.next').click(function () {
    //    clearOverlay();
    //    curPage += 1;
    //    LoadNewBanner();
    //    return false;
    //});

    // Load new banner
    function LoadNewBanner() {
        $('.prev').removeClass('off');
        $('.next').removeClass('off');

        var oldPage = curPage;

        if (curPage <= 1) {
            curPage = 1;
            $('.prev').addClass('off');
        }
        else if (curPage >= maxPage) {
            curPage = maxPage;
            $('.next').addClass('off');
        }
        var speed = parseInt(Math.abs(curPage - oldPage) * 5000);
        speed += '';
        $('.calendar ul.year').animate({ marginLeft: -((curPage - 1) * width) + "px" }, speed, function () {
        });
    }

    // Switch View
    $("a.switcher").toggle(function () {
        clearOverlay();
        
		$(this).removeClass("swapped");
        $("ul.month .week").fadeOut("fast", function () {
        $('ul.month').removeClass("monthListView");
            $(this).fadeIn("fast");
        });
        return false;
    }, function () {
        $(this).addClass("swapped");
        $("ul.month .week").fadeOut("fast", function () {
        $('ul.month').addClass("monthListView");
            $(this).fadeIn("fast");
        });
        return false;
    });

    $('ul.day').click(function () {
        var dump = $(this).html();
        $('.enlargeData ul').html(dump);
        $('.coverSheet').fadeIn();
        $('.enlargeData').fadeIn();
        return false;
    });

    $('.closeOverlay').click(function () {
        clearOverlay();
        return false;
    });

    function clearOverlay() {
        $('.enlargeData ul').html();
        $('.enlargeData').hide();
        $('.coverSheet').hide();
    }

    $('ul.day:even').addClass('dayAlt');

});
