(function (a) { a.fn.bxSlider = function (b) { var c = { alignment: "horizontal", controls: true, speed: 500, pager: true, pager_short: false, pager_short_separator: " / ", margin: 0, next_text: "next", next_image: "", prev_text: "prev", prev_image: "", auto: false, pause: 3500, auto_direction: "next", auto_hover: true, auto_controls: false, ticker: false, ticker_controls: false, ticker_direction: "next", ticker_hover: true, stop_text: "stop", start_text: "start", wrapper_class: "bxslider_wrap" }; var d = a.extend(c, b); return this.each(function () { var m = a(this); var z = m.children(); var x = m.children().length; var n = m.children(":first").clone(); var o = m.children(":last").clone(); var p = 0, y = 0, D = 0, k = 0, B = 0; var j = false, i = true, C = true; var u = 1; var v = "swing", e = "", r = ""; var A = {}; m.append(n).prepend(o); m.wrap('<div id="bxslider_container" class="bxslider_container"></div>'); m.parent().wrap('<div class="' + d.wrapper_class + '"></div>'); if (d.alignment == "horizontal") { m.children().css({ "float": "left", listStyle: "none", marginRight: d.margin }); p = n.outerWidth(true); m.css({ width: "99999px", position: "relative", left: -p }); m.parent().css({ position: "relative", overflow: "hidden", width: p - d.margin }) } else { if (d.alignment == "vertical") { z.each(function () { if (a(this).height() > y) { y = a(this).height() } }); p = n.outerWidth(); m.children().css({ height: y, listStyle: "none", marginBottom: d.margin }); m.css({ height: "99999px", width: p, position: "relative", top: -(y + d.margin) }); m.parent().css({ position: "relative", overflow: "hidden", height: y }) } } if (d.pager && !d.ticker) { m.parent().after('<div class="bx_pager"></div>'); if (!d.pager_short) { var f; z.each(function (h) { f = a('<a href="#">' + (h + 1) + "</a>"); m.parent().siblings(".bx_pager").append(f); f.click(function () { j = false; C = false; m.stop(); q(h + 1); u = h + 1; if (d.auto) { clearInterval(r); m.parent().siblings(".auto_controls").find("a").html(d.start_text); i = false } else { if (d.ticker) { m.parent().siblings(".ticker_controls").find("a").html(d.start_text); i = false } } return false }) }) } else { m.parent().siblings(".bx_pager").append() } g(1) } if (d.controls && !d.ticker) { if (d.next_image != "" || d.prev_image != "") { m.parent().after('<a class="prev" href="#"><img src="' + d.prev_image + '" /></a><a class="next" href="#"><img src="' + d.next_image + '" /></a>') } else { m.parent().after('<a class="prev" href="#">' + d.prev_text + '</a><a class="next" href="#">' + d.next_text + "</a>") } m.parent().siblings(".next").click(function () { if (!j) { q(++u) } if (d.auto) { clearInterval(r); m.parent().siblings(".auto_controls").find("a").html(d.start_text); i = false } return false }); m.parent().siblings(".prev").click(function () { if (!j) { q(--u) } if (d.auto) { clearInterval(r); m.parent().siblings(".auto_controls").find("a").html(d.start_text); i = false } return false }) } if (d.auto && !d.ticker) { r = setInterval(function () { if (d.auto_direction == "next") { q(++u) } else { q(--u) } }, d.pause); if (d.auto_hover) { m.hover(function () { clearInterval(r) }, function () { if (i) { r = setInterval(function () { if (d.auto_direction == "next") { q(++u) } else { q(--u) } }, d.pause) } }) } if (d.auto_controls) { m.parent().after('<div class="auto_controls"><a class="auto_link" href="#">' + d.stop_text + "</a></div>"); m.parent().siblings(".auto_controls").find("a").click(function () { if (i) { clearInterval(r); a(this).html(d.start_text); i = false } else { r = setInterval(function () { if (d.auto_direction == "next") { q(++u) } else { q(--u) } }, d.pause); a(this).html(d.stop_text); i = true } return false }) } } if (d.ticker) { var C = true; s(); m.hover(function () { m.stop() }, function () { if (C) { s() } }); if (d.ticker_controls) { m.parent().after('<div class="ticker_controls"><a class="ticker_link" href="#">' + d.stop_text + "</a></div>"); m.parent().siblings(".ticker_controls").find("a").click(function () { if (C) { m.stop(); a(this).html(d.start_text); C = false } else { j = false; a(this).html(d.stop_text); s(); C = true } return false }) } } function s() { if (d.ticker_direction == "next" && d.alignment == "horizontal") { m.animate({ left: "-=5px" }, d.speed / 5, "linear", function () { if (parseInt(m.css("left")) <= -((x + 1) * p)) { m.css("left", -p) } s() }) } else { if (d.ticker_direction == "prev" && d.alignment == "horizontal") { m.animate({ left: "+=5px" }, d.speed / 5, "linear", function () { if (parseInt(m.css("left")) >= -(p)) { m.css("left", -((x + 1) * p)) } s() }) } else { if (d.ticker_direction == "next" && d.alignment == "vertical") { m.animate({ top: "-=5px" }, d.speed / 5, "linear", function () { if (parseInt(m.css("top")) <= -((x + 1) * (y + d.margin))) { m.css("top", -(y + d.margin)) } s() }) } else { if (d.ticker_direction == "prev" && d.alignment == "vertical") { m.animate({ top: "+=4px" }, d.speed / 5, "linear", function () { if (parseInt(m.css("top")) > -(y + d.margin)) { m.css("top", -((x + 1) * (y + d.margin - 1))) } s() }) } } } } } function q(h) { if (d.ticker) { v = "linear" } if (!j) { if (d.alignment == "horizontal") { B = p; e = "left" } else { if (d.alignment == "vertical") { B = y + d.margin; e = "top" } } k = h * B; A[e] = -k; j = true; m.animate(A, d.speed, v, function () { j = false; if (u > x) { m.css(e, -B); u = 1 } else { if (u < 1) { m.css(e, -(B * x)); u = x } } g(u) }) } } function g(h) { if (d.pager && !d.pager_short) { m.parent().siblings(".bx_pager").find("a").removeClass("active").eq(h - 1).addClass("active") } else { if (d.pager_short) { m.parent().siblings(".bx_pager").html(h + d.pager_short_separator + z.length) } } } }) } })($ektron);
