/*! jCarousel - v0.3.0-beta.5 - 2013-05-08 * http://sorgalla.com/jcarousel * Copyright (c) 2013 Jan Sorgalla; Licensed MIT */ (function (b) { var a = b.jCarousel = {}; a.version = "0.3.0-beta.5"; var c = /^([+\-]=)?(.+)$/; a.parseTarget = function (f) { var d = !1, g = "object" != typeof f ? c.exec(f) : null; return g ? (f = parseInt(g[2], 10) || 0, g[1] && (d = !0, "-=" === g[1] && (f *= -1))) : "object" != typeof f && (f = parseInt(f, 10) || 0), {target: f, relative: d} }, a.detectCarousel = function (e) { for (var d; e.size() > 0;) { if (d = e.filter("[data-jcarousel]"), d.size() > 0) { return d } if (d = e.find("[data-jcarousel]"), d.size() > 0) { return d } e = e.parent() } return null }, a.base = function (d) { return{version: a.version, _options: {}, _element: null, _carousel: null, _init: b.noop, _create: b.noop, _destroy: b.noop, _reload: b.noop, create: function () { return this._element.attr("data-" + d.toLowerCase(), !0).data(d, this), !1 === this._trigger("create") ? this : (this._create(), this._trigger("createend"), this) }, destroy: function () { return !1 === this._trigger("destroy") ? this : (this._destroy(), this._trigger("destroyend"), this._element.removeData(d).removeAttr("data-" + d.toLowerCase()), this) }, reload: function (e) { return !1 === this._trigger("reload") ? this : (e && this.options(e), this._reload(), this._trigger("reloadend"), this) }, element: function () { return this._element }, options: function (e, f) { if (0 === arguments.length) { return b.extend({}, this._options) } if ("string" == typeof e) { if (f === void 0) { return this._options[e] === void 0 ? null : this._options[e] } this._options[e] = f } else { this._options = b.extend({}, this._options, e) } return this }, carousel: function () { return this._carousel || (this._carousel = a.detectCarousel(this.options("carousel") || this._element), this._carousel || b.error('Could not detect carousel for plugin "' + d + '"')), this._carousel }, _trigger: function (f, h, g) { var k, j = !1; return g = [this].concat(g || []), (h || this._element).each(function () { k = b.Event((f + "." + d).toLowerCase()), b(this).trigger(k, g), k.isDefaultPrevented() && (j = !0) }), !j }} }, a.plugin = function (d, g) { var f = b[d] = function (e, h) { this._element = b(e), this.options(h), this._init(), this.create() }; return f.fn = f.prototype = b.extend({}, a.base(d), g), b.fn[d] = function (h) { var j = Array.prototype.slice.call(arguments, 1), k = this; return"string" == typeof h ? this.each(function () { var e = b(this).data(d); if (!e) { return b.error("Cannot call methods on " + d + ' prior to initialization; attempted to call method "' + h + '"') } if (!b.isFunction(e[h]) || "_" === h.charAt(0)) { return b.error('No such method "' + h + '" for ' + d + " instance") } var i = e[h].apply(e, j); return i !== e && i !== void 0 ? (k = i, !1) : void 0 }) : this.each(function () { var i = b(this).data(d); i instanceof f ? i.reload(h) : new f(this, h) }), k }, f } })(jQuery), function (b, a) { var c = function (d) { return parseFloat(d) || 0 }; b.jCarousel.plugin("jcarousel", {animating: !1, tail: 0, inTail: !1, resizeTimer: null, lt: null, vertical: !1, rtl: !1, circular: !1, underflow: !1, _options: {list: function () { return this.element().children().eq(0) }, items: function () { return this.list().children() }, animation: 400, transitions: !1, wrap: null, vertical: null, rtl: null, center: !1}, _list: null, _items: null, _target: null, _first: null, _last: null, _visible: null, _fullyvisible: null, _init: function () { var d = this; return this.onWindowResize = function () { d.resizeTimer && clearTimeout(d.resizeTimer), d.resizeTimer = setTimeout(function () { d.reload() }, 100) }, this }, _create: function () { this._reload(), b(a).on("resize.jcarousel", this.onWindowResize) }, _destroy: function () { b(a).off("resize.jcarousel", this.onWindowResize) }, _reload: function () { this.vertical = this.options("vertical"), null == this.vertical && (this.vertical = this.list().height() > this.list().width()), this.rtl = this.options("rtl"), null == this.rtl && (this.rtl = function (f) { if ("rtl" === ("" + f.attr("dir")).toLowerCase()) { return !0 } var g = !1; return f.parents("[dir]").each(function () { return/rtl/i.test(b(this).attr("dir")) ? (g = !0, !1) : void 0 }), g }(this._element)), this.lt = this.vertical ? "top" : "left", this._items = null; var d = this._target && this.index(this._target) >= 0 ? this._target : this.closest(); this.circular = "circular" === this.options("wrap"), this.underflow = !1; var e = {left: 0, top: 0}; return d.size() > 0 && (this._prepare(d), this.list().find("[data-jcarousel-clone]").remove(), this._items = null, this.underflow = this._fullyvisible.size() >= this.items().size(), this.circular = this.circular && !this.underflow, e[this.lt] = this._position(d) + "px"), this.move(e), this }, list: function () { if (null === this._list) { var d = this.options("list"); this._list = b.isFunction(d) ? d.call(this) : this._element.find(d) } return this._list }, items: function () { if (null === this._items) { var d = this.options("items"); this._items = (b.isFunction(d) ? d.call(this) : this.list().find(d)).not("[data-jcarousel-clone]") } return this._items }, index: function (d) { return this.items().index(d) }, closest: function () { var f, h = this, g = this.list().position()[this.lt], k = b(), j = !1, d = this.vertical ? "bottom" : this.rtl ? "left" : "right"; return this.rtl && !this.vertical && (g = -1 * (g + this.list().width() - this.clipping())), this.items().each(function () { if (k = b(this), j) { return !1 } var e = h.dimension(k); if (g += e, g >= 0) { if (f = e - c(k.css("margin-" + d)), !(0 >= Math.abs(g) - e + f / 2)) { return !1 } j = !0 } }), k }, target: function () { return this._target }, first: function () { return this._first }, last: function () { return this._last }, visible: function () { return this._visible }, fullyvisible: function () { return this._fullyvisible }, hasNext: function () { if (!1 === this._trigger("hasnext")) { return !0 } var e = this.options("wrap"), d = this.items().size() - 1; return d >= 0 && (e && "first" !== e || d > this.index(this._last) || this.tail && !this.inTail) ? !0 : !1 }, hasPrev: function () { if (!1 === this._trigger("hasprev")) { return !0 } var d = this.options("wrap"); return this.items().size() > 0 && (d && "last" !== d || this.index(this._first) > 0 || this.tail && this.inTail) ? !0 : !1 }, clipping: function () { return this._element["inner" + (this.vertical ? "Height" : "Width")]() }, dimension: function (d) { return d["outer" + (this.vertical ? "Height" : "Width")](!0) }, scroll: function (B, F, s) { if (this.animating) { return this } if (!1 === this._trigger("scroll", null, [B, F])) { return this } b.isFunction(F) && (s = F, F = !0); var x = b.jCarousel.parseTarget(B); if (x.relative) { var w, I, A, C, q, H, E, G, J = this.items().size() - 1, t = Math.abs(x.target), z = this.options("wrap"); if (x.target > 0) { var k = this.index(this._last); if (k >= J && this.tail) { this.inTail ? "both" === z || "last" === z ? this._scroll(0, F, s) : this._scroll(Math.min(this.index(this._target) + t, J), F, s) : this._scrollTail(F, s) } else { if (w = this.index(this._target), this.underflow && w === J && ("circular" === z || "both" === z || "last" === z) || !this.underflow && k === J && ("both" === z || "last" === z)) { this._scroll(0, F, s) } else { if (A = w + t, this.circular && A > J) { for (G = J, q = this.items().get(-1); A > G++;) { q = this.items().eq(0), H = this._visible.index(q) >= 0, H && q.after(q.clone(!0).attr("data-jcarousel-clone", !0)), this.list().append(q), H || (E = {}, E[this.lt] = this.dimension(q) * (this.rtl ? -1 : 1), this.moveBy(E)), this._items = null } this._scroll(q, F, s) } else { this._scroll(Math.min(A, J), F, s) } } } } else { if (this.inTail) { this._scroll(Math.max(this.index(this._first) - t + 1, 0), F, s) } else { if (I = this.index(this._first), w = this.index(this._target), C = this.underflow ? w : I, A = C - t, 0 >= C && (this.underflow && "circular" === z || "both" === z || "first" === z)) { this._scroll(J, F, s) } else { if (this.circular && 0 > A) { for (G = A, q = this.items().get(0); 0 > G++;) { q = this.items().eq(-1), H = this._visible.index(q) >= 0, H && q.after(q.clone(!0).attr("data-jcarousel-clone", !0)), this.list().prepend(q), this._items = null; var D = c(this.list().position()[this.lt]), j = this.dimension(q); this.rtl && !this.vertical ? D += j : D -= j, E = {}, E[this.lt] = D + "px", this.move(E) } this._scroll(q, F, s) } else { this._scroll(Math.max(A, 0), F, s) } } } } } else { this._scroll(x.target, F, s) } return this._trigger("scrollend"), this }, moveBy: function (f, d) { var g = this.list().position(); return f.left && (f.left = g.left + c(f.left) + "px"), f.top && (f.top = g.top + c(f.top) + "px"), this.move(f, d) }, move: function (m, y) { y = y || {}; var t = this.options("transitions"), d = !!t, j = !!t.transforms, g = !!t.transforms3d, w = y.duration || 0, k = this.list(); if (!d && w > 0) { return k.animate(m, y), void 0 } var p = y.complete || b.noop, x = {}; if (d) { var v = k.css(["transitionDuration", "transitionTimingFunction", "transitionProperty"]), q = p; p = function () { b(this).css(v), q.call(this) }, x = {transitionDuration: (w > 0 ? w / 1000 : 0) + "s", transitionTimingFunction: t.easing || y.easing, transitionProperty: w > 0 ? function () { return j || g ? "all" : m.left ? "left" : "top" }() : "none", transform: "none"} } g ? x.transform = "translate3d(" + (m.left || 0) + "," + (m.top || 0) + ",0)" : j ? x.transform = "translate(" + (m.left || 0) + "," + (m.top || 0) + ")" : b.extend(x, m), d && w > 0 && k.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", p), k.css(x), 0 >= w && k.each(function () { p.call(this) }) }, _scroll: function (f, h, g) { if (this.animating) { return b.isFunction(g) && g.call(this, !1), this } if ("object" != typeof f ? f = this.items().eq(f) : f.jquery === void 0 && (f = b(f)), 0 === f.size()) { return b.isFunction(g) && g.call(this, !1), this } this.inTail = !1, this._prepare(f); var k = this._position(f), j = c(this.list().position()[this.lt]); if (k === j) { return b.isFunction(g) && g.call(this, !1), this } var d = {}; return d[this.lt] = k + "px", this._animate(d, h, g), this }, _scrollTail: function (d, f) { if (this.animating || !this.tail) { return b.isFunction(f) && f.call(this, !1), this } var h = this.list().position()[this.lt]; this.rtl ? h += this.tail : h -= this.tail, this.inTail = !0; var g = {}; return g[this.lt] = h + "px", this._update({target: this._target.next(), fullyvisible: this._fullyvisible.slice(1).add(this._visible.last())}), this._animate(g, d, f), this }, _animate: function (f, g, j) { if (j = j || b.noop, !1 === this._trigger("animate")) { return j.call(this, !1), this } this.animating = !0; var h = this.options("animation"), l = b.proxy(function () { this.animating = !1; var e = this.list().find("[data-jcarousel-clone]"); e.size() > 0 && (e.remove(), this._reload()), this._trigger("animateend"), j.call(this, !0) }, this), k = "object" == typeof h ? b.extend({}, h) : {duration: h}, d = k.complete || b.noop; return g === !1 ? k.duration = 0 : b.fx.speeds[k.duration] !== void 0 && (k.duration = b.fx.speeds[k.duration]), k.complete = function () { l(), d.call(this) }, this.move(f, k), this }, _prepare: function (p) { var t, g, k, j = this.index(p), x = j, m = this.dimension(p), q = this.clipping(), y = this.vertical ? "bottom" : this.rtl ? "left" : "right", w = this.options("center"), s = {target: p, first: p, last: p, visible: p, fullyvisible: q >= m ? p : b()}; if (w && (m /= 2, q /= 2), q > m) { for (; ;) { if (t = this.items().eq(++x), 0 === t.size()) { if (!this.circular) { break } if (t = this.items().eq(0), g = this._visible.index(t) >= 0, p.get(0) === t.get(0)) { break } if (g && t.after(t.clone(!0).attr("data-jcarousel-clone", !0)), this.list().append(t), !g) { var v = {}; v[this.lt] = this.dimension(t) * (this.rtl ? -1 : 1), this.moveBy(v) } this._items = null } if (m += this.dimension(t), s.last = t, s.visible = s.visible.add(t), k = c(t.css("margin-" + y)), q >= m - k && (s.fullyvisible = s.fullyvisible.add(t)), m >= q) { break } } } if (!this.circular && !w && q > m) { for (x = j; ;) { if (0 > --x) { break } if (t = this.items().eq(x), 0 === t.size()) { break } if (m += this.dimension(t), s.first = t, s.visible = s.visible.add(t), k = c(t.css("margin-" + y)), q >= m - k && (s.fullyvisible = s.fullyvisible.add(t)), m >= q) { break } } } return this._update(s), this.tail = 0, w || "circular" === this.options("wrap") || "custom" === this.options("wrap") || this.index(s.last) !== this.items().size() - 1 || (m -= c(s.last.css("margin-" + y)), m > q && (this.tail = m - q)), this }, _position: function (f) { var d = this._first, g = d.position()[this.lt], j = this.options("center"), h = j ? this.clipping() / 2 - this.dimension(d) / 2 : 0; return this.rtl && !this.vertical ? (g -= this.clipping() - this.dimension(d), g += h) : g -= h, !j && (this.index(f) > this.index(d) || this.inTail) && this.tail ? (g = this.rtl ? g - this.tail : g + this.tail, this.inTail = !0) : this.inTail = !1, -g }, _update: function (d) { var f, h = this, g = {target: this._target || b(), first: this._first || b(), last: this._last || b(), visible: this._visible || b(), fullyvisible: this._fullyvisible || b()}, k = this.index(d.first || g.first) < this.index(g.first), j = function (i) { var l = [], e = []; d[i].each(function () { 0 > g[i].index(this) && l.push(this) }), g[i].each(function () { 0 > d[i].index(this) && e.push(this) }), k ? l = l.reverse() : e = e.reverse(), h._trigger("item" + i + "in", b(l)), h._trigger("item" + i + "out", b(e)), h["_" + i] = d[i] }; for (f in d) { j(f) } return this }}) }(jQuery, window), function (a) { a.jcarousel.fn.scrollIntoView = function (m, z, t) { var b, j = a.jCarousel.parseTarget(m), g = this.index(this._fullyvisible.first()), x = this.index(this._fullyvisible.last()); if (b = j.relative ? 0 > j.target ? Math.max(0, g + j.target) : x + j.target : "object" != typeof j.target ? j.target : this.index(j.target), g > b) { return this.scroll(b, z, t) } if (b >= g && x >= b) { return a.isFunction(t) && t.call(this, !1), this } for (var k, p = this.items(), y = this.clipping(), w = this.vertical ? "bottom" : this.rtl ? "left" : "right", q = 0; ;) { if (k = p.eq(b), 0 === k.size()) { break } if (q += this.dimension(k), q >= y) { var v = parseFloat(k.css("margin-" + w)) || 0; q - v !== y && b++; break } if (0 >= b) { break } b-- } return this.scroll(b, z, t) } }(jQuery), function (a) { a.jCarousel.plugin("jcarouselControl", {_options: {target: "+=1", event: "click", method: "scroll"}, _active: null, _init: function () { this.onDestroy = a.proxy(function () { this._destroy(), this.carousel().one("createend.jcarousel", a.proxy(this._create, this)) }, this), this.onReload = a.proxy(this._reload, this), this.onEvent = a.proxy(function (b) { b.preventDefault(); var c = this.options("method"); a.isFunction(c) ? c.call(this) : this.carousel().jcarousel(this.options("method"), this.options("target")) }, this) }, _create: function () { this.carousel().one("destroy.jcarousel", this.onDestroy).on("reloadend.jcarousel scrollend.jcarousel", this.onReload), this._element.on(this.options("event") + ".jcarouselcontrol", this.onEvent), this._reload() }, _destroy: function () { this._element.off(".jcarouselcontrol", this.onEvent), this.carousel().off("destroy.jcarousel", this.onDestroy).off("reloadend.jcarousel scrollend.jcarousel", this.onReload) }, _reload: function () { var b, c = a.jCarousel.parseTarget(this.options("target")), f = this.carousel(); if (c.relative) { b = f.jcarousel(c.target > 0 ? "hasNext" : "hasPrev") } else { var d = "object" != typeof c.target ? f.jcarousel("items").eq(c.target) : c.target; b = f.jcarousel("target").index(d) >= 0 } return this._active !== b && (this._trigger(b ? "active" : "inactive"), this._active = b), this }}) }(jQuery), function (a) { a.jCarousel.plugin("jcarouselPagination", {_options: {perPage: null, item: function (b) { return'' + b + "" }, event: "click", method: "scroll"}, _pages: {}, _items: {}, _currentPage: null, _init: function () { this.onDestroy = a.proxy(function () { this._destroy(), this.carousel().one("createend.jcarousel", a.proxy(this._create, this)) }, this), this.onReload = a.proxy(this._reload, this), this.onScroll = a.proxy(this._update, this) }, _create: function () { this.carousel().one("destroy.jcarousel", this.onDestroy).on("reloadend.jcarousel", this.onReload).on("scrollend.jcarousel", this.onScroll), this._reload() }, _destroy: function () { this._clear(), this.carousel().off("destroy.jcarousel", this.onDestroy).off("reloadend.jcarousel", this.onReload).off("scrollend.jcarousel", this.onScroll) }, _reload: function () { var g = this.options("perPage"); if (this._pages = {}, this._items = {}, a.isFunction(g) && (g = g.call(this)), null == g) { this._pages = this._calculatePages() } else { for (var q, k = parseInt(g, 10) || 0, b = this.carousel().jcarousel("items"), d = 1, c = 0; ;) { if (q = b.eq(c++), 0 === q.size()) { break } this._pages[d] = this._pages[d] ? this._pages[d].add(q) : q, 0 === c % k && d++ } } this._clear(); var m = this, f = this.carousel().data("jcarousel"), j = this._element, p = this.options("item"); a.each(this._pages, function (h, l) { var n = m._items[h] = a(p.call(m, h, l)); n.on(m.options("event") + ".jcarouselpagination", a.proxy(function () { var i = l.eq(0); if (f.circular) { var s = f.index(f.target()), o = f.index(i); parseFloat(h) > parseFloat(m._currentPage) ? s > o && (i = "+=" + (f.items().size() - s + o)) : o > s && (i = "-=" + (s + (f.items().size() - o))) } f[this.options("method")](i) }, m)), j.append(n) }), this._update() }, _update: function () { var b, c = this.carousel().jcarousel("target"); a.each(this._pages, function (d, f) { return f.each(function () { return c.is(this) ? (b = d, !1) : void 0 }), b ? !1 : void 0 }), this._currentPage !== b && (this._trigger("inactive", this._items[this._currentPage]), this._trigger("active", this._items[b])), this._currentPage = b }, items: function () { return this._items }, _clear: function () { this._element.empty(), this._currentPage = null }, _calculatePages: function () { for (var d, c = this.carousel().data("jcarousel"), f = c.items(), h = c.clipping(), g = 0, k = 0, j = 1, b = {}; ;) { if (d = f.eq(k++), 0 === d.size()) { break } b[j] = b[j] ? b[j].add(d) : d, g += c.dimension(d), g >= h && (j++, g = 0) } return b }}) }(jQuery), function (a) { a.jCarousel.plugin("jcarouselAutoscroll", {_options: {target: "+=1", interval: 3000, autostart: !0}, _timer: null, _init: function () { this.onDestroy = a.proxy(function () { this._destroy(), this.carousel().one("createend.jcarousel", a.proxy(this._create, this)) }, this), this.onAnimateEnd = a.proxy(this.start, this) }, _create: function () { this.carousel().one("destroy.jcarousel", this.onDestroy), this.options("autostart") && this.start() }, _destroy: function () { this.stop(), this.carousel().off("destroy.jcarousel", this.onDestroy) }, start: function () { return this.stop(), this.carousel().one("animateend.jcarousel", this.onAnimateEnd), this._timer = setTimeout(a.proxy(function () { this.carousel().jcarousel("scroll", this.options("target")) }, this), this.options("interval")), this }, stop: function () { return this._timer && (this._timer = clearTimeout(this._timer)), this.carousel().off("animateend.jcarousel", this.onAnimateEnd), this }}) }(jQuery);