/* carousel lite */
// Rows modification: http://old.nabble.com/jcarousel-lite:-getting-it-to-work-with-a-gridded-li-display-td20198422s27240.html
(function ($) { $.fn.jCarouselLite = function (o) { o = $.extend({ btnPrev: null, btnNext: null, btnGo: null, mouseWheel: false, auto: null, speed: 200, easing: null, vertical: false, circular: true, visible: 3, start: 0, scroll: 1, rows: 1, beforeStart: null, afterEnd: null }, o || {}); return this.each(function () { var running = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width"; var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible; var rowCss = o.vertical ? "width" : "height"; if (o.circular) { ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone()); o.start += v; } var li = $("li", ul), itemLength = li.size(), curr = o.start; div.css("visibility", "visible"); li.css({ overflow: "hidden", float: o.vertical ? "none" : "left" }); ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" }); div.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" }); var liSize = o.vertical ? height(li) : width(li); var liRowSize = o.vertical ? width(li) : height(li); var ulSize = ((liSize * itemLength) / o.rows) + (liSize / 1.5); var divSize = liSize * v; var rowSize = liRowSize * o.rows; li.css({ width: li.width() }); ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize)); div.css(sizeCss, divSize + "px"); div.css(rowCss, rowSize + "px"); if (o.vertical && o.rows > 1) { ul.children().filter(function (index) { return ((index + 1) % o.rows > 0); }).css({ float: "left", width: "" }); } if (o.btnPrev) { $(o.btnPrev).click(function () { return go(curr - (o.scroll)); }); } if (o.btnNext) { $(o.btnNext).click(function () { return go(curr + (o.scroll)); }); } if (o.btnGo) { $.each(o.btnGo, function (i, val) { $(val).click(function () { return go(o.circular ? o.visible + i : i); }); }); } if (o.mouseWheel && div.mousewheel) { div.mousewheel(function (e, d) { return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll); }); } if (o.auto) { setInterval(function () { go(curr + o.scroll); }, o.auto + o.speed); } function vis() { return li.slice(curr).slice(0, v); } function go(to) { if (!running) { if (o.beforeStart) { o.beforeStart.call(this, vis()); } if (o.circular) { if (to <= o.start - v - 1) { ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px"); curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll; } else if (to >= itemLength - v + 1) { ul.css(animCss, -((v) * liSize) + "px"); curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll; } else { curr = to; } } else { if (to < 0 || to > ((itemLength - v) / o.rows)) { return; } else { curr = to; } } running = true; ul.animate(animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing, function () { if (o.afterEnd) { o.afterEnd.call(this, vis()); } running = false; }); if (!o.circular) { $(o.btnPrev + "," + o.btnNext).removeClass("disabled"); $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > ((itemLength - v) / o.rows) && o.btnNext) || []).addClass("disabled"); } } return false; } }); }; function css(el, prop) { return parseInt($.css(el[0], prop), 10) || 0; } function width(el) { return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight'); } function height(el) { return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom'); } })(jQuery);

/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
*       used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

jQuery(function ($) {
    if (jQuery("#carousel_holder").length > 0) {
        jQuery("#carousel_holder").jCarouselLite({ btnNext: "#carousel .next", btnPrev: "#carousel .prev", visible: 5, circular: true, speed: 400, scroll: 5});
    }
});

// toggle dark mode when clicking the selector
jQuery(function ($) {
    $("#varit").click(function () {
        $("body").toggleClass("dark");
        if ($("body").hasClass("dark")) {
            $.cookie("colors", "dark", { expires: 365 });
        } else {
            $.cookie("colors", "light", { expires: 365 });
        }
    });
});
