(function (j) {
    function X(L, C) {
        function z() {
            h.settings.shuffle && v.sort(function () { return 0.5 - Math.random() });
            h.settings.navigationArrows && Y();
            h.settings.navigationButtons && Z();
            h.settings.slideshowControls && $();

            if (h.settings.slidesPreloaded) {
                S();

                for (var a = 0, c = h.settings.slidesPreloaded == -1 ? v.length : h.settings.slidesPreloaded, e = 0; e < c; e++)
                    j("<img/>").load(function () {
                        a++;
                        if (a == c) {
                            T();
                            D(h.settings.slideStart)
                        }
                    }).attr("src", v[e].path)
            }
            else
                D(h.settings.slideStart)
        } 
        
        function Y() {
            var a = h.settings.hideNavigationArrows == true ? 0 : 1, c = j('<div class="arrow-navigation"></div>').appendTo(r);
            j('<a class="left-arrow"></a>').css("opacity", a).mouseover(function () {j(this).stop().css("opacity", 1)}).click(function () { M() }).appendTo(c); 
            j('<a class="right-arrow"></a>').css("opacity", a).mouseover(function () { j(this).stop().css("opacity", 1) }).click(function () { N() }).appendTo(c)
        } 
        
        function $() {
            var a = j('<div class="slideshow-controls"></div>').appendTo(r);
            currentClass = h.settings.slideshow ? "slideshow-pause" : "slideshow-play";

            a.addClass(currentClass).css("opacity", 0).mouseover(function () {
                j(this).stop().css("opacity", 1)
            }).click(function () {
                if (j(this).hasClass("slideshow-pause")) {
                    j(this).removeClass("slideshow-pause").addClass("slideshow-play");
                    E = "pause"; O()
                }
                else if (j(this).hasClass("slideshow-play")) {
                    if (!h.settings.slideshow)
                        h.settings.slideshow = true;
                    j(this).removeClass("slideshow-play").addClass("slideshow-pause");
                    E = "play";
                    P()
                } 
            })
        } 
        
        function Z() {
            for (var a = v.length, c = j('<div class="buttons-navigation"></div>').appendTo(r), e = 0; e < a; e++)
                j('<a rel="' + e + '"></a>').appendTo(c).bind({ 
                    mouseover: function () {
                        var f = j(this).attr("rel");
                        j(this).hasClass("select") || j(this).addClass("over"); 
                        h.settings.showThumbnails && aa(f)
                    }, mouseout: function () {
                        j(this).hasClass("select") || j(this).removeClass("over");
                        h.settings.showThumbnails && ba()
                    }, click: function () {
                        A || D(parseInt(j(this).attr("rel"))) 
                    }
                });

            if (h.settings.navigationButtonsCenter) {
                a = (h.settings.width - c.outerWidth()) / 2; c.css("left", a) 
            }
        } 
        
        function aa(a) {
            if (v[a].thumbnail) {
                var c = r.find(".buttons-navigation a").eq(a),
                    e = v[a].thumbnail,
                    f = j('<div class="thumbnail"></div>').appendTo(r.find(".buttons-navigation"));

                a = parseInt(c.position().left) - (parseInt(f.outerWidth(true)) - parseInt(c.css("width"))) / 2;
                c = parseInt(c.position().top) - parseInt(f.outerHeight(true));
                f.css({ left: a, top: c - h.settings.thumbnailSlide, opacity: 0 });
                j("<img/>").load(function () { f.css("background-image", "url(" + e + ")") }).attr("src", e); 
                f.animate({ top: c, opacity: 1 }, h.settings.thumbnailDuration)
            }
        } 
        
        function ba() {
            var a = r.find(".buttons-navigation .thumbnail"); 
            a && a.animate({ top: parseInt(a.css("top")) - h.settings.thumbnailSlide, opacity: 0 }, h.settings.thumbnailDuration,function () { a.remove() })
        }

        function D(a) {
            if (!A) {
                h.settings.slideshow && O();
                A = true;
                F = w;
                w = a;
                var c = v[w];
                S();

                j("<img/>").load(function () {
                    c.width = j(this).attr("width");
                    c.height = j(this).attr("height");
                    T();
                    ca()
                }).attr("src", c.path);

                if (h.settings.navigationButtons) {
                    var e = r.find(".buttons-navigation");
                    e.find(".select").attr("class", "out");
                    e.find("a").eq(a).attr("class", "select")
                }

                a = { type: "slideOpen", index: w, data: v[w] };
                j.isFunction(h.settings.slideOpen) && h.settings.slideOpen.call(this, a)
            }
        } 
        
        function N() {
            A || D(w == v.length - 1 ? 0 : w + 1)
        }

        function M() {
            A || D(w == 0 ? v.length - 1 : w - 1)
        }

        function S() {
            var a = j('<div class="preloader"></div>').hide().fadeIn(300).appendTo(r),
                c = (h.settings.width - parseInt(a.css("width"))) * 0.5,
                e = (h.settings.height - parseInt(a.css("height"))) * 0.5;

            a.css({ left: c, top: e })
        }

        function T() {
            r.find(".preloader").remove()
        } 
        
        function ca() {
            var a = v[w]; 

            if (F != -1) {
                var c = r.find(".slide").css("z-index");
                I = r.find(".slide").css("z-index", c - 1);
                c = v[F].width;
                var e = v[F].height, f = a.width, g = a.height;

                if (f < h.settings.width && f < c || g < h.settings.height && g < e) 
                    I.fadeOut(300); v[F].caption && da()
            }

            B = j('<div class="slide"></div>').appendTo(r);

            B.bind({
                mouseover: function () {
                    h.settings.hideNavigationArrows && r.find(".arrow-navigation a").stop().animate({ opacity: 1 }, 500);
                    h.settings.slideshowControls && r.find(".slideshow-controls").stop().animate({ opacity: 1 }, 500);

                    if (h.settings.timerAnimation && h.settings.hideTimer && !A) {
                        var y = r.find("#timer-animation");
                        j.browser.msie ? y.css("filter", "") : y.stop().animate({ opacity: 1 }, h.settings.timerFadeDuration)
                    } 

                    y = { type: "slideMouseOver", index: w, data: a}; 
                    j.isFunction(h.settings.slideMouseOver) && h.settings.slideMouseOver.call(this, y)
                }, mouseout: function () {
                    h.settings.hideNavigationArrows && r.find(".arrow-navigation a").stop().animate({ opacity: 0 }, 500);
                    h.settings.slideshowControls && r.find(".slideshow-controls").stop().animate({ opacity: 0 }, 500);

                    if (h.settings.timerAnimation && h.settings.hideTimer && !A) {
                        var y = r.find("#timer-animation");
                        j.browser.msie ? y.css("opacity", 0) : y.stop().animate({ opacity: 0 }, h.settings.timerFadeDuration)
                    }

                    y = { type: "slideMouseOut", index: w, data: a }; 
                    j.isFunction(h.settings.slideMouseOut) && h.settings.slideMouseOut.call(this, y)
                }, click: function () {
                    var y = { type: "slideClick", index: w, data: a };
                    j.isFunction(h.settings.slideClick) && h.settings.slideClick.call(this, y) 
                }
            });

            var b = a.properties, d = b.alignType, i = parseInt(b.horizontalSlices), u = parseInt(b.verticalSlices), p = b.slicePattern; c = b.effectType;
            e = b.slicePoint;
            f = b.slideStartPosition;
            g = parseFloat(b.slideStartRatio);
            var n = parseInt(b.sliceDuration),
                o = parseInt(b.sliceDelay),
                l = b.sliceFade == true ? 0 : 1,
                m = Math.floor(Math.min(a.width, h.settings.width) / i),
                q = Math.floor(Math.min(a.height, h.settings.height) / u),
                s = a.width > h.settings.width ? U(d, a.width, h.settings.width) : 0;

            d = a.height > h.settings.height ? V(d, a.height, h.settings.height) : 0;
            var t = a.width < h.settings.width ? Math.floor((h.settings.width - a.width) / 2) : 0,
                x = a.height < h.settings.height ? Math.floor((h.settings.height - a.height) / 2) : 0, 
                W = [];
            b.slideMask && B.css("overflow", "hidden");

            for (b = 0; b < i; b++) 
                for (var H = 0; H < u; H++) {
                    var ea = j('<div class="slice"></div>').css({ "background-image": "url(" + a.path + ")", "background-position": -(b * m + s) + "px " + -(H * q + d) + "px", "background-repeat": "no-repeat", left: b * m + t, top: H * q + x, width: m, height: q, opacity: l
                        }).data({ hPos: b, vPos: H }).appendTo(B); W.push(ea)
                }

                if (c == "random")
                    c = J(["scale", "width", "height", "slide", "fade"]);
                if (p == "random")
                    p = J(["randomPattern", "topToBottom", "bottomToTop", "leftToRight", "rightToLeft", "topLeftToBottomRight", "topRightToBottomLeft", "bottomLeftToTopRight", "bottomRightToTopLeft", "horizontalMarginToCenter", "horizontalCenterToMargin", "marginToCenter", "verticalCenterToMargin", "skipOneTopToBottom", "skipOneBottomToTop", "skipOneLeftToRight", "skipOneRightToLeft", "skipOneHorizontal", "skipOneVertical", "spiralMarginToCenterCW", "spiralMarginToCenterCCW", "spiralCenterToMarginCW", "spiralCenterToMarginCCW"]);
                if (e == "random")
                    e = J(["leftTop", "leftCenter", "leftBottom", "centerTop", "centerCenter", "centerBottom", "rightTop", "rightCenter", "rightBottom"]);
                if (f == "random") 
                    f = J(["left", "right", "top", "bottom", "leftTop", "rightTop", "leftBottom", "horizontalAlternative", "verticalAlternative"]);
                
                i = fa(W, p, i, u);
                u = i.length;
                
                for (b = 0; b < u; b++)
                    ga(i[b], b, u, c, e, f, g, n, o);
                
                c = { type: "transitionStart", index: w, data: a }; 
                j.isFunction(h.settings.transitionStart) && h.settings.transitionStart.call(this, c)
        } 
        
        function ha() {
            var a = v[w], c = a.properties.alignType, e = U(c, a.width, h.settings.width);
            c = V(c, a.height, h.settings.height);
            A = false;
            B.find(".slice").remove();
            B.css({ "background-image": "url(" + a.path + ")", "background-position": -e + "px " + -c + "px", "background-repeat": "no-repeat" }); 
            
            if (a.link) {
                B.css("cursor", "pointer"); 
                B.click(function () {
                    window.open(a.link, a.properties.linkTarget)
                })
            }
            
            I && I.remove();
            h.settings.slideshow && E != "pause" && P();
            a.caption && ia();
            e = { type: "transitionComplete", index: w, data: a }; 
            j.isFunction(h.settings.transitionComplete) && h.settings.transitionComplete.call(this, e)
        }

        function J(a) {
            return a[Math.floor(Math.random() * a.length)]
        } 
        
        function ia() {
            var a = v[w],
                c = a.properties,
                e = c.captionPosition,
                f = parseInt(c.captionSize),
                g = parseInt(c.captionWidth),
                b = parseInt(c.captionHeight),
                d = parseInt(c.captionLeft),
                i = parseInt(c.captionTop), 
                u = c.captionShowEffect,
                p = parseInt(c.captionShowEffectDuration);

            c = c.captionShowSlideDirection;
            var n = Math.min(a.width, h.settings.width), o = Math.min(a.height, h.settings.height);
            g = e == "custom" ? g : n;
            b = e == "custom" ? b : o;
            d = e == "custom" ? d : (h.settings.width - g) / 2;
            i = e == "custom" ? i : (h.settings.height - b) / 2;
            o = j('<div class="caption-container"></div>').appendTo(r);
            n = j('<div class="caption-wrapper"></div>').appendTo(o);
            var l = j('<div class="caption-background"></div>').css("opacity", h.settings.captionBackgroundOpacity).appendTo(n); 
            a = j('<div class="caption-content"></div>').html(a.caption).appendTo(n);
            var m = u == "fade" ? 0 : f; 

            switch (e) {
                case "left": 
                    o.css({ width: f, height: b, left: d, top: i });
                    c == "auto" && n.css({ width: f, height: b, left: -m, top: 0 });
                    break;
                case "right":
                    o.css({ width: f, height: b, right: d, top: i });
                    c == "auto" && n.css({ width: f, height: b, left: m, top: 0 });
                    break;
                case "top":
                    o.css({ width: g, height: f, left: d, top: i });
                    c == "auto" && n.css({ width: g, height: f, left: 0, top: -m });
                    break;
                case "bottom":
                    o.css({ width: g, height: f, left: d, bottom: i });
                    c == "auto" && n.css({ width: g, height: f, left: 0, top: m });
                    break;
                case "custom":
                    o.css({ width: g, height: b, left: d, top: i });
                    n.css({ width: g, height: b, left: 0, top: 0 });
                    break;
                case "default":
                    o.css({ width: g, height: f, left: d, bottom: i }); 
                    c == "auto" && n.css({ width: g, height: f, left: 0, top: m })
            }

            if (u == "fade")
                if (j.browser.msie) {
                    a.css({ opacity: 0 });
                    a.animate({ opacity: 1 }, p);
                    l.css({ opacity: 0 });
                    l.animate({ opacity: h.settings.captionBackgroundOpacity }, p)
                }
                else {
                    n.css({ opacity: 0 });
                    n.animate({ opacity: 1 }, p)
                } 
            else {
                e == "custom" && o.css({ width: g, height: b, left: d, top: i });
                if (c == "topToBottom")
                    n.css({ width: g, height: b, left: 0, top: -b });
                else if (c == "bottomToTop")
                    n.css({ width: g, height: b, left: 0, top: b });
                else if (c == "leftToRight")
                    n.css({ width: g, height: b, left: -g, top: 0 });
                else
                    c == "rightToLeft" && n.css({ width: g, height: b, left: g, top: 0 }); 
                n.animate({ top: 0, left: 0 }, p)
            }
        } 
        
        function da() {
            var a = r.find(".caption-container"),
                c = a.find(".caption-wrapper"),
                e = v[F].properties,
                f = e.captionPosition,
                g = e.captionHideEffect,
                b = parseInt(e.captionHideEffectDuration);

            e = e.captionHideSlideDirection;

            if (g == "fade")
                a.animate({ opacity: 0 }, b, function () {a.remove()});
            else if (e == "topToBottom")
                c.animate({ top: parseInt(c.css("height")) }, b, function () { a.remove() });
            else if (e == "bottomToTop")
                c.animate({ top: -parseInt(c.css("height")) }, b, function () { a.remove() });
            else if (e == "leftToRight")
                c.animate({ left: parseInt(c.css("width")) }, b, function () { a.remove() });
            else if (e == "rightToLeft")
                c.animate({ left: -parseInt(c.css("width")) }, b, function () { a.remove() });
            else if (e == "auto") 
                switch (f) {
                    case "left":
                        c.animate({ left: -parseInt(c.css("width")) }, b, function () { a.remove() });
                        break;
                    case "right": 
                        c.animate({ left: parseInt(c.css("width")) }, b, function () { a.remove() });
                        break;
                    case "top":
                        c.animate({ top: -parseInt(c.css("height")) }, b, function () { a.remove() });
                        break;
                    case "bottom":
                        c.animate({ top: parseInt(c.css("height")) }, b, function () { a.remove() });
                        break;
                    case "custom":
                        c.animate({ top: parseInt(c.css("height")) }, b, function () { a.remove() });
                        break;
                    case "default": 
                        c.animate({ top: parseInt(c.css("height")) }, b, function () { a.remove() })
            }
        } 
        
        function P() {
            var a = v[w].properties.slideshowDelay || h.settings.slideshowDelay; h.settings.timerAnimation && ja(a); Q = setTimeout(function () {
                if (h.settings.slideshowDirection == "next")
                    N();
                else
                    h.settings.slideshowDirection == "previous" && M()
            }, a)
        }

        function O() {
            Q && clearTimeout(Q);
            h.settings.timerAnimation && ka()
        } 
        
        function ja(a) {
            var c = document.createElement("canvas"),
                e = Math.max(h.settings.timerStrokeWidth1, h.settings.timerStrokeWidth2) + h.settings.timerRadius * 2,
                f = e / 2,
                g = Math.PI / 180,
                b = 0,
                d = (new Date).getTime(),
                i,
                u,
                p = h.settings.timerStrokeOpacity1,
                n = h.settings.timerStrokeOpacity2,
                o = G(h.settings.timerStrokeColor1).red,
                l = G(h.settings.timerStrokeColor1).green, 
                m = G(h.settings.timerStrokeColor1).blue,
                q = G(h.settings.timerStrokeColor2).red,
                s = G(h.settings.timerStrokeColor2).green,
                t = G(h.settings.timerStrokeColor2).blue;

            c.width = c.height = e;
            j(c).attr("id", "timer-animation").appendTo(r);

            if (h.settings.hideTimer)
                j(c).css({ opacity: 0 });
            else
                j.browser.msie || j(c).css({ opacity: 0 }).stop().animate({ opacity: 1 }, h.settings.timerFadeDuration);
            if (j.browser.msie)
                c = G_vmlCanvasManager.initElement(c);
            var x = c.getContext("2d"); 
            
            R = setInterval(function () {
                if (b <= 360) {
                    i = (new Date).getTime();
                    u = i - d;
                    b = u / a * 360 + 1;
                    if (b > 360)
                        b = 360;
                    c.width = c.width;
                    x.beginPath();
                    x.lineWidth = h.settings.timerStrokeWidth1;
                    x.strokeStyle = "rgba(" + o + ", " + l + ", " + m + ", " + p + ")";
                    x.arc(f, f, h.settings.timerRadius, 0, 2 * Math.PI, false);
                    x.stroke();
                    x.beginPath();
                    x.lineWidth = h.settings.timerStrokeWidth2;
                    x.strokeStyle = "rgba(" + q + ", " + s + ", " + t + ", " + n + ")";
                    x.arc(f, f, h.settings.timerRadius, 0, b * g, false); 
                    x.stroke()
                } 
            }, 20)
        }

        function ka() {
            R && clearInterval(R);
            var a = r.find("#timer-animation");

            if (a)
                j.browser.msie ? a.remove() : a.stop().animate({ opacity: 0 }, h.settings.timerFadeDuration, function () { a.remove() }) 
        }

        function U(a, c, e) {
            var f = 0;

            if (a == "centerTop" || a == "centerCenter" || a == "centerBottom")
                f = Math.floor((c - e) / 2);
            else if (a == "rightTop" || a == "rightCenter" || a == "rightBottom")
                f = c - e;
            return f
        }

        function V(a, c, e) {
            var f = 0;

            if (a == "leftCenter" || a == "centerCenter" || a == "rightCenter")
                f = Math.floor((c - e) / 2);
            else if (a == "leftBottom" || a == "centerBottom" || a == "rightBottom")
                f = c - e;
            return f
        } 
        
        function ga(a, c, e, f, g, b, d, i, u) {
            var p = {},
                n = {},
                o = parseInt(a.css("width")),
                l = parseInt(a.css("height")),
                m = parseInt(a.css("left")), 
                q = parseInt(a.css("top")),
                s,
                t;

            if (f == "scale" || f == "width" || f == "height")
                switch (g) {
                    case "centerCenter":
                        t = q + l * 0.5;
                        s = m + o * 0.5;
                        break;
                    case "rightCenter":
                        t = q + l * 0.5;
                        s = m + o;
                        break;
                    case "leftCenter":
                        t = q + l * 0.5;
                        s = m;
                        break;
                    case "centerTop":
                        t = q;
                        s = m + o * 0.5;
                        break;
                    case "rightTop":
                        t = q;
                        s = m + o;
                        break;
                    case "leftTop":
                        t = q;
                        s = m;
                        break;
                    case "centerBottom":
                        t = q + l;
                        s = m + o * 0.5;
                        break;
                    case "rightBottom":
                        t = q + l;
                        s = m + o;
                        break;
                    case "leftBottom":
                        t = q + l;
                        s = m;
                        break;
                    default:
                        t = q + l * 0.5;
                        s = m + o * 0.5
                }
            else if (f == "slide") 
                switch (b) {
                    case "left":
                        t = q;
                        s = m - o * d;
                        break;
                    case "right":
                        t = q; 
                        s = m + o * d;
                        break;
                    case "top":
                        t = q - l * d;
                        s = m;
                        break;
                    case "bottom":
                        t = q + l * d;
                        s = m;
                        break;
                    case "leftTop":
                        t = q - l * d;
                        s = m - o * d;
                        break;
                    case "rightTop":
                        t = q - l * d;
                        s = m + o * d;
                        break;
                    case "leftBottom":
                        t = q + l * d;
                        s = m - o * d;
                        break;
                    case "rightBottom":
                        t = q + l * d;
                        s = m + o * d;
                        break;
                    case "horizontalAlternative":
                        t = q;
                        s = m + o * d * (c % 2 == 0 ? 1 : -1);
                        break;
                    case "verticalAlternative":
                        t = q + l * d * (c % 2 == 0 ? 1 : -1);
                        s = m;
                        break;
                    default:
                        t = q; 
                        s = m - o * d
                } 
            switch (f) {
                case "fade":
                    n = { opacity: 1 };
                    break;
                case "scale":
                    p = { width: 0, height: 0, left: s, top: t };
                    n = { width: o, height: l, left: m, top: q, opacity: 1 }; 
                    break;
                case "width":
                    p = { width: 0, left: s };
                    n = { width: o, left: m, opacity: 1 };
                    break;
                case "height":
                    p = { height: 0, top: t };
                    n = { height: l, top: q, opacity: 1 };
                    break;
                case "slide":
                    p = { left: s, top: t };
                    n = { left: m, top: q, opacity: 1 };
                    break;
                default: 
                    n = { opacity: 1}
            }

            a.css(p); 
            setTimeout(function () { a.animate(n, i, function () { c == e - 1 && ha() }) }, c * u)
        } 
        
        function fa(a, c, e, f) {
            var g = [], b, d, i = 0; 
            
            switch (c) {
                case "randomPattern":
                    for (e = []; a.length; ) {
                        i = Math.floor(Math.random() * a.length);
                        e.push(a[i]);
                        a.splice(i, 1)
                    }
                    var u = e.length;
                    for (c = 0; c < u; c++)
                        g[c] = e[c];
                    break;
                case "topToBottom":
                    for (d = 0; d < f; d++)
                        for (b = 0; b < e; b++)
                            g.push(k(a, b, d));
                    break;
                case "bottomToTop":
                    for (d = f - 1; d >= 0; d--)
                        for (b = e - 1; b >= 0; b--)
                            g.push(k(a, b, d));
                    break;
                case "rightToLeft":
                    for (b = e - 1; b >= 0; b--)
                        for (d = f - 1; d >= 0; d--)
                            g.push(k(a, b, d));
                    break;
                case "leftToRight":
                    for (b = 0; b < e; b++)
                        for (d = 0; d < f; d++)
                            g.push(k(a, b, d));
                    break;
                case "topLeftToBottomRight":
                    for (c = 0; c < e + f - 1; c++) {
                        d = 0;
                        for (b = c; b >= 0; b--) {
                            k(a, b, d) != undefined && g.push(k(a, b, d));
                            d++
                        }
                    }
                    break;
                case "bottomLeftToTopRight":
                    i = e > f ? e : f; 
                    for (c = e - 1; c >= 1 - i; c--) {
                        b = 0; 
                        for (d = c; d <= e - 1; d++) {
                            k(a, b, d) != undefined && g.push(k(a, b, d)); 
                            b++
                        }
                    }
                    break;
                case "topRightToBottomLeft":
                    i = e > f ? e : f;
                    for (c = e - 1; c >= 1 - i; c--) {
                        b = c;
                        for (d = 0; d <= f - 1; d++) {
                            k(a, b, d) != undefined && g.push(k(a, b, d));
                            b++
                        }
                    }
                    break;
                case "bottomRightToTopLeft":
                    for (c = f + e - 2; c >= 0; c--) {
                        d = 0;
                        for (b = c; b >= 0; b--) {
                            k(a, b, d) != undefined && g.push(k(a, b, d));
                            d++
                        }
                    }
                    break;
                case "horizontalMarginToCenter":
                    if (e % 2) {
                        for (b = 0; b < Math.floor(e / 2); b++)
                            for (d = 0; d < f; d++) {
                                g.push(k(a, b, d));
                                g.push(k(a, e - 1 - b, d))
                            }
                            for (c = 0; c < f; c++)
                                g.push(k(a, Math.floor(e / 2), c))
                    }
                    else
                        for (b = 0; b < Math.floor(e / 2); b++) 
                    for (d = 0; d < f; d++) {
                        g.push(k(a, b, d)); 
                        g.push(k(a, e - 1 - b, d))
                    }
                    break;
                case "horizontalCenterToMargin":
                    if (e % 2)
                        for (c = 0; c < f; c++)
                            g.push(k(a, Math.floor(e / 2), c));
                    for (b = Math.floor(e / 2) - 1; b >= 0; b--)
                        for (d = 0; d < f; d++) {
                            g.push(k(a, b, d));
                            g.push(k(a, e - 1 - b, d))
                        }
                    break;
                case "verticalMarginToCenter":
                    if (f % 2) {
                        for (d = 0; d < Math.floor(f / 2); d++)
                            for (b = 0; b < e; b++) {
                                g.push(k(a, b, d));
                                g.push(k(a, b, f - 1 - d))
                            }
                        for (c = 0; c < e; c++)
                            g.push(k(a, c, Math.floor(f / 2)))
                    }
                    else
                        for (d = 0; d < Math.floor(f / 2); d++)
                            for (b = 0; b < e; b++) {
                                g.push(k(a, b, d));
                                g.push(k(a, b, f - 1 - d))
                            }
                    break;
                case "verticalCenterToMargin":
                    if (f % 2)
                        for (c = 0; c < e; c++)
                            g.push(k(a, c, Math.floor(f / 2)));
                    for (d = Math.floor(f / 2) - 1; d >= 0; d--)
                        for (b = 0; b < e; b++) {
                            g.push(k(a, b, d));
                            g.push(k(a, b, f - 1 - d))
                        }
                    break;
                case "skipOneTopToBottom":
                    for (d = 0; d < f; d++) {
                        for (b = i; b < e; b += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    i = 1;
                    for (d = 0; d < f; d++) {
                        for (b = i; b < e; b += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    break;
                case "skipOneBottomToTop":
                    for (d = f - 1; d >= 0; d--) {
                        for (b = i; b < e; b += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    i = 1;
                    for (d = f - 1; d >= 0; d--) {
                        for (b = i; b < e; b += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    break;
                case "skipOneLeftToRight":
                    for (b = 0; b < e; b++) {
                        for (d = i; d < f; d += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    i = 1;
                    for (b = 0; b < e; b++) {
                        for (d = i; d < f; d += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    break;
                case "skipOneRightToLeft":
                    for (b = e - 1; b >= 0; b--) {
                        for (d = i; d < f; d += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    i = 1;
                    for (b = e - 1; b >= 0; b--) {
                        for (d = i; d < f; d += 2)
                            g.push(k(a, b, d));
                        i == 0 ? i = 1 : i = 0
                    }
                    break;
                case "skipOneVertical":
                    if (f % 2) 
                        for (d = 0; d < f; d++) {
                            for (b = i; b < e; b += 2) {
                                if (d == Math.floor(f / 2)) {
                                    d++; 
                                    for (c = 1 - e % 2; c < e; c += 2) {
                                        g.push(k(a, c, Math.floor(f / 2))); 
                                        k(a, c - 1, Math.floor(f / 2)) != undefined && g.push(k(a, c - 1, Math.floor(f / 2)))
                                    }
                                }
                                g.push(k(a, b, d)); 
                                g.push(k(a, b, f - d - 1))
                            } 
                            i == 0 ? i = 1 : i = 0
                        }
                    else
                        for (d = 0; d < f; d++) {
                            for (b = i; b < e; b += 2) {
                                g.push(k(a, b, d));
                                g.push(k(a, b, f - d - 1))
                            }
                            i == 0 ? i = 1 : i = 0
                        }
                    break;
                case "skipOneHorizontal":
                    if (e % 2)
                        for (b = 0; b < e; b++) {
                            for (d = i; d < f; d += 2) {
                                if (b == Math.floor(e / 2)) {
                                    b++;
                                    for (c = 1 - f % 2; c < f; c += 2) {
                                        g.push(k(a, Math.floor(e / 2), c));
                                        k(a, Math.floor(e / 2), c - 1) != undefined && g.push(k(a, Math.floor(e / 2), c - 1))
                                    }
                                }
                                g.push(k(a, b, d));
                                g.push(k(a, e - 1 - b, d))
                            }
                            i == 0 ? i = 1 : i = 0
                        }
                    else 
                        for (b = 0; b < e; b++) {
                            for (d = i; d < f; d += 2) {
                                g.push(k(a, b, d));
                                g.push(k(a, e - 1 - b, d))
                            } 
                            i == 0 ? i = 1 : i = 0
                        }
                    break;
                case "spiralMarginToCenterCW":
                    var p = e,
                    n = f,
                    o,
                    l = 0,
                    m = f < e ? f : e;

                    u = Math.floor(m / 2);
                    for (o = 0; o < u; o++) {
                        for (b = l++; b < p; b++)
                            g.push(k(a, b, l - 1));
                        p--;
                        for (d = l; d < n; d++)
                            g.push(k(a, e - l, d));
                        n--;
                        for (c = p; c >= e - p; c--)
                            g.push(k(a, c - 1, n));
                        for (i = n - 1; i >= f - n; i--)
                            g.push(k(a, l - 1, i))
                    }
                    if (m % 2) {
                        if (m == f)
                            for (b = l++; b < p; b++)
                                g.push(k(a, b, l - 1));
                        if (m == e)
                            for (d = l++; d < n; d++)
                                g.push(k(a, e - l, d))
                    }
                    break;
                case "spiralMarginToCenterCCW":
                    p = e;
                    n = f;
                    l = 0;
                    m = f < e ? f : e;
                    u = Math.floor(m / 2); 
                    
                    for (o = 0; o < u; o++) {
                        for (d = l++; d < n; d++)
                            g.push(k(a, l - 1, d));
                        n--;
                        for (b = l; b < p; b++)
                            g.push(k(a, b, f - l));
                        p--;
                        for (c = n; c >= f - n; c--)
                            g.push(k(a, p, c - 1));
                        for (i = p - 1; i >= e - p; i--) 
                            g.push(k(a, i, l - 1))
                    }
                    if (m % 2) {
                        if (m == f)
                            for (b = l++; b < p; b++)
                                g.push(k(a, b, f - l));
                        if (m == e)
                            for (d = l++; d < n; d++)
                                g.push(k(a, l - 1, d))
                    }
                    break;
                case "spiralCenterToMarginCCW":
                    p = e;
                    n = f;
                    l = 0;
                    m = f < e ? f : e;
                    u = Math.floor(m / 2);

                    for (o = 0; o < u; o++) {
                        for (b = l++; b < p; b++)
                            g.push(k(a, b, l - 1));
                        p--;
                        for (d = l; d < n; d++)
                            g.push(k(a, e - l, d));
                        n--;
                        for (c = p; c >= e - p; c--)
                            g.push(k(a, c - 1, n));
                        for (i = n - 1; i >= f - n; i--)
                            g.push(k(a, l - 1, i))
                    } 
                    if (m % 2) {
                        if (m == f)
                            for (b = l++; b < p; b++)
                                g.push(k(a, b, l - 1));
                        if (m == e)
                            for (d = l++; d < n; d++) 
                                g.push(k(a, e - l, d))
                    }
                    g.reverse();
                    break;
                case "spiralCenterToMarginCW":
                    p = e;
                    n = f;
                    l = 0;
                    m = f < e ? f : e;
                    u = Math.floor(m / 2);
                    
                    for (o = 0; o < u; o++) {
                        for (d = l++; d < n; d++)
                            g.push(k(a, l - 1, d));
                        n--;
                        for (b = l; b < p; b++)
                            g.push(k(a, b, f - l));
                        p--;
                        for (c = n; c >= f - n; c--)
                            g.push(k(a, p, c - 1));
                        for (i = p - 1; i >= e - p; i--)
                            g.push(k(a, i, l - 1))
                    }
                    if (m % 2) {
                        if (m == f)
                            for (b = l++; b < p; b++)
                                g.push(k(a, b, f - l));
                        if (m == e)
                            for (d = l++; d < n; d++)
                                g.push(k(a, l - 1, d))
                    }
                    g.reverse();
                    break;
                default: 
                    for (e = []; a.length; ) {
                        i = Math.floor(Math.random() * a.length); e.push(a[i]);
                        a.splice(i, 1)
                    } 
                    u = e.length; for (c = 0; c < u; c++) g[c] = e[c]
            } 
            return g
        }

        function k(a, c, e) {
            return j.grep(a, function (f) {
                return f.data("hPos") == c && f.data("vPos") == e 
            })[0]
        }

        function G(a) {
            var c = parseInt(a.substring(1, 3), 16),
                e = parseInt(a.substring(3, 5), 16);
                a = parseInt(a.substring(5, 7), 16);

                return { red: c, green: e, blue: a }
        }

        var r = j(L),
            h = this,
            w = -1,
            F = -1,
            v = [],
            B = null,
            I = null,
            A = false,
            Q = 0,
            R = 0,
            E = "", 
            K = ["alignType", "effectType", "sliceDelay", "sliceDuration", "horizontalSlices", "verticalSlices", "slicePattern", "slicePoint", "slideStartPosition", "slideStartRatio", "sliceFade", "captionSize", "captionPosition", "captionShowEffectDuration", "captionHideEffectDuration", "captionShowEffect", "captionHideEffect", "captionLeft", "captionTop", "captionWidth", "captionHeight", "captionShowSlideDirection", "captionHideSlideDirection", "slideshowDelay", "slideMask", "linkTarget"];

        this.settings = j.extend({}, j.fn.advancedSlider.defaults, C); 
            
        (function () {
            r.addClass("advanced-slider").css({ width: h.settings.width, height: h.settings.height }); 
            
            if (h.settings.xmlSource) {
                r.empty();
                j.ajax({
                    type: "GET",
                    url: h.settings.xmlSource,
                    dataType: j.browser.msie ? "text" : "xml",

                    success: function (a) {
                        var c;
                        if (j.browser.msie) {
                            c = new ActiveXObject("Microsoft.XMLDOM");
                            c.async = false;
                            c.loadXML(a)
                        }
                        else
                            c = a;
                        j(c).find("slide").each(function () {
                            var e = {};
                            e.properties = {};
                            for (var f = 0; f < j(this).children().length; f++) {
                                var g = j(this).children()[f];
                                e[g.nodeName] = j(this).find(g.nodeName).text()
                            }
                            for (f = 0; f < K.length; f++) {
                                g = K[f];
                                var b = j(this).attr(g);
                                e.properties[g] = b == undefined ? h.settings[g] : b
                            }
                            v.push(e)
                        });
                        z()
                    } 
                })
            } 
            else {
                r.children().each(function (a) {
                    var c = {};
                    c.properties = {};

                    for (var e = 0; e < j(this).children().length; e++) {
                        var f = j(this).children()[e];
                        
                        if (j(f).is("a")) {
                            c.path = j(f).find("img").attr("src");
                            c.link = j(f).attr("href");
                            if (j(f).attr("target"))
                                c.properties.linkTarget = j(f).attr("target")
                        }
                        else if (j(f).is("img"))
                            if (j(f).hasClass("thumbnail"))
                                c.thumbnail = j(f).attr("src");
                            else
                                c.path = j(f).attr("src");
                        else
                            c[j(f).attr("class")] = j(f).html()
                    } 
                    for (e = 0; e < K.length; e++) {
                        f = K[e];
                        var g;
                        if (h.settings.slideProperties)
                            if (h.settings.slideProperties[a]) 
                                g = h.settings.slideProperties[a][f];
                                c.properties[f] || (c.properties[f] = g == undefined ? h.settings[f] : g)
                    } 
                    v.push(c)
                });
                r.empty(); 
                z()
            }
        })();

        this.nextSlide = N;
        this.previousSlide = M;
        this.gotoSlide = D;
        this.startSlideshow = function () {
            r.find(".slideshow-controls").removeClass("slideshow-play").addClass("slideshow-pause");
            E = "play";
            P()
        };
        this.stopSlideshow = function () {
            r.find(".slideshow-controls").removeClass("slideshow-pause").addClass("slideshow-play");
            E = "pause";
            O()
        };
        this.getSlideshowState = function () { return E }; 
        this.getCurrentIndex = function () { return w };
        this.getSlideAt = function (a) { return v[a] }; 
        this.isTransition = function () { return A }
    }

    j.fn.advancedSlider = function (L) {
        for (var C = [], z = 0; z < this.length; z++)
            if (!this[z].slider) {
                this[z].slider = new X(this[z], L);
                C.push(this[z].slider)
            }

        return C.length > 1 ? C : C[0] 
    };

    j.fn.advancedSlider.defaults = {
        xmlSource: null,
        width: 500,
        height: 300,
        alignType: "leftTop",
        slideshow: true,
        slideshowDelay: 5E3,
        slideshowDirection: "next",
        slideshowControls: true,
        timerAnimation: true,
        timerFadeDuration: 500,
        hideTimer: false,
        timerRadius: 18, 
        timerStrokeColor1: "#000000",
        timerStrokeColor2: "#FFFFFF",
        timerStrokeOpacity1: 0.5,
        timerStrokeOpacity2: 0.7,
        timerStrokeWidth1: 8,
        timerStrokeWidth2: 4,
        slideStart: 0,
        slidesPreloaded: 0,
        shuffle: false,
        effectType: "random",
        sliceDelay: 50,
        sliceDuration: 1E3,
        horizontalSlices: 5,
        verticalSlices: 3,
        slicePattern: "random",
        slicePoint: "centerCenter",
        slideStartPosition: "left",
        slideStartRatio: 1,
        sliceFade: true,
        navigationArrows: true,
        hideNavigationArrows: true,
        navigationButtons: true,
        navigationButtonsCenter: true,
        showThumbnails: true,
        thumbnailSlide: 10, 
        thumbnailDuration: 300,
        captionSize: 70,
        captionBackgroundOpacity: 0.8,
        captionShowEffect: "slide",
        captionShowEffectDuration: 500,
        captionShowSlideDirection: "auto",
        captionHideEffect: "fade",
        captionHideEffectDuration: 300,
        captionHideSlideDirection: "auto",
        captionPosition: "bottom",
        captionLeft: 50,
        captionTop: 50,
        captionWidth: 300,
        captionHeight: 100,
        slideProperties: null,
        slideMask: false,
        linkTarget: "_blank",
        slideOpen: null,
        slideClick: null,
        slideMouseOver: null,
        slideMouseOut: null,
        transitionStart: null, 
        transitionComplete: null
    }
})(jQuery);

