
$(document).ready(function () {
    /* Set Collapsible Footer */
    /*$('#footer').addClass('collapsed');
    $('.foot').html('<a id="show_footer">Quicklinks >></a>');
    $('#show_footer').click(function() {
    var txt = $(this).text();
    $(this).text(txt == "Quicklinks >>" ? "Hide Quicklinks" : "Quicklinks >>");
    toggleFooter();
    return false;
    });*/

    /* Prep Care Nav Slider */
    //$('#navigatorRibbon #nrLink1').addClass('selected');
    $('#cycle #prev').addClass('disabled');
    $('#cycle a.disabled').live('click', function () {
        return false;
    });

    /* Build the reflected carousel */
    $('#theNavigator').append('<div id="theReflection" class="slider"><div class="top_curve"></div><div class="carousel"><ul></ul></div></div>');
    $('#theNavigator li.slide').each(function () {
        img_src = $(this).find('img:first').attr('src');
        $('#theReflection ul').append('<li class="slide"><img src="' + img_src + '" /></li>');
    });

    /* Init both carousels */
    $('.carousel').jCarouselLite({
        btnGo: ['#nrLink1', '#nrLink2', '#nrLink3', '#nrLink4'], visible: 1, speed: 800, circular: false, btnNext: '#cycle #next', btnPrev: '#cycle #prev'
        //        beforeStart: function (a) {
        //            $('#navigatorRibbon a').removeClass('selected');
        //        },
        //        afterEnd: function (a) {
        //            selector = a.attr('class');
        //            selector = selector.replace(" slide", "")
        //            if (selector != '') {
        //                $('#' + selector).addClass('selected');
        //            }
        //        }
    });

    /* Create custom scrollers if content is longer than slide */
    $('#theNavigator .slideMsg').each(function () {
        $(this).jScroller();
    });

});

function showFooterLinks() {
    $('.footerwave').find('.main').animate({ left: 0 }, 600, function() {
        $('.footerwave').find('.locations').animate({ left: 0 }, 600);
    });
}
function toggleFooter() {
    if ($('.footerwave').is(':visible')) {
            $('.footerwave').find('.main, .locations').animate({ left: -1000 }, 600, function() {
                $('.footerwave').slideUp(450);
            });
    }
    else {
        $('.footerwave').slideDown(450, function() {
            var bottom = $('#page').height();
            $('html, body').animate({ scrollTop: bottom }, 600, function() {
                showFooterLinks();
            });
        });
    }
}

function setNav() {
    var navLinks = $('#navigatorRibbonWrap li');
    var numNavLinks = navLinks.length;
    navLinks.width(960 / numNavLinks);
}
