$(document).ready(function () {
    $('#nav li').hover(function () {
        $(this).find('ul:first').css({ visibility: 'visible', display: 'none' }).show(400); // shows the tier when its parent is being hovered
    }, function () {
        $(this).find('ul:first').css({ visibility: 'hidden' }); // hides the tier when its parent is not being hovered
    });

    $('#nav>li>a').addClass('first-tier'); // adds the styles for the first tier on page load
    $('#nav>li>a').hover(function () {
        $(this).removeClass('first-tier').addClass('first-tier-hover'); // adds the hover for the first tier
    }, function () {
        $(this).removeClass('first-tier-hover').addClass('first-tier'); // removes the hover for the first tier
    });

    $('#nav>li>ul').hover(function () {
        $(this).parent().find('a').first().removeClass('first-tier').addClass('first-tier-hover'); // keeps the hover on the first tier if on second tier or higher
    }, function () {
        $(this).parent().find('a').first().removeClass('first-tier-hover').addClass('first-tier'); // removes the hover for the first tier
    });

    $('#nav>li>ul>li:nth-child(2) a').css('border-top', '0px')


    $('#lnav li').hover(function () {
        $(this).find('ul:first').css({ visibility: 'visible', display: 'none' }).show(400); // shows the tier when its parent is being hovered
    }, function () {
        $(this).find('ul:first').css({ visibility: 'hidden' }); // hides the tier when its parent is not being hovered
    });

    $('#lnav>li>a').addClass('first-tierl'); // adds the styles for the first tier on page load
    $('#lnav>li>a').hover(function () {
        $(this).removeClass('first-tierl').addClass('first-tier-hoverl'); // adds the hover for the first tier
    }, function () {
        $(this).removeClass('first-tier-hoverl').addClass('first-tierl'); // removes the hover for the first tier
    });

    $('#lnav>li>ul').hover(function () {
        $(this).parent().find('a').first().removeClass('first-tierl').addClass('first-tier-hoverl'); // keeps the hover on the first tier if on second tier or higher
    }, function () {
        $(this).parent().find('a').first().removeClass('first-tier-hoverl').addClass('first-tierl'); // removes the hover for the first tier
    });

    $('#lnav>li>ul>li a').first().css('border-top', '0px');
});

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function () {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function () {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });
};

jQuery(document).ready(function () {
    jQuery('#mycarousel').jcarousel({
        auto: 4,
        wrap: 'circular',
        scroll: 6,
        initCallback: mycarousel_initCallback
    });
});
