/*!
* jQuery bxSlider v3.0
* http://bxslider.com
*
* Copyright 2010, Steven Wanderski
* http://stevenwanderski.com
*
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
*/
(function (a) { a.fn.bxSlider = function (t) { var F = { mode: "horizontal", infiniteLoop: true, hideControlOnEnd: false, controls: true, speed: 500, easing: "swing", pager: false, pagerSelector: null, pagerType: "full", pagerLocation: "bottom", pagerShortSeparator: "/", pagerActiveClass: "pager-active", nextText: "next", nextImage: "", nextSelector: null, prevText: "prev", prevImage: "", prevSelector: null, captions: false, captionsSelector: null, auto: false, autoDirection: "next", autoControls: false, autoControlsSelector: null, autoStart: true, autoHover: false, autoDelay: 0, pause: 3000, startText: "start", startImage: "", stopText: "stop", stopImage: "", ticker: false, tickerSpeed: 5000, tickerDirection: "next", tickerHover: false, wrapperClass: "bx-wrapper", startingSlide: 0, displaySlideQty: 1, moveSlideQty: 1, randomStart: false, onBeforeSlide: function () { }, onAfterSlide: function () { }, onLastSlide: function () { }, onFirstSlide: function () { }, onNextSlide: function () { }, onPrevSlide: function () { }, buildPager: null }; var t = a.extend(F, t); var n = this; var j = ""; var y = ""; var N = ""; var x = ""; var C = ""; var b = ""; var S = ""; var l = ""; var W = ""; var G = ""; var e = ""; var Z = ""; var J = ""; var R = ""; var X = ""; var L = true; var z = false; var u = 0; var K = 0; var r = 0; var Y = 0; var w = 0; var p = 0; var s = 0; var P = 0; var g = 0; var V = false; var O = 0; var v = N.length - 1; this.goToSlide = function (aa, ab) { if (!V) { V = true; r = aa; t.onBeforeSlide(r, N.length, N.eq(r)); if (typeof (ab) == "undefined") { var ab = true } if (ab) { if (t.auto) { n.stopShow(true) } } slide = aa; if (slide == O) { t.onFirstSlide(r, N.length, N.eq(r)) } if (slide == v) { t.onLastSlide(r, N.length, N.eq(r)) } if (t.mode == "horizontal") { j.animate({ left: "-" + B(slide, "left") + "px" }, t.speed, t.easing, function () { V = false; t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "vertical") { j.animate({ top: "-" + B(slide, "top") + "px" }, t.speed, t.easing, function () { V = false; t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "fade") { A() } } } d(); if (t.moveSlideQty > 1) { aa = Math.floor(aa / t.moveSlideQty) } H(aa); T() } }; this.goToNextSlide = function (ad) { if (typeof (ad) == "undefined") { var ad = true } if (ad) { if (t.auto) { n.stopShow(true) } } if (!t.infiniteLoop) { if (!V) { var aa = false; r = (r + (t.moveSlideQty)); if (r <= v) { d(); t.onNextSlide(r, N.length, N.eq(r)); n.goToSlide(r) } else { r -= t.moveSlideQty } } } else { if (!V) { V = true; var aa = false; r = (r + t.moveSlideQty); if (r > v) { r = r % N.length; aa = true } t.onNextSlide(r, N.length, N.eq(r)); t.onBeforeSlide(r, N.length, N.eq(r)); if (t.mode == "horizontal") { var ab = (t.moveSlideQty * S); j.animate({ left: "-=" + ab + "px" }, t.speed, t.easing, function () { V = false; if (aa) { j.css("left", "-" + B(r, "left") + "px") } t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "vertical") { var ac = (t.moveSlideQty * K); j.animate({ top: "-=" + ac + "px" }, t.speed, t.easing, function () { V = false; if (aa) { j.css("top", "-" + B(r, "top") + "px") } t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "fade") { A() } } } if (t.moveSlideQty > 1) { H(Math.ceil(r / t.moveSlideQty)) } else { H(r) } T() } } }; this.goToPreviousSlide = function (ad) { if (typeof (ad) == "undefined") { var ad = true } if (ad) { if (t.auto) { n.stopShow(true) } } if (!t.infiniteLoop) { if (!V) { var aa = false; r = r - t.moveSlideQty; if (r < 0) { r = 0; if (t.hideControlOnEnd) { a(".bx-prev", x).hide() } } d(); t.onPrevSlide(r, N.length, N.eq(r)); n.goToSlide(r) } } else { if (!V) { V = true; var aa = false; r = (r - (t.moveSlideQty)); if (r < 0) { negativeOffset = (r % N.length); if (negativeOffset == 0) { r = 0 } else { r = (N.length) + negativeOffset } aa = true } t.onPrevSlide(r, N.length, N.eq(r)); t.onBeforeSlide(r, N.length, N.eq(r)); if (t.mode == "horizontal") { var ab = (t.moveSlideQty * S); j.animate({ left: "+=" + ab + "px" }, t.speed, t.easing, function () { V = false; if (aa) { j.css("left", "-" + B(r, "left") + "px") } t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "vertical") { var ac = (t.moveSlideQty * K); j.animate({ top: "+=" + ac + "px" }, t.speed, t.easing, function () { V = false; if (aa) { j.css("top", "-" + B(r, "top") + "px") } t.onAfterSlide(r, N.length, N.eq(r)) }) } else { if (t.mode == "fade") { A() } } } if (t.moveSlideQty > 1) { H(Math.ceil(r / t.moveSlideQty)) } else { H(r) } T() } } }; this.goToFirstSlide = function (aa) { if (typeof (aa) == "undefined") { var aa = true } n.goToSlide(O, aa) }; this.goToLastSlide = function () { if (typeof (aa) == "undefined") { var aa = true } n.goToSlide(v, aa) }; this.getCurrentSlide = function () { return r }; this.getSlideCount = function () { return N.length }; this.stopShow = function (aa) { clearInterval(e); if (typeof (aa) == "undefined") { var aa = true } if (aa && t.autoControls) { Z.html(R).removeClass("stop").addClass("start"); L = false } }; this.startShow = function (aa) { if (typeof (aa) == "undefined") { var aa = true } m(); if (aa && t.autoControls) { Z.html(X).removeClass("start").addClass("stop"); L = true } }; this.stopTicker = function (aa) { j.stop(); if (typeof (aa) == "undefined") { var aa = true } if (aa && t.ticker) { Z.html(R).removeClass("stop").addClass("start"); L = false } }; this.startTicker = function (aa) { if (t.mode == "horizontal") { if (t.tickerDirection == "next") { var ac = parseInt(j.css("left")); var ae = (p + ac) + N.eq(0).width() } else { if (t.tickerDirection == "prev") { var ac = -parseInt(j.css("left")); var ae = (ac) - N.eq(0).width() } } var ad = (ae * t.tickerSpeed) / p; E(P, ae, ad) } else { if (t.mode == "vertical") { if (t.tickerDirection == "next") { var ab = parseInt(j.css("top")); var ae = (s + ab) + N.eq(0).height() } else { if (t.tickerDirection == "prev") { var ab = -parseInt(j.css("top")); var ae = (ab) - N.eq(0).height() } } var ad = (ae * t.tickerSpeed) / s; E(g, ae, ad); if (typeof (aa) == "undefined") { var aa = true } if (aa && t.ticker) { Z.html(X).removeClass("start").addClass("stop"); L = true } } } }; this.initShow = function () { j = a(this); y = j.clone(); N = j.children(); x = ""; C = j.children(":first"); b = C.width(); u = 0; S = C.outerWidth(); K = 0; l = f(); W = U(); V = false; G = ""; r = 0; Y = 0; w = 0; e = ""; Z = ""; J = ""; R = ""; X = ""; L = true; z = false; p = 0; s = 0; P = 0; g = 0; O = 0; v = N.length - 1; N.each(function (ab) { if (a(this).outerHeight() > K) { K = a(this).outerHeight() } if (a(this).outerWidth() > u) { u = a(this).outerWidth() } }); if (t.randomStart) { var aa = Math.floor(Math.random() * N.length); r = aa; Y = S * (t.moveSlideQty + aa); w = K * (t.moveSlideQty + aa) } else { r = t.startingSlide; Y = S * (t.moveSlideQty + t.startingSlide); w = K * (t.moveSlideQty + t.startingSlide) } o(); if (t.pager && !t.ticker) { if (t.pagerType == "full") { I("full") } else { if (t.pagerType == "short") { I("short") } } } if (t.controls && !t.ticker) { i() } if (t.auto || t.ticker) { if (t.autoControls) { q() } if (t.autoStart) { setTimeout(function () { n.startShow(true) }, t.autoDelay) } else { n.stopShow(true) } if (t.autoHover && !t.ticker) { D() } } if (t.moveSlideQty > 1) { H(Math.ceil(r / t.moveSlideQty)) } else { H(r) } d(); if (t.captions) { T() } t.onAfterSlide(r, N.length, N.eq(r)) }; this.destroyShow = function () { clearInterval(e); a(".bx-next, .bx-prev, .bx-pager, .bx-auto", x).remove(); j.unwrap().unwrap().removeAttr("style"); j.children().removeAttr("style").not(".pager").remove(); N.removeClass("pager") }; this.reloadShow = function () { n.destroyShow(); n.initShow() }; function o() { Q(t.startingSlide); if (t.mode == "horizontal") { j.wrap('<div class="' + t.wrapperClass + '" style="width:' + l + 'px; position:relative;"></div>').wrap('<div class="bx-window" style="position:relative; overflow:hidden; width:' + l + 'px;"></div>').css({ width: "99999px", position: "relative", left: "-" + (Y) + "px" }); j.children().css({ width: b, "float": "left", listStyle: "none" }); x = j.parent().parent(); N.addClass("pager") } else { if (t.mode == "vertical") { j.wrap('<div class="' + t.wrapperClass + '" style="width:' + u + 'px; position:relative;"></div>').wrap('<div class="bx-window" style="width:' + u + "px; height:" + W + 'px; position:relative; overflow:hidden;"></div>').css({ height: "99999px", position: "relative", top: "-" + (w) + "px" }); j.children().css({ listStyle: "none", height: K }); x = j.parent().parent(); N.addClass("pager") } else { if (t.mode == "fade") { j.wrap('<div class="' + t.wrapperClass + '" style="width:' + u + 'px; position:relative;"></div>').wrap('<div class="bx-window" style="height:' + K + "px; width:" + u + 'px; position:relative; overflow:hidden;"></div>'); j.children().css({ listStyle: "none", position: "absolute", top: 0, left: 0, zIndex: 98 }); x = j.parent().parent(); N.not(":eq(" + r + ")").fadeTo(0, 0); N.eq(r).css("zIndex", 99) } } } if (t.captions && t.captionsSelector == null) { x.append('<div class="bx-captions"></div>') } } function Q() { if (t.mode == "horizontal" || t.mode == "vertical") { var ad = M(N, 0, t.moveSlideQty, "backward"); a.each(ad, function (af) { j.prepend(a(this)) }); var ac = (N.length + t.moveSlideQty) - 1; var ab = N.length - t.displaySlideQty; var aa = ac - ab; var ae = M(N, 0, aa, "forward"); if (t.infiniteLoop) { a.each(ae, function (af) { j.append(a(this)) }) } } } function i() { if (t.nextImage != "") { nextContent = t.nextImage; nextType = "image" } else { nextContent = t.nextText; nextType = "text" } if (t.prevImage != "") { prevContent = t.prevImage; prevType = "image" } else { prevContent = t.prevText; prevType = "text" } h(nextType, nextContent, prevType, prevContent) } function m() { if (t.auto) { if (!t.infiniteLoop) { if (t.autoDirection == "next") { e = setInterval(function () { r += t.moveSlideQty; if (r > v) { r = 0 } n.goToSlide(r, false) }, t.pause) } else { if (t.autoDirection == "prev") { e = setInterval(function () { r -= t.moveSlideQty; if (r < 0) { negativeOffset = (r % N.length); if (negativeOffset == 0) { r = 0 } else { r = (N.length) + negativeOffset } } n.goToSlide(r, false) }, t.pause) } } } else { if (t.autoDirection == "next") { e = setInterval(function () { n.goToNextSlide(false) }, t.pause) } else { if (t.autoDirection == "prev") { e = setInterval(function () { n.goToPreviousSlide(false) }, t.pause) } } } } else { if (t.ticker) { t.tickerSpeed *= 10; a(".pager", x).each(function (aa) { p += a(this).width(); s += a(this).height() }); if (t.tickerDirection == "prev" && t.mode == "horizontal") { j.css("left", "-" + (p + Y) + "px") } else { if (t.tickerDirection == "prev" && t.mode == "vertical") { j.css("top", "-" + (s + w) + "px") } } if (t.mode == "horizontal") { P = parseInt(j.css("left")); E(P, p, t.tickerSpeed) } else { if (t.mode == "vertical") { g = parseInt(j.css("top")); E(g, s, t.tickerSpeed) } } if (t.tickerHover) { k() } } } } function E(ab, ac, aa) { if (t.mode == "horizontal") { if (t.tickerDirection == "next") { j.animate({ left: "-=" + ac + "px" }, aa, "linear", function () { j.css("left", ab); E(ab, p, t.tickerSpeed) }) } else { if (t.tickerDirection == "prev") { j.animate({ left: "+=" + ac + "px" }, aa, "linear", function () { j.css("left", ab); E(ab, p, t.tickerSpeed) }) } } } else { if (t.mode == "vertical") { if (t.tickerDirection == "next") { j.animate({ top: "-=" + ac + "px" }, aa, "linear", function () { j.css("top", ab); E(ab, s, t.tickerSpeed) }) } else { if (t.tickerDirection == "prev") { j.animate({ top: "+=" + ac + "px" }, aa, "linear", function () { j.css("top", ab); E(ab, s, t.tickerSpeed) }) } } } } } function q() { if (t.startImage != "") { startContent = t.startImage; startType = "image" } else { startContent = t.startText; startType = "text" } if (t.stopImage != "") { stopContent = t.stopImage; stopType = "image" } else { stopContent = t.stopText; stopType = "text" } c(startType, startContent, stopType, stopContent) } function D() { x.find(".bx-window").hover(function () { if (L) { n.stopShow(false) } }, function () { if (L) { n.startShow(false) } }) } function k() { j.hover(function () { if (L) { n.stopTicker(false) } }, function () { if (L) { n.startTicker(false) } }) } function A() { N.not(":eq(" + r + ")").fadeTo(t.speed, 0).css("zIndex", 98); N.eq(r).css("zIndex", 99).fadeTo(t.speed, 1, function () { V = false; t.onAfterSlide(r, N.length, N.eq(r)) }) } function H(aa) { if (t.pagerType == "full" && t.pager) { a("a", G).removeClass(t.pagerActiveClass); a("a", G).eq(aa).addClass(t.pagerActiveClass) } else { if (t.pagerType == "short" && t.pager) { a(".bx-pager-current", G).html(r + 1) } } } function h(af, ae, aa, ab) { var ac = a('<a href="" class="bx-next"></a>'); var ad = a('<a href="" class="bx-prev"></a>'); if (af == "text") { ac.html(ae) } else { ac.html('<img src="' + ae + '" />') } if (aa == "text") { ad.html(ab) } else { ad.html('<img src="' + ab + '" />') } if (t.prevSelector) { a(t.prevSelector).append(ad) } else { x.append(ad) } if (t.nextSelector) { a(t.nextSelector).append(ac) } else { x.append(ac) } ac.click(function () { n.goToNextSlide(); return false }); ad.click(function () { n.goToPreviousSlide(); return false }) } function I(ad) { var ac = N.length; if (t.moveSlideQty > 1) { if (N.length % t.moveSlideQty != 0) { ac = Math.ceil(N.length / t.moveSlideQty) } else { ac = N.length / t.moveSlideQty } } var ae = ""; if (t.buildPager) { for (var aa = 0; aa < ac; aa++) { ae += t.buildPager(aa, N.eq(aa * t.moveSlideQty)) } } else { if (ad == "full") { for (var aa = 1; aa <= ac; aa++) { ae += '<a href="" class="pager-link pager-' + aa + '">' + aa + "</a>" } } else { if (ad == "short") { ae = '<span class="bx-pager-current">' + (t.startingSlide + 1) + "</span> " + t.pagerShortSeparator + ' <span class="bx-pager-total">' + N.length + "<span>" } } } if (t.pagerSelector) { a(t.pagerSelector).append(ae); G = a(t.pagerSelector) } else { var ab = a('<div class="bx-pager"></div>'); ab.append(ae); if (t.pagerLocation == "top") { x.prepend(ab) } else { if (t.pagerLocation == "bottom") { x.append(ab) } } G = a(".bx-pager", x) } G.children().click(function () { if (t.pagerType == "full") { var af = G.children().index(this); if (t.moveSlideQty > 1) { af *= t.moveSlideQty } n.goToSlide(af) } return false }) } function T() { var aa = a("img", N.eq(r)).attr("title"); if (aa != "") { if (t.captionsSelector) { a(t.captionsSelector).html(aa) } else { a(".bx-captions", x).html(aa) } } else { if (t.captionsSelector) { a(t.captionsSelector).html("&nbsp;") } else { a(".bx-captions", x).html("&nbsp;") } } } function c(ab, ac, aa, ad) { Z = a('<a href="" class="bx-start"></a>'); if (ab == "text") { R = ac } else { R = '<img src="' + ac + '" />' } if (aa == "text") { X = ad } else { X = '<img src="' + ad + '" />' } if (t.autoControlsSelector) { a(t.autoControlsSelector).append(Z) } else { x.append('<div class="bx-auto"></div>'); a(".bx-auto", x).html(Z) } Z.click(function () { if (t.ticker) { if (a(this).hasClass("stop")) { n.stopTicker() } else { if (a(this).hasClass("start")) { n.startTicker() } } } else { if (a(this).hasClass("stop")) { n.stopShow(true) } else { if (a(this).hasClass("start")) { n.startShow(true) } } } return false }) } function d() { if (!t.infiniteLoop && t.hideControlOnEnd) { if (r == O) { a(".bx-prev", x).hide() } else { a(".bx-prev", x).show() } if (r + t.moveSlideQty >= v) { a(".bx-next", x).hide() } else { a(".bx-next", x).show() } } } function B(ac, ab) { if (ab == "left") { var aa = a(".pager", x).eq(ac).position().left } else { if (ab == "top") { var aa = a(".pager", x).eq(ac).position().top } } return aa } function f() { var aa = C.outerWidth() * t.displaySlideQty; return aa } function U() { var aa = C.outerHeight() * t.displaySlideQty; return aa } function M(ag, af, ad, ae) { var ac = []; var ab = ad; var aa = false; if (ae == "backward") { ag = a.makeArray(ag); ag.reverse() } while (ab > 0) { a.each(ag, function (ah, ai) { if (ab > 0) { if (!aa) { if (ah == af) { aa = true; ac.push(a(this).clone()); ab-- } } else { ac.push(a(this).clone()); ab-- } } else { return false } }) } return ac } this.each(function () { n.initShow() }); return this } })(jQuery);
