(function (h) {
    h.fn.sudoSlider = function (X) {
        var c = false,
            e = !c,
            f = this,
            X = h.extend({
                controlsShow: e,
                controlsFadeSpeed: 400,
                controlsFade: e,
                insertAfter: e,
                firstShow: c,
                lastShow: c,
                vertical: c,
                speed: 800,
                ease: "swing",
                auto: c,
                pause: 2E3,
                continuous: c,
                prevNext: e,
                numeric: c,
                numericAttr: 'class="controls"',
                numericText: [],
                clickableAni: c,
                history: c,
                speedhistory: 400,
                autoheight: e,
                customLink: c,
                fade: c,
                crossFade: e,
                fadespeed: 1E3,
                updateBefore: c,
                ajax: c,
                preloadAjax: 100,
                startSlide: c,
                ajaxLoadFunction: c,
                beforeAniFunc: c,
                afterAniFunc: c,
                uncurrentFunc: c,
                currentFunc: c,
                prevHtml: '<a href="#" class="prevBtn"> previous </a>',
                nextHtml: '<a href="#" class="nextBtn"> next </a>',
                loadingText: "Loading Content...",
                firstHtml: '<a href="#" class="firstBtn"> first </a>',
                controlsAttr: 'id="controls"',
                lastHtml: '<a href="#" class="lastBtn"> last </a>',
                autowidth: e,
                slideCount: 1,
                resumePause: c,
                moveCount: 1
            }, X);
        return this.each(function () {
            function ea(d, p) {
                l = 0;
                for (b in I) a[l] = I[b], l++;
                x = c;
                D = e;
                o = d.children("ul");
                k = o.children("li");
                j = k.length;
                if (a[25] && (o.length == 0 && d.append(o = h("<ul></ul>")), a[25].length > j)) {
                    for (b = 1; b <= a[25].length - j; b++) o.append("<li><p>" + a[35] + "</p></li>");
                    k = o.children("li");
                    j = k.length
                }
                y = g = 0;
                t = j - 1;
                q = e;
                J = r = Y = c;
                Q = [];
                x = c;
                d.css("position") == "static" && d.css("position", "relative");
                k.css({
                    "float": "left",
                    display: "block"
                });
                a[40] = n(a[40]);
                a[42]--;
                v = a[40];
                a[21] || (a[40] += a[42]);
                a[40] > j && (a[40] = j);
                a[27] = n(a[27]) || 1;
                E = a[11] && (!a[21] || a[40] > 1);
                for (b = 0; b < j; b++) a[15][b] = a[15][b] || b + 1, a[25][b] = a[25][b] || c;
                if (E) {
                    for (i = a[40]; i >= 1; i--) o.prepend(k.eq(-a[40] + i - 1).clone()).append(k.eq(a[40] - i).clone());
                    m = o.children("li");
                    if (a[25]) for (b = j - a[40]; b < j; b++) a[25][b] && b != a[27] - 1 && z(b, c, 0, c)
                }
                a[2] = a[2] && !a[11];
                o[a[6] ? "height" : "width"](1E7);
                m = o.children("li");
                A = c;
                if (a[0]) {
                    A = h("<span " + a[37] + "></span>");
                    h(d)[a[3] ? "after" : "before"](A);
                    if (a[13]) {
                        fa = A.prepend("<ol " + a[14] + "></ol>").children();
                        l = a[13] == "pages" ? v : 1;
                        for (b = 0; b < j - (a[11] || a[13] == "pages" ? 1 : v) + 1; b += l) Q[b] = h("<li rel='" + (b + 1) + "'><a href='#'><span>" + a[15][b] + "</span></a></li>").appendTo(fa).click(function () {
                            F(h(this).attr("rel") - 1, e);
                            return c
                        })
                    }
                    a[4] && (ga = R(a[36], "first"));
                    a[5] && (ha = R(a[38], "last"));
                    a[12] && (ia = R(a[34], "next"), ja = R(a[33], "prev"))
                }
                if (a[26] === e) for (i = 0; i <= t; i++) a[25][i] && a[27] - 1 != i && z(i, c, 0, c);
                l = [1, 7, 10, 18, 23];
                for (b in l) a[n(l[b])] = sa(a[n(l[b])]);
                a[20] && h(a[20]).live("click", function () {
                    if (b = h(this).attr("rel")) b == "stop" ? (a[9] = c, clearTimeout(u), K = c) : b == "start" ? (u = L(a[10]), a[9] = e) : b == "block" ? q = c : b == "unblock" ? q = e : q && F(b == n(b) ? b - 1 : b, e);
                    return c
                });
                Z(m.slice(0, a[40]), e, function () {
                    a[9] && (u = L(a[10]));
                    p ? B(p, c, c, c) : a[17] ? (h.hashchange ? h(window).hashchange(S) : h.address ? h.address.change(function () {
                        S()
                    }) : h(window).bind("hashchange", S), S()) : B(a[27] - 1, c, c, c)
                })
            }
            function S() {
                a: {
                    var d = location.hash.substr(1);
                    for (i in a[15]) if (a[15][i] == d) break a;
                    i = d ? g : 0
                }
                D ? B(i, c, c, c) : i != g && F(i, c)
            }
            function ka() {
                if (a[25] && n(a[26])) for (b in a[25]) if (a[25][b]) {
                    clearTimeout(T);
                    T = setTimeout(function () {
                        z(b, c, 0, c)
                    }, n(a[26]));
                    break
                }
            }
            function L(a) {
                K = e;
                return setTimeout(function () {
                    F("next", c)
                }, a)
            }
            function sa(a) {
                return n(a) || a == 0 ? n(a) : a == "fast" ? 200 : a == "normal" || a == "medium" ? 400 : a == "slow" ? 600 : 400
            }
            function R(a, b) {
                return h(a).prependTo(A).click(function () {
                    F(b, e);
                    return c
                })
            }
            function F(d, p) {
                M = c;
                if (!x) {
                    if (a[9]) {
                        var w = a[7];
                        r && a[22] ? w = n(w * 0.6) : r && (w = 0);
                        p ? (clearTimeout(u), K = c, a[41] && (u = L(w + a[41]))) : u = L(a[10] + w)
                    }
                    a[21] ? la(d, p) : (a[11] ? (d = b = N(d), w = Math.abs(g - b), b < a[40] - v + 1 && Math.abs(g - b - j) < w && (d = b + j, w = Math.abs(g - b - j)), b > t - a[40] && Math.abs(g - b + j) < w && (d = b - j)) : d = N(d), B(d, p, e, c))
                }
            }
            function ma(d, c, b) {
                if (b) var b = ia,
                    e = ha,
                    g = "next",
                    f = "last",
                    j = a[5];
                else b = ja, e = ga, g = "prev", f = "first", j = a[4];
                if (a[0]) {
                    if (a[12]) b[d ? "fadeIn" : "fadeOut"](c);
                    if (j) e[d ? "fadeIn" : "fadeOut"](c)
                }
                if (a[20]) h(a[20]).filter(function () {
                    return h(this).attr("rel") == g || h(this).attr("rel") == f
                })[d ? "fadeIn" : "fadeOut"](c)
            }
            function na(a, b) {
                ma(a, b, c);
                ma(a < j - v, b, e)
            }
            function $(d) {
                d = s(d) + 1;
                if (a[13]) for (b in Q) oa(Q[b], d);
                a[20] && oa(h(a[20]), d)
            }
            function oa(d, p) {
                d.filter && (d.filter(".current").removeClass("current").each(function () {
                    h.isFunction(a[31]) && a[31].call(this, h(this).attr("rel"))
                }), d.filter(function () {
                    l = h(this).attr("rel");
                    if (a[13] == "pages") for (b = 0; b < v; b++) {
                        if (l == p - b) return e
                    } else return l == p;
                    return c
                }).addClass("current").each(function () {
                    h.isFunction(a[32]) && a[32].call(this, p)
                }))
            }
            function Z(a, b, c) {
                var a = h(a).add(a.find("img")).filter("img"),
                    e = a.length;
                e || c();
                a.each(function () {
                    h(this).load(function () {
                        this.naturalHeight && !this.clientHeight && h(this).height(this.naturalHeight).width(this.naturalWidth);
                        b ? (e--, e == 0 && c()) : c()
                    });
                    if (this.readyState == "complete") h(this).trigger("load");
                    else if (this.readyState) this.onreadystatechange = function () {
                        this.readyState == "complete" && h(this).trigger("load")
                    }, this.src = this.src;
                    else if ((this.complete || this.complete === void 0) && b) {
                        var a = this.src;
                        this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
                        this.src = a
                    }
                })
            }
            function V(d, b) {
                a[19] && pa(d, b, e);
                a[39] && pa(d, b, c)
            }
            function pa(a, b, e) {
                O.ready(function () {
                    qa(a, b, e);
                    Z(k.eq(a), c, function () {
                        qa(a, b, e)
                    })
                })
            }
            function qa(d, b, e) {
                d = s(d);
                l = k.eq(d)[e ? "height" : "width"]();
                O.animate(e ? {
                    height: l
                } : {
                    width: l
                }, {
                    queue: c,
                    duration: b,
                    easing: a[8]
                })
            }
            function aa() {
                o.css(a[6] ? "margin-top" : "margin-left", ba(g))
            }
            function ba(d) {
                d = m.eq(d + (E ? a[40] : 0));
                return d.length ? -d.position()[a[6] ? "top" : "left"] : 0
            }
            function ta() {
                g = s(g);
                a[24] || $(g);
                aa();
                q = e;
                if (a[17] && Y) window.location.hash = a[15][g];
                !r && M && C(g, e)
            }
            function C(d, b) {
                (b ? ca : da)(k.eq(d), s(d) + 1);
                if (E && (d < a[40] && (b ? ca : da)(m.eq(d < 0 ? d + a[40] : d - a[40]), d + 1), d > t - a[40] || d == -a[40]))(b ? ca : da)(m.eq(d == -a[40] ? -1 : a[40] + d - t - 1), d + 1)
            }
            function ca(d, b) {
                h.isFunction(a[30]) && a[30].call(d, b)
            }
            function da(d, b) {
                h.isFunction(a[29]) && a[29].call(d, b)
            }
            function N(d) {
                return d == "next" ? s(g + 1 + a[42]) : d == "prev" ? s(g - 1 - a[42]) : d == "first" ? 0 : d == "last" ? t : n(d)
            }
            function z(d, b, g, f) {
                T && clearTimeout(T);
                var U = a[25][d],
                    j = k.eq(d),
                    l = g === e,
                    g = g === e ? 0 : g;
                r && !a[22] && n(a[23] * 0.4);
                var i = c;
                h.ajax({
                    url: U,
                    success: function (a, h, U) {
                        U.getResponseHeader("Content-Type").substr(0, 5) != "image" && (i = e, j.html(a), ra(d, g, f, b, l, c))
                    },
                    complete: function () {
                        if (!i) image = new Image, j.html("").append(image), image.src = U, ra(d, g, f, b, l, e)
                    }
                });
                a[25][d] = c;
                I.ajax[d] = c
            }
            function ra(d, b, g, f, j, l) {
                var i = k.eq(d);
                E && (d < a[40] && m.eq(d < 0 ? d + a[40] : d - a[40]).replaceWith(h(i).clone()), d > t - a[40] && m.eq(a[40] + d - t - 1).replaceWith(h(i).clone()), m = o.children("li"), j === e && aa());
                f && V(d, b);
                Z(i, e, function () {
                    j === e && aa();
                    h.isFunction(g) && g();
                    ka()
                });
                h.isFunction(a[28]) && a[28].call(i, n(d) + 1, l);
                g == 2 && (C(d, c), M || (C(d, e), M = e))
            }
            function la(d, p, f) {
                if (N(d) != g && !x && q) {
                    J = c;
                    a[24] && $(N(d));
                    var j = !p && !a[9] && a[17] ? a[23] * (a[18] / a[7]) : a[23],
                        i = N(d);
                    a[2] && na(i, a[1]);
                    if (f) j = W, G && G--;
                    else if (a[25]) {
                        G = 0;
                        W = j;
                        for (b = i; b < i + v; b++) a[25][b] && (z(s(b), c, j, function () {
                            la(d, p, e)
                        }), G++)
                    } else G = c;
                    if (!G) if (q = !p, V(i, a[23]), C(i, c), a[22]) {
                        var l = e,
                            f = 0;
                        for (b = i; b < i + v; b++) j = k.eq(s(b)).clone().prependTo(O), h.isFunction(a[29]) && a[29].call(j, s(b) + 1), j.css({
                            "z-index": "100000",
                            position: "absolute",
                            "list-style": "none",
                            top: a[6] ? f : 0,
                            left: a[6] ? 0 : f
                        }).hide().fadeIn(a[23], function () {
                            screen.fontSmoothingEnabled && this.style.removeAttribute("filter");
                            r = q = e;
                            if (l) {
                                B(i, c, c, c);
                                if (a[17] && p) window.location.hash = a[15][g];
                                C(i, e);
                                l = c
                            }
                            h(this).remove();
                            r = c
                        }), f += k.eq(b)[a[6] ? "outerHeight" : "outerWidth"](e)
                    } else {
                        var o = n(j * 0.6);
                        k.stop().fadeTo(j - o, 0.001, function () {
                            r = q = e;
                            B(i, c, c, c);
                            q = !p;
                            k.fadeTo(o, 1, function () {
                                screen.fontSmoothingEnabled && this.style.removeAttribute("filter");
                                if (a[17] && p) window.location.hash = a[15][g];
                                q = e;
                                r = c;
                                C(i, e)
                            })
                        })
                    }
                }
            }
            function B(d, f, h, i) {
                if (q && !x && (d != g || D) && j > s(d) || i) {
                    i || (J = c);
                    q = !f && !a[9] ? e : a[16];
                    Y = f;
                    y = g;
                    g = d;
                    a[24] && $(g);
                    var k = Math.sqrt(Math.abs(y - g)),
                        m = !h ? 0 : !f && !a[9] ? n(k * a[18]) : n(k * a[7]),
                        k = s(g);
                    if (i) m = W, P && P--;
                    else if (a[25]) {
                        a[25][k] && (z(k, e, D || m, 2), J = e);
                        if (!r) {
                            var i = y > g ? g : y,
                                u = y > g ? y : g;
                            P = 0;
                            W = m;
                            for (b = i; b <= u; b++) b <= t && b >= 0 && a[25][b] && (z(b, c, m, function () {
                                B(d, f, h, e)
                            }), P++)
                        }
                        for (b = k + 1; b <= k + v; b++) a[25][b] && z(b, c, 0, c)
                    }
                    P || (!r && !J && (C(k, c), M = e), r || V(g, m), l = ba(g), o.animate(a[6] ? {
                        marginTop: l
                    } : {
                        marginLeft: l
                    }, {
                        queue: c,
                        duration: m,
                        easing: a[8],
                        complete: ta
                    }), a[2] && (m = a[1], !f && !a[9] && (m = a[18] / a[7] * a[1]), h || (m = 0), r && (m = n(a[23] * 0.6)), na(g, m)), D && (a[25][k] || ka()), D = c)
                }
            }
            function s(a) {
                return n(a < 0 ? a + j : a > t ? a - j : a)
            }
            function n(a) {
                return parseInt(a, 10)
            }
            var D, o, k, m, j, g, y, t, q, Y, r, J, Q, fa, x, A, ga, ha, ia, ja, u, H, W, P, G, K, b, l, i, E, v, M = c,
                T, O = h(this),
                I = X,
                a = [];
            ea(O, c);
            f.getOption = function (a) {
                return I[a]
            };
            f.setOption = function (a, b) {
                b && (f.destroy(), I[a] = b, f.init());
                return f
            };
            f.insertSlide = function (b, c, e) {
                if (b) {
                    f.destroy();
                    c > j && (c = j);
                    b = "<li>" + b + "</li>";
                    !c || c == 0 ? o.prepend(b) : k.eq(c - 1).after(b);
                    (c <= H || !c || c == 0) && H++;
                    if (a[15].length < c) a[15].length = c;
                    a[15].splice(c, 0, e || n(c) + 1);
                    f.init()
                }
                return f
            };
            f.removeSlide = function (b) {
                b--;
                f.destroy();
                k.eq(b).remove();
                a[15].splice(b, 1);
                b < H && H--;
                f.init();
                return f
            };
            f.goToSlide = function (a) {
                F(a == n(a) ? a - 1 : a, e);
                return f
            };
            f.block = function () {
                q = c;
                return f
            };
            f.unblock = function () {
                q = e;
                return f
            };
            f.startAuto = function () {
                a[9] = e;
                u = L(a[10]);
                return f
            };
            f.stopAuto = function () {
                a[9] = c;
                clearTimeout(u);
                K = c;
                return f
            };
            f.destroy = function () {
                H = g;
                A && A.remove();
                x = e;
                h(a[20]).die("click");
                if (E) for (b = 1; b <= a[40]; b++) m.eq(b - 1).add(m.eq(-b)).remove();
                o.css(a[6] ? "margin-top" : "margin-left", ba(g));
                return f
            };
            f.init = function () {
                x && ea(O, H);
                return f
            };
            f.adjust = function (a) {
                a || (a = 0);
                V(i, a);
                return f
            };
            f.getValue = function (a) {
                return a == "currentSlide" ? g + 1 : a == "totalSlides" ? j : a == "clickable" ? q : a == "destroyed" ? x : a == "autoAnimation" ? K : void 0
            }
        })
    }
})(jQuery);



