(function (k) {
    function T(K, C) {
        function x() {
            j.settings.shuffle && v.sort(function () {
                return 0.5 - Math.random()
            });
            j.settings.navigationArrows && U();
            j.settings.navigationButtons && V();
            j.settings.slideshowControls && W();
            if (j.settings.slidesPreloaded) {
                P();
                for (var a = 0, d = j.settings.slidesPreloaded == -1 ? v.length : j.settings.slidesPreloaded, e = 0; e < d; e++) k("<img/>").load(function () {
                    a++;
                    if (a == d) {
                        Q();
                        D(j.settings.slideStart)
                    }
                }).attr("src", v[e].path)
            } else D(j.settings.slideStart)
        }
        function U() {
            var a = k('<div class="arrow-navigation"></div>').appendTo(u);
            k('<a class="left-arrow"></a>').css("opacity", 0).mouseover(function () {
                k(this).stop().css("opacity", 1)
            }).click(function () {
                L()
            }).appendTo(a);
            k('<a class="right-arrow"></a>').css("opacity", 0).mouseover(function () {
                k(this).stop().css("opacity", 1)
            }).click(function () {
                M()
            }).appendTo(a)
        }
        function W() {
            var a = k('<div class="slideshow-controls"></div>').appendTo(u);
            currentClass = j.settings.slideshow ? "slideshow-pause" : "slideshow-play";
            a.addClass(currentClass).css("opacity", 0).mouseover(function () {
                k(this).stop().css("opacity", 1)
            }).click(function () {
                if (k(this).hasClass("slideshow-pause")) {
                    k(this).removeClass("slideshow-pause").addClass("slideshow-play");
                    E = "pause";
                    z && clearTimeout(z)
                } else if (k(this).hasClass("slideshow-play")) {
                    if (!j.settings.slideshow) j.settings.slideshow = true;
                    k(this).removeClass("slideshow-play").addClass("slideshow-pause");
                    E = "play";
                    N()
                }
            })
        }
        function V() {
            for (var a = v.length, d = k('<div class="buttons-navigation"></div>').appendTo(u), e = 0; e < a; e++) k('<a rel="' + e + '"></a>').appendTo(d).bind({
                mouseover: function () {
                    var f =
                    k(this).attr("rel");
                    k(this).hasClass("select") || k(this).addClass("over");
                    j.settings.showThumbnails && X(f)
                },
                mouseout: function () {
                    k(this).hasClass("select") || k(this).removeClass("over");
                    j.settings.showThumbnails && Y()
                },
                click: function () {
                    A || D(parseInt(k(this).attr("rel")))
                }
            });
            if (j.settings.navigationButtonsCenter) {
                a = (j.settings.width - d.outerWidth()) / 2;
                d.css("left", a)
            }
        }
        function X(a) {
            if (v[a].thumbnail) {
                var d = u.find(".buttons-navigation a").eq(a),
                    e = v[a].thumbnail,
                    f = k('<div class="thumbnail"></div>').appendTo(u.find(".buttons-navigation"));
                a = parseInt(d.position().left) - (parseInt(f.outerWidth(true)) - parseInt(d.css("width"))) / 2;
                d = parseInt(d.position().top) - parseInt(f.outerHeight(true));
                f.css({
                    left: a,
                    top: d - j.settings.thumbnailSlide,
                    opacity: 0
                });
                k("<img/>").load(function () {
                    f.css("background-image", "url(" + e + ")")
                }).attr("src", e);
                f.animate({
                    top: d,
                    opacity: 1
                }, j.settings.thumbnailDuration)
            }
        }
        function Y() {
            var a = u.find(".buttons-navigation .thumbnail");
            a && a.animate({
                top: parseInt(a.css("top")) - j.settings.thumbnailSlide,
                opacity: 0
            }, j.settings.thumbnailDuration, function () {
                a.remove()
            })
        }
        function D(a) {
            if (!A) {
                j.settings.slideshow && z && clearTimeout(z);
                A = true;
                O = w;
                w = a;
                var d = v[w];
                P();
                k("<img/>").load(function () {
                    d.width = k(this).attr("width");
                    d.height = k(this).attr("height");
                    Q();
                    Z()
                }).attr("src", d.path);
                if (j.settings.navigationButtons) {
                    var e = u.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]
                };
                k.isFunction(j.settings.slideOpen) && j.settings.slideOpen.call(this, a)
            }
        }
        function M() {
            A || D(w == v.length - 1 ? 0 : w + 1)
        }
        function L() {
            A || D(w == 0 ? v.length - 1 : w - 1)
        }
        function P() {
            var a = k('<div class="preloader"></div>').hide().fadeIn(300).appendTo(u),
                d = (j.settings.width - parseInt(a.css("width"))) * 0.5,
                e = (j.settings.height - parseInt(a.css("height"))) * 0.5;
            a.css({
                left: d,
                top: e
            })
        }
        function Q() {
            u.find(".preloader").remove()
        }
        function Z() {
            var a = v[w];
            if (u.find(".slide").length) {
                var d = u.find(".slide").css("z-index");
                H = u.find(".slide").css("z-index", d - 1);
                d = v[O].width;
                var e = v[O].height,
                    f = a.width,
                    g = a.height;
                if (f < j.settings.width && f < d || g < j.settings.height && g < e) H.fadeOut(300)
            }
            y = k('<div class="slide"></div>').appendTo(u);
            y.bind({
                mouseover: function () {
                    u.find(".arrow-navigation a").stop().animate({
                        opacity: 1
                    }, 500);
                    j.settings.slideshowControls && u.find(".slideshow-controls").stop().animate({
                        opacity: 1
                    }, 500);
                    var F = {
                        type: "slideMouseOver",
                        index: w,
                        data: a
                    };
                    k.isFunction(j.settings.slideMouseOver) && j.settings.slideMouseOver.call(this, F)
                },
                mouseout: function () {
                    u.find(".arrow-navigation a").stop().animate({
                        opacity: 0
                    }, 500);
                    j.settings.slideshowControls && u.find(".slideshow-controls").stop().animate({
                        opacity: 0
                    }, 500);
                    var F = {
                        type: "slideMouseOut",
                        index: w,
                        data: a
                    };
                    k.isFunction(j.settings.slideMouseOut) && j.settings.slideMouseOut.call(this, F)
                },
                click: function () {
                    var F = {
                        type: "slideClick",
                        index: w,
                        data: a
                    };
                    k.isFunction(j.settings.slideClick) && j.settings.slideClick.call(this, F)
                }
            });
            var b = a.properties,
                c = b.alignType,
                h = parseInt(b.horizontalSlices),
                q = parseInt(b.verticalSlices),
                n = b.slicePattern;
            d = b.effectType;
            e = b.slicePoint;
            f = b.slideStartPosition;
            g = parseFloat(b.slideStartRatio);
            var o = parseInt(b.sliceDuration),
                p = parseInt(b.sliceDelay),
                l = Math.floor(Math.min(a.width, j.settings.width) / h),
                m = Math.floor(Math.min(a.height, j.settings.height) / q),
                r = a.width > j.settings.width ? R(c, a.width, j.settings.width) : 0;
            c = a.height > j.settings.height ? S(c, a.height, j.settings.height) : 0;
            var s = a.width < j.settings.width ? Math.floor((j.settings.width - a.width) / 2) : 0,
                t = a.height < j.settings.height ? Math.floor((j.settings.height - a.height) / 2) : 0,
                B = [];
            b.slideMask && y.css("overflow", "hidden");
            for (b = 0; b < h; b++) for (var G =
            0; G < q; G++) {
                var $ = k('<div class="slice"></div>').css({
                    "background-image": "url(" + a.path + ")",
                    "background-position": -(b * l + r) + "px " + -(G * m + c) + "px",
                    "background-repeat": "no-repeat",
                    left: b * l + s,
                    top: G * m + t,
                    width: l,
                    height: m,
                    opacity: 0
                }).data({
                    hPos: b,
                    vPos: G
                }).appendTo(y);
                B.push($)
            }
            if (d == "random") d = I(["scale", "width", "height", "slide", "fade"]);
            if (n == "random") n = I(["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 = I(["leftTop", "leftCenter", "leftBottom", "centerTop", "centerCenter", "centerBottom", "rightTop", "rightCenter", "rightBottom"]);
            if (f == "random") f = I(["left", "right", "top", "bottom", "leftTop", "rightTop", "leftBottom", "horizontalAlternative", "verticalAlternative"]);
            h = aa(B, n, h, q);
            q = h.length;
            for (b = 0; b < q; b++) ba(h[b], b, q, d, e, f, g, o, p);
            ca();
            d = {
                type: "transitionStart",
                index: w,
                data: a
            };
            k.isFunction(j.settings.transitionStart) && j.settings.transitionStart.call(this, d)
        }
        function da() {
            var a = v[w],
                d = a.properties.alignType,
                e = R(d, a.width, j.settings.width);
            d = S(d, a.height, j.settings.height);
            A = false;
            y.find(".slice").remove();
            y.css({
                "background-image": "url(" + a.path + ")",
                "background-position": -e + "px " + -d + "px",
                "background-repeat": "no-repeat"
            });
            if (a.link) {
                y.css("cursor", "pointer");
                y.click(function () {
                    window.open(a.link)
                })
            }
            H && H.remove();
            j.settings.slideshow && E != "pause" && N();
            a.caption && ea(a.caption);
            e = {
                type: "transitionComplete",
                index: w,
                data: a
            };
            k.isFunction(j.settings.transitionComplete) && j.settings.transitionComplete.call(this, e)
        }
        function I(a) {
            return a[Math.floor(Math.random() * a.length)]
        }
        function ea(a) {
            var d = v[w],
                e = d.properties,
                f = e.captionPosition,
                g = e.captionSize;
            e = e.captionSlideDuration;
            var b =
            Math.min(d.width, j.settings.width);
            d = Math.min(d.height, j.settings.height);
            var c = (j.settings.width - b) / 2,
                h = (j.settings.height - d) / 2,
                q = k('<div class="caption-container"></div>').appendTo(u),
                n = k('<div class="caption"></div>').appendTo(q);
            k("<p></p>").html(a).appendTo(n);
            a = {};
            switch (f) {
            case "left":
                q.css({
                    width: g,
                    height: d,
                    left: c,
                    top: h
                });
                n.css({
                    width: "100%",
                    height: "100%",
                    left: -g,
                    top: 0
                });
                a.left = 0;
                break;
            case "right":
                q.css({
                    width: g,
                    height: d,
                    right: c,
                    top: h
                });
                n.css({
                    width: "100%",
                    height: "100%",
                    right: -g,
                    top: 0
                });
                if (k.browser.opera) a.left = 0;
                else a.right = 0;
                break;
            case "top":
                q.css({
                    width: b,
                    height: g,
                    left: c,
                    top: h
                });
                n.css({
                    width: "100%",
                    height: "100%",
                    left: 0,
                    top: -g
                });
                a.top = 0;
                break;
            case "bottom":
                q.css({
                    width: b,
                    height: g,
                    left: c,
                    bottom: h
                });
                n.css({
                    width: "100%",
                    height: "100%",
                    left: 0,
                    bottom: -g
                });
                if (k.browser.opera) a.top = 0;
                else a.bottom = 0;
                break;
            default:
                q.css({
                    width: g,
                    height: d,
                    left: c,
                    top: h
                });
                n.css({
                    width: "100%",
                    height: "100%",
                    left: -g,
                    top: 0
                });
                a.left = 0
            }
            n.animate(a, e)
        }
        function ca() {
            var a = u.find(".caption-container");
            a && a.find(".caption").animate({
                opacity: 0
            }, 300, function () {
                a.remove()
            })
        }
        function N() {
            z = setTimeout(function () {
                if (j.settings.slideshowDirection == "next") M();
                else j.settings.slideshowDirection == "previous" && L()
            }, v[w].properties.slideshowDelay || j.settings.slideshowDelay)
        }
        function R(a, d, e) {
            var f = 0;
            if (a == "centerTop" || a == "centerCenter" || a == "centerBottom") f = Math.floor((d - e) / 2);
            else if (a == "rightTop" || a == "rightCenter" || a == "rightBottom") f = d - e;
            return f
        }
        function S(a, d, e) {
            var f = 0;
            if (a == "leftCenter" || a == "centerCenter" || a == "rightCenter") f = Math.floor((d - e) / 2);
            else if (a == "leftBottom" || a == "centerBottom" || a == "rightBottom") f = d - e;
            return f
        }
        function ba(a, d, e, f, g, b, c, h, q) {
            var n = {},
                o = {},
                p = parseInt(a.css("width")),
                l = parseInt(a.css("height")),
                m = parseInt(a.css("left")),
                r = parseInt(a.css("top")),
                s, t, B = j.settings.sliceFade == true ? 0 : 1;
            if (f == "scale" || f == "width" || f == "height") switch (g) {
            case "centerCenter":
                t = r + l * 0.5;
                s = m + p * 0.5;
                break;
            case "rightCenter":
                t = r + l * 0.5;
                s = m + p;
                break;
            case "leftCenter":
                t = r + l * 0.5;
                s = m;
                break;
            case "centerTop":
                t = r;
                s = m + p * 0.5;
                break;
            case "rightTop":
                t = r;
                s = m + p;
                break;
            case "leftTop":
                t = r;
                s = m;
                break;
            case "centerBottom":
                t = r + l;
                s = m + p * 0.5;
                break;
            case "rightBottom":
                t = r + l;
                s = m + p;
                break;
            case "leftBottom":
                t = r + l;
                s = m;
                break;
            default:
                t = r + l * 0.5;
                s = m + p * 0.5
            } else if (f == "slide") switch (b) {
            case "left":
                t = r;
                s = m - p * c;
                break;
            case "right":
                t = r;
                s = m + p * c;
                break;
            case "top":
                t = r - l * c;
                s = m;
                break;
            case "bottom":
                t = r + l * c;
                s = m;
                break;
            case "leftTop":
                t = r - l * c;
                s = m - p * c;
                break;
            case "rightTop":
                t = r - l * c;
                s = m + p * c;
                break;
            case "leftBottom":
                t = r + l * c;
                s = m - p * c;
                break;
            case "rightBottom":
                t = r + l * c;
                s = m + p * c;
                break;
            case "horizontalAlternative":
                t =
                r;
                s = m + p * c * (d % 2 == 0 ? 1 : -1);
                break;
            case "verticalAlternative":
                t = r + l * c * (d % 2 == 0 ? 1 : -1);
                s = m;
                break;
            default:
                t = r;
                s = m - p * c
            }
            switch (f) {
            case "fade":
                o = {
                    opacity: 1
                };
                break;
            case "scale":
                n = {
                    width: 0,
                    height: 0,
                    left: s,
                    top: t,
                    opacity: B
                };
                o = {
                    width: p,
                    height: l,
                    left: m,
                    top: r,
                    opacity: 1
                };
                break;
            case "width":
                n = {
                    width: 0,
                    left: s,
                    opacity: B
                };
                o = {
                    width: p,
                    left: m,
                    opacity: 1
                };
                break;
            case "height":
                n = {
                    height: 0,
                    top: t,
                    opacity: B
                };
                o = {
                    height: l,
                    top: r,
                    opacity: 1
                };
                break;
            case "slide":
                n = {
                    left: s,
                    top: t,
                    opacity: B
                };
                o = {
                    left: m,
                    top: r,
                    opacity: 1
                };
                break;
            default:
                o = {
                    opacity: 1
                }
            }
            a.css(n);
            setTimeout(function () {
                a.animate(o, h, function () {
                    d == e - 1 && da()
                })
            }, d * q)
        }
        function aa(a, d, e, f) {
            var g = [],
                b, c, h = 0;
            switch (d) {
            case "randomPattern":
                for (e = []; a.length;) {
                    h = Math.floor(Math.random() * a.length);
                    e.push(a[h]);
                    a.splice(h, 1)
                }
                var q = e.length;
                for (d = 0; d < q; d++) g[d] = e[d];
                break;
            case "topToBottom":
                for (c = 0; c < f; c++) for (b = 0; b < e; b++) g.push(i(a, b, c));
                break;
            case "bottomToTop":
                for (c = f - 1; c >= 0; c--) for (b = e - 1; b >= 0; b--) g.push(i(a, b, c));
                break;
            case "rightToLeft":
                for (b = e - 1; b >= 0; b--) for (c = f - 1; c >= 0; c--) g.push(i(a, b, c));
                break;
            case "leftToRight":
                for (b = 0; b < e; b++) for (c = 0; c < f; c++) g.push(i(a, b, c));
                break;
            case "topLeftToBottomRight":
                for (d = 0; d < e + f - 1; d++) {
                    c = 0;
                    for (b = d; b >= 0; b--) {
                        i(a, b, c) != undefined && g.push(i(a, b, c));
                        c++
                    }
                }
                break;
            case "bottomLeftToTopRight":
                h = e > f ? e : f;
                for (d = e - 1; d >= 1 - h; d--) {
                    b = 0;
                    for (c = d; c <= e - 1; c++) {
                        i(a, b, c) != undefined && g.push(i(a, b, c));
                        b++
                    }
                }
                break;
            case "topRightToBottomLeft":
                h = e > f ? e : f;
                for (d = e - 1; d >= 1 - h; d--) {
                    b = d;
                    for (c = 0; c <= f - 1; c++) {
                        i(a, b, c) != undefined && g.push(i(a, b, c));
                        b++
                    }
                }
                break;
            case "bottomRightToTopLeft":
                for (d = f + e - 2; d >= 0; d--) {
                    c = 0;
                    for (b = d; b >= 0; b--) {
                        i(a, b, c) != undefined && g.push(i(a, b, c));
                        c++
                    }
                }
                break;
            case "horizontalMarginToCenter":
                if (e % 2) {
                    for (b = 0; b < Math.floor(e / 2); b++) for (c = 0; c < f; c++) {
                        g.push(i(a, b, c));
                        g.push(i(a, e - 1 - b, c))
                    }
                    for (d = 0; d < f; d++) g.push(i(a, Math.floor(e / 2), d))
                } else for (b = 0; b < Math.floor(e / 2); b++) for (c = 0; c < f; c++) {
                    g.push(i(a, b, c));
                    g.push(i(a, e - 1 - b, c))
                }
                break;
            case "horizontalCenterToMargin":
                if (e % 2) for (d = 0; d < f; d++) g.push(i(a, Math.floor(e / 2), d));
                for (b = Math.floor(e / 2) - 1; b >= 0; b--) for (c = 0; c < f; c++) {
                    g.push(i(a, b, c));
                    g.push(i(a, e - 1 - b, c))
                }
                break;
            case "verticalMarginToCenter":
                if (f % 2) {
                    for (c = 0; c < Math.floor(f / 2); c++) for (b = 0; b < e; b++) {
                        g.push(i(a, b, c));
                        g.push(i(a, b, f - 1 - c))
                    }
                    for (d = 0; d < e; d++) g.push(i(a, d, Math.floor(f / 2)))
                } else for (c = 0; c < Math.floor(f / 2); c++) for (b = 0; b < e; b++) {
                    g.push(i(a, b, c));
                    g.push(i(a, b, f - 1 - c))
                }
                break;
            case "verticalCenterToMargin":
                if (f % 2) for (d = 0; d < e; d++) g.push(i(a, d, Math.floor(f / 2)));
                for (c = Math.floor(f / 2) - 1; c >= 0; c--) for (b = 0; b < e; b++) {
                    g.push(i(a, b, c));
                    g.push(i(a, b, f - 1 - c))
                }
                break;
            case "skipOneTopToBottom":
                for (c = 0; c < f; c++) {
                    for (b =
                    h; b < e; b += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                h = 1;
                for (c = 0; c < f; c++) {
                    for (b = h; b < e; b += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "skipOneBottomToTop":
                for (c = f - 1; c >= 0; c--) {
                    for (b = h; b < e; b += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                h = 1;
                for (c = f - 1; c >= 0; c--) {
                    for (b = h; b < e; b += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "skipOneLeftToRight":
                for (b = 0; b < e; b++) {
                    for (c = h; c < f; c += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                h = 1;
                for (b = 0; b < e; b++) {
                    for (c = h; c < f; c += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "skipOneRightToLeft":
                for (b = e - 1; b >= 0; b--) {
                    for (c =
                    h; c < f; c += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                h = 1;
                for (b = e - 1; b >= 0; b--) {
                    for (c = h; c < f; c += 2) g.push(i(a, b, c));
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "skipOneVertical":
                if (f % 2) for (c = 0; c < f; c++) {
                    for (b = h; b < e; b += 2) {
                        if (c == Math.floor(f / 2)) {
                            c++;
                            for (d = 1 - e % 2; d < e; d += 2) {
                                g.push(i(a, d, Math.floor(f / 2)));
                                i(a, d - 1, Math.floor(f / 2)) != undefined && g.push(i(a, d - 1, Math.floor(f / 2)))
                            }
                        }
                        g.push(i(a, b, c));
                        g.push(i(a, b, f - c - 1))
                    }
                    h == 0 ? h = 1 : h = 0
                } else for (c = 0; c < f; c++) {
                    for (b = h; b < e; b += 2) {
                        g.push(i(a, b, c));
                        g.push(i(a, b, f - c - 1))
                    }
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "skipOneHorizontal":
                if (e % 2) for (b = 0; b < e; b++) {
                    for (c = h; c < f; c += 2) {
                        if (b == Math.floor(e / 2)) {
                            b++;
                            for (d = 1 - f % 2; d < f; d += 2) {
                                g.push(i(a, Math.floor(e / 2), d));
                                i(a, Math.floor(e / 2), d - 1) != undefined && g.push(i(a, Math.floor(e / 2), d - 1))
                            }
                        }
                        g.push(i(a, b, c));
                        g.push(i(a, e - 1 - b, c))
                    }
                    h == 0 ? h = 1 : h = 0
                } else for (b = 0; b < e; b++) {
                    for (c = h; c < f; c += 2) {
                        g.push(i(a, b, c));
                        g.push(i(a, e - 1 - b, c))
                    }
                    h == 0 ? h = 1 : h = 0
                }
                break;
            case "spiralMarginToCenterCW":
                var n = e,
                    o = f,
                    p, l = 0,
                    m = f < e ? f : e;
                q = Math.floor(m / 2);
                for (p = 0; p < q; p++) {
                    for (b = l++; b < n; b++) g.push(i(a, b, l - 1));
                    n--;
                    for (c = l; c < o; c++) g.push(i(a, e - l, c));
                    o--;
                    for (d = n; d >= e - n; d--) g.push(i(a, d - 1, o));
                    for (h = o - 1; h >= f - o; h--) g.push(i(a, l - 1, h))
                }
                if (m % 2) {
                    if (m == f) for (b = l++; b < n; b++) g.push(i(a, b, l - 1));
                    if (m == e) for (c = l++; c < o; c++) g.push(i(a, e - l, c))
                }
                break;
            case "spiralMarginToCenterCCW":
                n = e;
                o = f;
                l = 0;
                m = f < e ? f : e;
                q = Math.floor(m / 2);
                for (p = 0; p < q; p++) {
                    for (c = l++; c < o; c++) g.push(i(a, l - 1, c));
                    o--;
                    for (b = l; b < n; b++) g.push(i(a, b, f - l));
                    n--;
                    for (d = o; d >= f - o; d--) g.push(i(a, n, d - 1));
                    for (h = n - 1; h >= e - n; h--) g.push(i(a, h, l - 1))
                }
                if (m % 2) {
                    if (m == f) for (b = l++; b < n; b++) g.push(i(a, b, f - l));
                    if (m == e) for (c =
                    l++; c < o; c++) g.push(i(a, l - 1, c))
                }
                break;
            case "spiralCenterToMarginCCW":
                n = e;
                o = f;
                l = 0;
                m = f < e ? f : e;
                q = Math.floor(m / 2);
                for (p = 0; p < q; p++) {
                    for (b = l++; b < n; b++) g.push(i(a, b, l - 1));
                    n--;
                    for (c = l; c < o; c++) g.push(i(a, e - l, c));
                    o--;
                    for (d = n; d >= e - n; d--) g.push(i(a, d - 1, o));
                    for (h = o - 1; h >= f - o; h--) g.push(i(a, l - 1, h))
                }
                if (m % 2) {
                    if (m == f) for (b = l++; b < n; b++) g.push(i(a, b, l - 1));
                    if (m == e) for (c = l++; c < o; c++) g.push(i(a, e - l, c))
                }
                g.reverse();
                break;
            case "spiralCenterToMarginCW":
                n = e;
                o = f;
                l = 0;
                m = f < e ? f : e;
                q = Math.floor(m / 2);
                for (p = 0; p < q; p++) {
                    for (c = l++; c < o; c++) g.push(i(a, l - 1, c));
                    o--;
                    for (b = l; b < n; b++) g.push(i(a, b, f - l));
                    n--;
                    for (d = o; d >= f - o; d--) g.push(i(a, n, d - 1));
                    for (h = n - 1; h >= e - n; h--) g.push(i(a, h, l - 1))
                }
                if (m % 2) {
                    if (m == f) for (b = l++; b < n; b++) g.push(i(a, b, f - l));
                    if (m == e) for (c = l++; c < o; c++) g.push(i(a, l - 1, c))
                }
                g.reverse();
                break;
            default:
                for (e = []; a.length;) {
                    h = Math.floor(Math.random() * a.length);
                    e.push(a[h]);
                    a.splice(h, 1)
                }
                q = e.length;
                for (d = 0; d < q; d++) g[d] = e[d]
            }
            return g
        }
        function i(a, d, e) {
            return k.grep(a, function (f) {
                return f.data("hPos") == d && f.data("vPos") == e
            })[0]
        }
        var u = k(K),
            j = this,
            w = -1,
            O = -1,
            v = [],
            y = null,
            H = null,
            A = false,
            z = 0,
            E = "",
            J = ["alignType", "effectType", "sliceDelay", "sliceDuration", "horizontalSlices", "verticalSlices", "slicePattern", "slicePoint", "slideStartPosition", "slideStartRatio", "sliceFade", "captionSize", "captionPosition", "captionSlideDuration", "slideshowDelay", "slideMask"];
        this.settings = k.extend({}, k.fn.advancedSlider.defaults, C);
        (function () {
            u.addClass("advanced-slider").css({
                width: j.settings.width,
                height: j.settings.height
            });
            if (j.settings.xmlSource) {
                u.empty();
                k.ajax({
                    type: "GET",
                    url: j.settings.xmlSource,
                    dataType: k.browser.msie ? "text" : "xml",
                    success: function (a) {
                        var d;
                        if (k.browser.msie) {
                            d = new ActiveXObject("Microsoft.XMLDOM");
                            d.async = false;
                            d.loadXML(a)
                        } else d = a;
                        k(d).find("slide").each(function () {
                            var e = {};
                            e.properties = {};
                            for (var f = 0; f < k(this).children().length; f++) {
                                var g = k(this).children()[f];
                                e[g.nodeName] = k(this).find(g.nodeName).text()
                            }
                            for (f in J) {
                                g = J[f];
                                var b = k(this).attr(g);
                                e.properties[g] = b || j.settings[g]
                            }
                            v.push(e)
                        });
                        x()
                    }
                })
            } else {
                u.children().each(function (a) {
                    var d = {};
                    d.properties = {};
                    for (var e = 0; e < k(this).children().length; e++) {
                        var f = k(this).children()[e];
                        if (k(f).is("a")) {
                            d.path = k(f).find("img").attr("src");
                            d.link = k(f).attr("href")
                        } else if (k(f).is("img")) if (k(f).hasClass("thumbnail")) d.thumbnail = k(f).attr("src");
                        else d.path = k(f).attr("src");
                        else d[k(f).attr("class")] = k(f).html()
                    }
                    for (e in J) {
                        f = J[e];
                        var g;
                        if (j.settings.slideProperties) if (j.settings.slideProperties[a]) g = j.settings.slideProperties[a][f];
                        d.properties[f] = g || j.settings[f]
                    }
                    v.push(d)
                });
                u.empty();
                x()
            }
        })();
        this.nextSlide =
        M;
        this.previousSlide = L;
        this.gotoSlide = D;
        this.startSlideshow = function () {
            u.find(".slideshow-controls").removeClass("slideshow-play").addClass("slideshow-pause");
            E = "play";
            N()
        };
        this.stopSlideshow = function () {
            u.find(".slideshow-controls").removeClass("slideshow-pause").addClass("slideshow-play");
            E = "pause";
            z && clearTimeout(z)
        };
        this.getSlideshowState = function () {
            return E
        };
        this.getCurrentIndex = function () {
            return w
        };
        this.getSlideAt = function (a) {
            return v[a]
        };
        this.isTransition = function () {
            return A
        }
    }
    k.fn.advancedSlider =

    function (K) {
        for (var C = [], x = 0; x < this.length; x++) if (!this[x].slider) {
            this[x].slider = new T(this[x], K);
            C.push(this[x].slider)
        }
        return C.length > 1 ? C : C[0]
    };
    k.fn.advancedSlider.defaults = {
        xmlSource: null,
        width: 500,
        height: 300,
        alignType: "leftTop",
        slideshow: true,
        slideshowDelay: 5E3,
        slideshowDirection: "next",
        slideshowControls: true,
        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,
        navigationButtons: true,
        navigationButtonsCenter: true,
        showThumbnails: true,
        thumbnailSlide: 10,
        thumbnailDuration: 300,
        captionSize: 70,
        captionPosition: "bottom",
        captionSlideDuration: 500,
        slideProperties: null,
        slideMask: false,
        slideOpen: null,
        slideClick: null,
        slideMouseOver: null,
        slideMouseOut: null,
        transitionStart: null,
        transitionComplete: null
    }
})(jQuery);
