1/*! jCarousel - v0.3.0-beta.5 - 2013-05-08
2 * http://sorgalla.com/jcarousel
3 * Copyright (c) 2013 Jan Sorgalla; Licensed MIT */
4(function (t) {
5	"use strict";
6	var i = t.jCarousel = {};
7	i.version = "0.3.0-beta.5";
8	var s = /^([+\-]=)?(.+)$/;
9	i.parseTarget = function (t) {
10		var i = !1,
11			e = "object" != typeof t ? s.exec(t) : null;
12		return e ? (t = parseInt(e[2], 10) || 0, e[1] && (i = !0, "-=" === e[1] && (t *= -1))) : "object" != typeof t && (t = parseInt(t, 10) || 0), {
13			target: t,
14			relative: i
15		}
16	}, i.detectCarousel = function (t) {
17		for (var i; t.size() > 0;) {
18			if (i = t.filter("[data-jcarousel]"), i.size() > 0) return i;
19			if (i = t.find("[data-jcarousel]"), i.size() > 0) return i;
20			t = t.parent()
21		}
22		return null
23	}, i.base = function (s) {
24		return {
25			version: i.version,
26			_options: {},
27			_element: null,
28			_carousel: null,
29			_init: t.noop,
30			_create: t.noop,
31			_destroy: t.noop,
32			_reload: t.noop,
33			create: function () {
34				return this._element.attr("data-" + s.toLowerCase(), !0).data(s, this), !1 === this._trigger("create") ? this : (this._create(), this._trigger("createend"), this)
35			},
36			destroy: function () {
37				return !1 === this._trigger("destroy") ? this : (this._destroy(), this._trigger("destroyend"), this._element.removeData(s).removeAttr("data-" + s.toLowerCase()), this)
38			},
39			reload: function (t) {
40				return !1 === this._trigger("reload") ? this : (t && this.options(t), this._reload(), this._trigger("reloadend"), this)
41			},
42			element: function () {
43				return this._element
44			},
45			options: function (i, s) {
46				if (0 === arguments.length) return t.extend({}, this._options);
47				if ("string" == typeof i) {
48					if (s === void 0) return this._options[i] === void 0 ? null : this._options[i];
49					this._options[i] = s
50				} else this._options = t.extend({}, this._options, i);
51				return this
52			},
53			carousel: function () {
54				return this._carousel || (this._carousel = i.detectCarousel(this.options("carousel") || this._element), this._carousel || t.error('Could not detect carousel for plugin "' + s + '"')), this._carousel
55			},
56			_trigger: function (i, e, r) {
57				var n, o = !1;
58				return r = [this].concat(r || []), (e || this._element).each(function () {
59					n = t.Event((i + "." + s).toLowerCase()), t(this).trigger(n, r), n.isDefaultPrevented() && (o = !0)
60				}), !o
61			}
62		}
63	}, i.plugin = function (s, e) {
64		var r = t[s] = function (i, s) {
65			this._element = t(i), this.options(s), this._init(), this.create()
66		};
67		return r.fn = r.prototype = t.extend({}, i.base(s), e), t.fn[s] = function (i) {
68			var e = Array.prototype.slice.call(arguments, 1),
69				n = this;
70			return "string" == typeof i ? this.each(function () {
71				var r = t(this).data(s);
72				if (!r) return t.error("Cannot call methods on " + s + " prior to initialization; " + 'attempted to call method "' + i + '"');
73				if (!t.isFunction(r[i]) || "_" === i.charAt(0)) return t.error('No such method "' + i + '" for ' + s + " instance");
74				var o = r[i].apply(r, e);
75				return o !== r && o !== void 0 ? (n = o, !1) : void 0
76			}) : this.each(function () {
77				var e = t(this).data(s);
78				e instanceof r ? e.reload(i) : new r(this, i)
79			}), n
80		}, r
81	}
82})(jQuery),
83	function (t, i) {
84		"use strict";
85		var s = function (t) {
86			return parseFloat(t) || 0
87		};
88		t.jCarousel.plugin("jcarousel", {
89			animating: !1,
90			tail: 0,
91			inTail: !1,
92			resizeTimer: null,
93			lt: null,
94			vertical: !1,
95			rtl: !1,
96			circular: !1,
97			underflow: !1,
98			_options: {
99				list: function () {
100					return this.element().children().eq(0)
101				},
102				items: function () {
103					return this.list().children()
104				},
105				animation: 400,
106				transitions: !1,
107				wrap: null,
108				vertical: null,
109				rtl: null,
110				center: !1
111			},
112			_list: null,
113			_items: null,
114			_target: null,
115			_first: null,
116			_last: null,
117			_visible: null,
118			_fullyvisible: null,
119			_init: function () {
120				var t = this;
121				return this.onWindowResize = function () {
122					t.resizeTimer && clearTimeout(t.resizeTimer), t.resizeTimer = setTimeout(function () {
123						t.reload()
124					}, 100)
125				}, this
126			},
127			_create: function () {
128				this._reload(), t(i).on("resize.jcarousel", this.onWindowResize)
129			},
130			_destroy: function () {
131				t(i).off("resize.jcarousel", this.onWindowResize)
132			},
133			_reload: function () {
134				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 (i) {
135					if ("rtl" === ("" + i.attr("dir")).toLowerCase()) return !0;
136					var s = !1;
137					return i.parents("[dir]").each(function () {
138						return /rtl/i.test(t(this).attr("dir")) ? (s = !0, !1) : void 0
139					}), s
140				}(this._element)), this.lt = this.vertical ? "top" : "left", this._items = null;
141				var i = this._target && this.index(this._target) >= 0 ? this._target : this.closest();
142				this.circular = "circular" === this.options("wrap"), this.underflow = !1;
143				var s = {
144					left: 0,
145					top: 0
146				};
147				return i.size() > 0 && (this._prepare(i), this.list().find("[data-jcarousel-clone]").remove(), this._items = null, this.underflow = this._fullyvisible.size() >= this.items().size(), this.circular = this.circular && !this.underflow, s[this.lt] = this._position(i) + "px"), this.move(s), this
148			},
149			list: function () {
150				if (null === this._list) {
151					var i = this.options("list");
152					this._list = t.isFunction(i) ? i.call(this) : this._element.find(i)
153				}
154				return this._list
155			},
156			items: function () {
157				if (null === this._items) {
158					var i = this.options("items");
159					this._items = (t.isFunction(i) ? i.call(this) : this.list().find(i)).not("[data-jcarousel-clone]")
160				}
161				return this._items
162			},
163			index: function (t) {
164				return this.items().index(t)
165			},
166			closest: function () {
167				var i, e = this,
168					r = this.list().position()[this.lt],
169					n = t(),
170					o = !1,
171					a = this.vertical ? "bottom" : this.rtl ? "left" : "right";
172				return this.rtl && !this.vertical && (r = -1 * (r + this.list().width() - this.clipping())), this.items().each(function () {
173					if (n = t(this), o) return !1;
174					var l = e.dimension(n);
175					if (r += l, r >= 0) {
176						if (i = l - s(n.css("margin-" + a)), !(0 >= Math.abs(r) - l + i / 2)) return !1;
177						o = !0
178					}
179				}), n
180			},
181			target: function () {
182				return this._target
183			},
184			first: function () {
185				return this._first
186			},
187			last: function () {
188				return this._last
189			},
190			visible: function () {
191				return this._visible
192			},
193			fullyvisible: function () {
194				return this._fullyvisible
195			},
196			hasNext: function () {
197				if (!1 === this._trigger("hasnext")) return !0;
198				var t = this.options("wrap"),
199					i = this.items().size() - 1;
200				return i >= 0 && (t && "first" !== t || i > this.index(this._last) || this.tail && !this.inTail) ? !0 : !1
201			},
202			hasPrev: function () {
203				if (!1 === this._trigger("hasprev")) return !0;
204				var t = this.options("wrap");
205				return this.items().size() > 0 && (t && "last" !== t || this.index(this._first) > 0 || this.tail && this.inTail) ? !0 : !1
206			},
207			clipping: function () {
208				return this._element["inner" + (this.vertical ? "Height" : "Width")]()
209			},
210			dimension: function (t) {
211				return t["outer" + (this.vertical ? "Height" : "Width")](!0)
212			},
213			scroll: function (i, e, r) {
214				if (this.animating) return this;
215				if (!1 === this._trigger("scroll", null, [i, e])) return this;
216				t.isFunction(e) && (r = e, e = !0);
217				var n = t.jCarousel.parseTarget(i);
218				if (n.relative) {
219					var o, a, l, h, u, c, f, d, _ = this.items().size() - 1,
220						p = Math.abs(n.target),
221						m = this.options("wrap");
222					if (n.target > 0) {
223						var v = this.index(this._last);
224						if (v >= _ && this.tail) this.inTail ? "both" === m || "last" === m ? this._scroll(0, e, r) : this._scroll(Math.min(this.index(this._target) + p, _), e, r) : this._scrollTail(e, r);
225						else if (o = this.index(this._target), this.underflow && o === _ && ("circular" === m || "both" === m || "last" === m) || !this.underflow && v === _ && ("both" === m || "last" === m)) this._scroll(0, e, r);
226						else if (l = o + p, this.circular && l > _) {
227							for (d = _, u = this.items().get(-1); l > d++;) u = this.items().eq(0), c = this._visible.index(u) >= 0, c && u.after(u.clone(!0).attr("data-jcarousel-clone", !0)), this.list().append(u), c || (f = {}, f[this.lt] = this.dimension(u) * (this.rtl ? -1 : 1), this.moveBy(f)), this._items = null;
228							this._scroll(u, e, r)
229						} else this._scroll(Math.min(l, _), e, r)
230					} else if (this.inTail) this._scroll(Math.max(this.index(this._first) - p + 1, 0), e, r);
231					else if (a = this.index(this._first), o = this.index(this._target), h = this.underflow ? o : a, l = h - p, 0 >= h && (this.underflow && "circular" === m || "both" === m || "first" === m)) this._scroll(_, e, r);
232					else if (this.circular && 0 > l) {
233						for (d = l, u = this.items().get(0); 0 > d++;) {
234							u = this.items().eq(-1), c = this._visible.index(u) >= 0, c && u.after(u.clone(!0).attr("data-jcarousel-clone", !0)), this.list().prepend(u), this._items = null;
235							var g = s(this.list().position()[this.lt]),
236								y = this.dimension(u);
237							this.rtl && !this.vertical ? g += y : g -= y, f = {}, f[this.lt] = g + "px", this.move(f)
238						}
239						this._scroll(u, e, r)
240					} else this._scroll(Math.max(l, 0), e, r)
241				} else this._scroll(n.target, e, r);
242				return this._trigger("scrollend"), this
243			},
244			moveBy: function (t, i) {
245				var e = this.list().position();
246				return t.left && (t.left = e.left + s(t.left) + "px"), t.top && (t.top = e.top + s(t.top) + "px"), this.move(t, i)
247			},
248			move: function (i, s) {
249				s = s || {};
250				var e = this.options("transitions"),
251					r = !!e,
252					n = !!e.transforms,
253					o = !!e.transforms3d,
254					a = s.duration || 0,
255					l = this.list();
256				if (!r && a > 0) return l.animate(i, s), void 0;
257				var h = s.complete || t.noop,
258					u = {};
259				if (r) {
260					var c = l.css(["transitionDuration", "transitionTimingFunction", "transitionProperty"]),
261						f = h;
262					h = function () {
263						t(this).css(c), f.call(this)
264					}, u = {
265						transitionDuration: (a > 0 ? a / 1e3 : 0) + "s",
266						transitionTimingFunction: e.easing || s.easing,
267						transitionProperty: a > 0 ? function () {
268							return n || o ? "all" : i.left ? "left" : "top"
269						}() : "none",
270						transform: "none"
271					}
272				}
273				o ? u.transform = "translate3d(" + (i.left || 0) + "," + (i.top || 0) + ",0)" : n ? u.transform = "translate(" + (i.left || 0) + "," + (i.top || 0) + ")" : t.extend(u, i), r && a > 0 && l.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", h), l.css(u), 0 >= a && l.each(function () {
274					h.call(this)
275				})
276			},
277			_scroll: function (i, e, r) {
278				if (this.animating) return t.isFunction(r) && r.call(this, !1), this;
279				if ("object" != typeof i ? i = this.items().eq(i) : i.jquery === void 0 && (i = t(i)), 0 === i.size()) return t.isFunction(r) && r.call(this, !1), this;
280				this.inTail = !1, this._prepare(i);
281				var n = this._position(i),
282					o = s(this.list().position()[this.lt]);
283				if (n === o) return t.isFunction(r) && r.call(this, !1), this;
284				var a = {};
285				return a[this.lt] = n + "px", this._animate(a, e, r), this
286			},
287			_scrollTail: function (i, s) {
288				if (this.animating || !this.tail) return t.isFunction(s) && s.call(this, !1), this;
289				var e = this.list().position()[this.lt];
290				this.rtl ? e += this.tail : e -= this.tail, this.inTail = !0;
291				var r = {};
292				return r[this.lt] = e + "px", this._update({
293					target: this._target.next(),
294					fullyvisible: this._fullyvisible.slice(1).add(this._visible.last())
295				}), this._animate(r, i, s), this
296			},
297			_animate: function (i, s, e) {
298				if (e = e || t.noop, !1 === this._trigger("animate")) return e.call(this, !1), this;
299				this.animating = !0;
300				var r = this.options("animation"),
301					n = t.proxy(function () {
302						this.animating = !1;
303						var t = this.list().find("[data-jcarousel-clone]");
304						t.size() > 0 && (t.remove(), this._reload()), this._trigger("animateend"), e.call(this, !0)
305					}, this),
306					o = "object" == typeof r ? t.extend({}, r) : {
307						duration: r
308					}, a = o.complete || t.noop;
309				return s === !1 ? o.duration = 0 : t.fx.speeds[o.duration] !== void 0 && (o.duration = t.fx.speeds[o.duration]), o.complete = function () {
310					n(), a.call(this)
311				}, this.move(i, o), this
312			},
313			_prepare: function (i) {
314				var e, r, n, o = this.index(i),
315					a = o,
316					l = this.dimension(i),
317					h = this.clipping(),
318					u = this.vertical ? "bottom" : this.rtl ? "left" : "right",
319					c = this.options("center"),
320					f = {
321						target: i,
322						first: i,
323						last: i,
324						visible: i,
325						fullyvisible: h >= l ? i : t()
326					};
327				if (c && (l /= 2, h /= 2), h > l)
328					for (; ;) {
329						if (e = this.items().eq(++a), 0 === e.size()) {
330							if (!this.circular) break;
331							if (e = this.items().eq(0), r = this._visible.index(e) >= 0, i.get(0) === e.get(0)) break;
332							if (r && e.after(e.clone(!0).attr("data-jcarousel-clone", !0)), this.list().append(e), !r) {
333								var d = {};
334								d[this.lt] = this.dimension(e) * (this.rtl ? -1 : 1), this.moveBy(d)
335							}
336							this._items = null
337						}
338						if (l += this.dimension(e), f.last = e, f.visible = f.visible.add(e), n = s(e.css("margin-" + u)), h >= l - n && (f.fullyvisible = f.fullyvisible.add(e)), l >= h) break
339					}
340				if (!this.circular && !c && h > l)
341					for (a = o; ;) {
342						if (0 > --a) break;
343						if (e = this.items().eq(a), 0 === e.size()) break;
344						if (l += this.dimension(e), f.first = e, f.visible = f.visible.add(e), n = s(e.css("margin-" + u)), h >= l - n && (f.fullyvisible = f.fullyvisible.add(e)), l >= h) break
345					}
346				return this._update(f), this.tail = 0, c || "circular" === this.options("wrap") || "custom" === this.options("wrap") || this.index(f.last) !== this.items().size() - 1 || (l -= s(f.last.css("margin-" + u)), l > h && (this.tail = l - h)), this
347			},
348			_position: function (t) {
349				var i = this._first,
350					s = i.position()[this.lt],
351					e = this.options("center"),
352					r = e ? this.clipping() / 2 - this.dimension(i) / 2 : 0;
353				return this.rtl && !this.vertical ? (s -= this.clipping() - this.dimension(i), s += r) : s -= r, !e && (this.index(t) > this.index(i) || this.inTail) && this.tail ? (s = this.rtl ? s - this.tail : s + this.tail, this.inTail = !0) : this.inTail = !1, -s
354			},
355			_update: function (i) {
356				var s, e = this,
357					r = {
358						target: this._target || t(),
359						first: this._first || t(),
360						last: this._last || t(),
361						visible: this._visible || t(),
362						fullyvisible: this._fullyvisible || t()
363					}, n = this.index(i.first || r.first) < this.index(r.first),
364					o = function (s) {
365						var o = [],
366							a = [];
367						i[s].each(function () {
368							0 > r[s].index(this) && o.push(this)
369						}), r[s].each(function () {
370							0 > i[s].index(this) && a.push(this)
371						}), n ? o = o.reverse() : a = a.reverse(), e._trigger("item" + s + "in", t(o)), e._trigger("item" + s + "out", t(a)), e["_" + s] = i[s]
372					};
373				for (s in i) o(s);
374				return this
375			}
376		})
377	}(jQuery, window),
378	function (t) {
379		"use strict";
380		t.jcarousel.fn.scrollIntoView = function (i, s, e) {
381			var r, n = t.jCarousel.parseTarget(i),
382				o = this.index(this._fullyvisible.first()),
383				a = this.index(this._fullyvisible.last());
384			if (r = n.relative ? 0 > n.target ? Math.max(0, o + n.target) : a + n.target : "object" != typeof n.target ? n.target : this.index(n.target), o > r) return this.scroll(r, s, e);
385			if (r >= o && a >= r) return t.isFunction(e) && e.call(this, !1), this;
386			for (var l, h = this.items(), u = this.clipping(), c = this.vertical ? "bottom" : this.rtl ? "left" : "right", f = 0; ;) {
387				if (l = h.eq(r), 0 === l.size()) break;
388				if (f += this.dimension(l), f >= u) {
389					var d = parseFloat(l.css("margin-" + c)) || 0;
390					f - d !== u && r++;
391					break
392				}
393				if (0 >= r) break;
394				r--
395			}
396			return this.scroll(r, s, e)
397		}
398	}(jQuery),
399	function (t) {
400		"use strict";
401		t.jCarousel.plugin("jcarouselControl", {
402			_options: {
403				target: "+=1",
404				event: "click",
405				method: "scroll"
406			},
407			_active: null,
408			_init: function () {
409				this.onDestroy = t.proxy(function () {
410					this._destroy(), this.carousel().one("createend.jcarousel", t.proxy(this._create, this))
411				}, this), this.onReload = t.proxy(this._reload, this), this.onEvent = t.proxy(function (i) {
412					i.preventDefault();
413					var s = this.options("method");
414					t.isFunction(s) ? s.call(this) : this.carousel().jcarousel(this.options("method"), this.options("target"))
415				}, this)
416			},
417			_create: function () {
418				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()
419			},
420			_destroy: function () {
421				this._element.off(".jcarouselcontrol", this.onEvent), this.carousel().off("destroy.jcarousel", this.onDestroy).off("reloadend.jcarousel scrollend.jcarousel", this.onReload)
422			},
423			_reload: function () {
424				var i, s = t.jCarousel.parseTarget(this.options("target")),
425					e = this.carousel();
426				if (s.relative) i = e.jcarousel(s.target > 0 ? "hasNext" : "hasPrev");
427				else {
428					var r = "object" != typeof s.target ? e.jcarousel("items").eq(s.target) : s.target;
429					i = e.jcarousel("target").index(r) >= 0
430				}
431				return this._active !== i && (this._trigger(i ? "active" : "inactive"), this._active = i), this
432			}
433		})
434	}(jQuery),
435	function (t) {
436		"use strict";
437		t.jCarousel.plugin("jcarouselPagination", {
438			_options: {
439				perPage: null,
440				item: function (t) {
441					return '<a href="#' + t + '">' + t + "</a>"
442				},
443				event: "click",
444				method: "scroll"
445			},
446			_pages: {},
447			_items: {},
448			_currentPage: null,
449			_init: function () {
450				this.onDestroy = t.proxy(function () {
451					this._destroy(), this.carousel().one("createend.jcarousel", t.proxy(this._create, this))
452				}, this), this.onReload = t.proxy(this._reload, this), this.onScroll = t.proxy(this._update, this)
453			},
454			_create: function () {
455				this.carousel().one("destroy.jcarousel", this.onDestroy).on("reloadend.jcarousel", this.onReload).on("scrollend.jcarousel", this.onScroll), this._reload()
456			},
457			_destroy: function () {
458				this._clear(), this.carousel().off("destroy.jcarousel", this.onDestroy).off("reloadend.jcarousel", this.onReload).off("scrollend.jcarousel", this.onScroll)
459			},
460			_reload: function () {
461				var i = this.options("perPage");
462				if (this._pages = {}, this._items = {}, t.isFunction(i) && (i = i.call(this)), null == i) this._pages = this._calculatePages();
463				else
464					for (var s, e = parseInt(i, 10) || 0, r = this.carousel().jcarousel("items"), n = 1, o = 0; ;) {
465						if (s = r.eq(o++), 0 === s.size()) break;
466						this._pages[n] = this._pages[n] ? this._pages[n].add(s) : s, 0 === o % e && n++
467					}
468				this._clear();
469				var a = this,
470					l = this.carousel().data("jcarousel"),
471					h = this._element,
472					u = this.options("item");
473				t.each(this._pages, function (i, s) {
474					var e = a._items[i] = t(u.call(a, i, s));
475					e.on(a.options("event") + ".jcarouselpagination", t.proxy(function () {
476						var t = s.eq(0);
477						if (l.circular) {
478							var e = l.index(l.target()),
479								r = l.index(t);
480							parseFloat(i) > parseFloat(a._currentPage) ? e > r && (t = "+=" + (l.items().size() - e + r)) : r > e && (t = "-=" + (e + (l.items().size() - r)))
481						}
482						l[this.options("method")](t)
483					}, a)), h.append(e)
484				}), this._update()
485			},
486			_update: function () {
487				var i, s = this.carousel().jcarousel("target");
488				t.each(this._pages, function (t, e) {
489					return e.each(function () {
490						return s.is(this) ? (i = t, !1) : void 0
491					}), i ? !1 : void 0
492				}), this._currentPage !== i && (this._trigger("inactive", this._items[this._currentPage]), this._trigger("active", this._items[i])), this._currentPage = i
493			},
494			items: function () {
495				return this._items
496			},
497			_clear: function () {
498				this._element.empty(), this._currentPage = null
499			},
500			_calculatePages: function () {
501				for (var t, i = this.carousel().data("jcarousel"), s = i.items(), e = i.clipping(), r = 0, n = 0, o = 1, a = {}; ;) {
502					if (t = s.eq(n++), 0 === t.size()) break;
503					a[o] = a[o] ? a[o].add(t) : t, r += i.dimension(t), r >= e && (o++, r = 0)
504				}
505				return a
506			}
507		})
508	}(jQuery),
509	function (t) {
510		"use strict";
511		t.jCarousel.plugin("jcarouselAutoscroll", {
512			_options: {
513				target: "+=1",
514				interval: 3e3,
515				autostart: !0
516			},
517			_timer: null,
518			_init: function () {
519				this.onDestroy = t.proxy(function () {
520					this._destroy(), this.carousel().one("createend.jcarousel", t.proxy(this._create, this))
521				}, this), this.onAnimateEnd = t.proxy(this.start, this)
522			},
523			_create: function () {
524				this.carousel().one("destroy.jcarousel", this.onDestroy), this.options("autostart") && this.start()
525			},
526			_destroy: function () {
527				this.stop(), this.carousel().off("destroy.jcarousel", this.onDestroy)
528			},
529			start: function () {
530				return this.stop(), this.carousel().one("animateend.jcarousel", this.onAnimateEnd), this._timer = setTimeout(t.proxy(function () {
531					this.carousel().jcarousel("scroll", this.options("target"))
532				}, this), this.options("interval")), this
533			},
534			stop: function () {
535				return this._timer && (this._timer = clearTimeout(this._timer)), this.carousel().off("animateend.jcarousel", this.onAnimateEnd), this
536			}
537		})
538	}(jQuery);