jQuery(function($) {
    $("[scrollable]").css("-webkit-overflow-scrolling", "auto");
    setTimeout(function () {
        $("[scrollable]").css("-webkit-overflow-scrolling", "touch");
    }, 100);

    //--- Color theme stylesheet handling --------------------------------------
    // Click handler for stylesheet switching
    $("#color-theme-toggle").click(function(e) {
        e.preventDefault();
        var $body = $("body");
        $body.toggleClass("day night");
        var isNightThemeActive = $body.hasClass("night");
        var themeStyleName = isNightThemeActive ? 'night' : 'day';
        if (window.ThemeManager) {
            ThemeManager.setTheme(themeStyleName);
        }
        //Set a style cookie for next 7 days
        $.cookie('themeStyle', themeStyleName, {expires: 7, path: Application.contextPath() + '/'});
        // Trigger 'themeChanged' event ..
        $body.trigger('themeChanged', themeStyleName);
    });
    //--- end: Color theme stylesheet handling ---------------------------------

    // Attach tooltip to trigger fields
    if(!Modernizr.touch){
        $(".tooltip-trigger").tooltip();
    }
});