
(function ($) {

     function setFontSize(size) {
        if (typeof (size) === "undefined" || size == null) {
            // initialize with value from cookie, if any
            size = jQuery.cookie('lmst-size');
        }
        size = (size == null ? 1 : parseInt(size, 10));
                
        switch (size) {
            case 0:
                jQuery("body").css("font-size", "0.5em");                
                break;
            case 1:
                jQuery("body").css("font-size", "");
                break;
            case 2:
                jQuery("body").css("font-size", "0.89em");
                break;
        }

        jQuery.cookie('lmst-size', size, { path: '/' });
    };

    $(document).ready(function () {
        $('.top_navigation ul li ul li').each(function (idx, item) {
        });
        
		$(function () {

            $(".carousel").show();
            $(".docarousel").each(function () {
                $(this).jCarouselLite({
                    btnNext: ".carousel_next",
                    btnPrev: ".carousel_prev",
					scroll: 3,
                    visible: $(this).parents(".center").length ? 2 : 4 /* Only two items for carousels on subpages */
                });

            });            
        });

        $(".docarousel li").live("click", function() {
            var href = $(".header a", this).attr("href");
            if( href ) {
                document.location.href = href;
            }
        });


        //Font-size toggler
        setFontSize(null);
    
        $("#toolbar a.toggle-font-size").click(function(e) {                   
            setFontSize(1*$(this).attr("href").substr(1));
            e.preventDefault();
        });

        $(".faq-question").live("click", function() {
            $(this).parent().parent().next().slideToggle(300);
        });

        $("table.grid tbody tr, table.hover-table tr.body-row").live("mouseover", function(e) {
            $(this).addClass("hover");
        });

        $("table.grid tbody tr, table.hover-table tr.body-row").live("mouseout", function (e) {
            $(this).removeClass("hover");
        });
    });
})(jQuery);
