; (function($) { var x = '2.73'; if ($.support == undefined) { $.support = { opacity: !($.browser.msie)} } function debug(s) { if ($.fn.cycle.debug) log(s) } function log() { if (window.console && window.console.log) window.console.log('[cycle] ' + Array.prototype.join.call(arguments, ' ')) }; $.fn.cycle = function(g, h) { var o = { s: this.selector, c: this.context }; if (this.length === 0 && g != 'stop') { if (!$.isReady && o.s) { log('DOM not ready, queuing slideshow'); $(function() { $(o.s, o.c).cycle(g, h) }); return this } log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); return this } return this.each(function() { var a = handleArguments(this, g, h); if (a === false) return; if (this.cycleTimeout) clearTimeout(this.cycleTimeout); this.cycleTimeout = this.cyclePause = 0; var b = $(this); var c = a.slideExpr ? $(a.slideExpr, this) : b.children(); var d = c.get(); if (d.length < 2) { log('terminating; too few slides: ' + d.length); return } var e = buildOptions(b, c, d, a, o); if (e === false) return; var f = e.continuous ? 10 : getTimeout(e.currSlide, e.nextSlide, e, !e.rev); if (f) { f += (e.delay || 0); if (f < 10) f = 10; debug('first timeout: ' + f); this.cycleTimeout = setTimeout(function() { go(d, e, 0, !e.rev) }, f) } }) }; function handleArguments(a, b, c) { if (a.cycleStop == undefined) a.cycleStop = 0; if (b === undefined || b === null) b = {}; if (b.constructor == String) { switch (b) { case 'stop': a.cycleStop++; if (a.cycleTimeout) clearTimeout(a.cycleTimeout); a.cycleTimeout = 0; $(a).removeData('cycle.opts'); return false; case 'pause': a.cyclePause = 1; return false; case 'resume': a.cyclePause = 0; if (c === true) { b = $(a).data('cycle.opts'); if (!b) { log('options not found, can not resume'); return false } if (a.cycleTimeout) { clearTimeout(a.cycleTimeout); a.cycleTimeout = 0 } go(b.elements, b, 1, 1) } return false; case 'prev': case 'next': var d = $(a).data('cycle.opts'); if (!d) { log('options not found, "prev/next" ignored'); return false } $.fn.cycle[b](d); return false; default: b = { fx: b} }; return b } else if (b.constructor == Number) { var e = b; b = $(a).data('cycle.opts'); if (!b) { log('options not found, can not advance slide'); return false } if (e < 0 || e >= b.elements.length) { log('invalid slide index: ' + e); return false } b.nextSlide = e; if (a.cycleTimeout) { clearTimeout(a.cycleTimeout); a.cycleTimeout = 0 } if (typeof c == 'string') b.oneTimeFx = c; go(b.elements, b, 1, e >= b.currSlide); return false } return b }; function removeFilter(a, b) { if (!$.support.opacity && b.cleartype && a.style.filter) { try { a.style.removeAttribute('filter') } catch (smother) { } } }; function buildOptions(f, g, k, l, o) { var m = $.extend({}, $.fn.cycle.defaults, l || {}, $.metadata ? f.metadata() : $.meta ? f.data() : {}); if (m.autostop) m.countdown = m.autostopCount || k.length; var n = f[0]; f.data('cycle.opts', m); m.$cont = f; m.stopCount = n.cycleStop; m.elements = k; m.before = m.before ? [m.before] : []; m.after = m.after ? [m.after] : []; m.after.unshift(function() { m.busy = 0 }); if (!$.support.opacity && m.cleartype) m.after.push(function() { removeFilter(this, m) }); if (m.continuous) m.after.push(function() { go(k, m, 0, !m.rev) }); saveOriginalOpts(m); if (!$.support.opacity && m.cleartype && !m.cleartypeNoBg) clearTypeFix(g); if (f.css('position') == 'static') f.css('position', 'relative'); if (m.width) f.width(m.width); if (m.height && m.height != 'auto') f.height(m.height); if (m.startingSlide) m.startingSlide = parseInt(m.startingSlide); if (m.random) { m.randomMap = []; for (var i = 0; i < k.length; i++) m.randomMap.push(i); m.randomMap.sort(function(a, b) { return Math.random() - 0.5 }); m.randomIndex = 0; m.startingSlide = m.randomMap[0] } else if (m.startingSlide >= k.length) m.startingSlide = 0; m.currSlide = m.startingSlide = m.startingSlide || 0; var p = m.startingSlide; g.css({ position: 'absolute', top: 0, left: 0 }).hide().each(function(i) { var z = p ? i >= p ? k.length - (i - p) : p - i : k.length - i; $(this).css('z-index', z) }); $(k[p]).css('opacity', 1).show(); removeFilter(k[p], m); if (m.fit && m.width) g.width(m.width); if (m.fit && m.height && m.height != 'auto') g.height(m.height); var q = m.containerResize && !f.innerHeight(); if (q) { var r = 0, maxh = 0; for (var j = 0; j < k.length; j++) { var s = $(k[j]), e = s[0], w = s.outerWidth(), h = s.outerHeight(); if (!w) w = e.offsetWidth; if (!h) h = e.offsetHeight; r = w > r ? w : r; maxh = h > maxh ? h : maxh } if (r > 0 && maxh > 0) f.css({ width: r + 'px', height: maxh + 'px' }) } if (m.pause) f.hover(function() { this.cyclePause++ }, function() { this.cyclePause-- }); if (supportMultiTransitions(m) === false) return false; var t = false; l.requeueAttempts = l.requeueAttempts || 0; g.each(function() { var a = $(this); this.cycleH = (m.fit && m.height) ? m.height : a.height(); this.cycleW = (m.fit && m.width) ? m.width : a.width(); if (a.is('img')) { var b = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); var c = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); var d = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); var e = (this.cycleH == 0 && this.cycleW == 0 && !this.complete); if (b || c || d || e) { if (o.s && m.requeueOnImageNotLoaded && ++l.requeueAttempts < 100) { log(l.requeueAttempts, ' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); setTimeout(function() { $(o.s, o.c).cycle(l) }, m.requeueTimeout); t = true; return false } else { log('could not determine size of image: ' + this.src, this.cycleW, this.cycleH) } } } return true }); if (t) return false; m.cssBefore = m.cssBefore || {}; m.animIn = m.animIn || {}; m.animOut = m.animOut || {}; g.not(':eq(' + p + ')').css(m.cssBefore); if (m.cssFirst) $(g[p]).css(m.cssFirst); if (m.timeout) { m.timeout = parseInt(m.timeout); if (m.speed.constructor == String) m.speed = $.fx.speeds[m.speed] || parseInt(m.speed); if (!m.sync) m.speed = m.speed / 2; while ((m.timeout - m.speed) < 250) m.timeout += m.speed } if (m.easing) m.easeIn = m.easeOut = m.easing; if (!m.speedIn) m.speedIn = m.speed; if (!m.speedOut) m.speedOut = m.speed; m.slideCount = k.length; m.currSlide = m.lastSlide = p; if (m.random) { m.nextSlide = m.currSlide; if (++m.randomIndex == k.length) m.randomIndex = 0; m.nextSlide = m.randomMap[m.randomIndex] } else m.nextSlide = m.startingSlide >= (k.length - 1) ? 0 : m.startingSlide + 1; if (!m.multiFx) { var u = $.fn.cycle.transitions[m.fx]; if ($.isFunction(u)) u(f, g, m); else if (m.fx != 'custom' && !m.multiFx) { log('unknown transition: ' + m.fx, '; slideshow terminating'); return false } } var v = g[p]; if (m.before.length) m.before[0].apply(v, [v, v, m, true]); if (m.after.length > 1) m.after[1].apply(v, [v, v, m, true]); if (m.next) $(m.next).bind(m.prevNextEvent, function() { return advance(m, m.rev ? -1 : 1) }); if (m.prev) $(m.prev).bind(m.prevNextEvent, function() { return advance(m, m.rev ? 1 : -1) }); if (m.pager) buildPager(k, m); exposeAddSlide(m, k); if (m.nowrap && m.currSlide <= 0) $(m.prev).hide(); if (m.nowrap && m.currSlide >= k.length - 1) $(m.next).hide(); return m }; function saveOriginalOpts(a) { a.original = { before: [], after: [] }; a.original.cssBefore = $.extend({}, a.cssBefore); a.original.cssAfter = $.extend({}, a.cssAfter); a.original.animIn = $.extend({}, a.animIn); a.original.animOut = $.extend({}, a.animOut); $.each(a.before, function() { a.original.before.push(this) }); $.each(a.after, function() { a.original.after.push(this) }) }; function supportMultiTransitions(a) { var i, tx, txs = $.fn.cycle.transitions; if (a.fx.indexOf(',') > 0) { a.multiFx = true; a.fxs = a.fx.replace(/\s*/g, '').split(','); for (i = 0; i < a.fxs.length; i++) { var b = a.fxs[i]; tx = txs[b]; if (!tx || !txs.hasOwnProperty(b) || !$.isFunction(tx)) { log('discarding unknown transition: ', b); a.fxs.splice(i, 1); i-- } } if (!a.fxs.length) { log('No valid transitions named; slideshow terminating.'); return false } } else if (a.fx == 'all') { a.multiFx = true; a.fxs = []; for (p in txs) { tx = txs[p]; if (txs.hasOwnProperty(p) && $.isFunction(tx)) a.fxs.push(p) } } if (a.multiFx && a.randomizeEffects) { var c = Math.floor(Math.random() * 20) + 30; for (i = 0; i < c; i++) { var d = Math.floor(Math.random() * a.fxs.length); a.fxs.push(a.fxs.splice(d, 1)[0]) } debug('randomized fx sequence: ', a.fxs) } return true }; function exposeAddSlide(d, e) { d.addSlide = function(a, b) { var c = $(a), s = c[0]; if (!d.autostopCount) d.countdown++; e[b ? 'unshift' : 'push'](s); if (d.els) d.els[b ? 'unshift' : 'push'](s); d.slideCount = e.length; c.css('position', 'absolute'); c[b ? 'prependTo' : 'appendTo'](d.$cont); if (b) { d.currSlide++; d.nextSlide++ } if (!$.support.opacity && d.cleartype && !d.cleartypeNoBg) clearTypeFix(c); if (d.fit && d.width) c.width(d.width); if (d.fit && d.height && d.height != 'auto') $slides.height(d.height); s.cycleH = (d.fit && d.height) ? d.height : c.height(); s.cycleW = (d.fit && d.width) ? d.width : c.width(); c.css(d.cssBefore); if (d.pager) $.fn.cycle.createPagerAnchor(e.length - 1, s, $(d.pager), e, d); if ($.isFunction(d.onAddSlide)) d.onAddSlide(c); else c.hide() } } $.fn.cycle.resetState = function(a, b) { b = b || a.fx; a.before = []; a.after = []; a.cssBefore = $.extend({}, a.original.cssBefore); a.cssAfter = $.extend({}, a.original.cssAfter); a.animIn = $.extend({}, a.original.animIn); a.animOut = $.extend({}, a.original.animOut); a.fxFn = null; $.each(a.original.before, function() { a.before.push(this) }); $.each(a.original.after, function() { a.after.push(this) }); var c = $.fn.cycle.transitions[b]; if ($.isFunction(c)) c(a.$cont, $(a.elements), a) }; function go(a, b, c, d) { if (c && b.busy && b.manualTrump) { $(a).stop(true, true); b.busy = false } if (b.busy) return; var p = b.$cont[0], curr = a[b.currSlide], next = a[b.nextSlide]; if (p.cycleStop != b.stopCount || p.cycleTimeout === 0 && !c) return; if (!c && !p.cyclePause && ((b.autostop && (--b.countdown <= 0)) || (b.nowrap && !b.random && b.nextSlide < b.currSlide))) { if (b.end) b.end(b); return } if (c || !p.cyclePause) { var e = b.fx; curr.cycleH = curr.cycleH || $(curr).height(); curr.cycleW = curr.cycleW || $(curr).width(); next.cycleH = next.cycleH || $(next).height(); next.cycleW = next.cycleW || $(next).width(); if (b.multiFx) { if (b.lastFx == undefined || ++b.lastFx >= b.fxs.length) b.lastFx = 0; e = b.fxs[b.lastFx]; b.currFx = e } if (b.oneTimeFx) { e = b.oneTimeFx; b.oneTimeFx = null } $.fn.cycle.resetState(b, e); if (b.before.length) $.each(b.before, function(i, o) { if (p.cycleStop != b.stopCount) return; o.apply(next, [curr, next, b, d]) }); var f = function() { $.each(b.after, function(i, o) { if (p.cycleStop != b.stopCount) return; o.apply(next, [curr, next, b, d]) }) }; if (b.nextSlide != b.currSlide) { b.busy = 1; if (b.fxFn) b.fxFn(curr, next, b, f, d); else if ($.isFunction($.fn.cycle[b.fx])) $.fn.cycle[b.fx](curr, next, b, f); else $.fn.cycle.custom(curr, next, b, f, c && b.fastOnEvent) } b.lastSlide = b.currSlide; if (b.random) { b.currSlide = b.nextSlide; if (++b.randomIndex == a.length) b.randomIndex = 0; b.nextSlide = b.randomMap[b.randomIndex] } else { var g = (b.nextSlide + 1) == a.length; b.nextSlide = g ? 0 : b.nextSlide + 1; b.currSlide = g ? a.length - 1 : b.nextSlide - 1 } if (b.pager) $.fn.cycle.updateActivePagerLink(b.pager, b.currSlide) } var h = 0; if (b.timeout && !b.continuous) h = getTimeout(curr, next, b, d); else if (b.continuous && p.cyclePause) h = 10; if (h > 0) p.cycleTimeout = setTimeout(function() { go(a, b, 0, !b.rev) }, h) }; $.fn.cycle.updateActivePagerLink = function(a, b) { $(a).each(function() { $(this).find('a').removeClass('activeSlide').filter('a:eq(' + b + ')').addClass('activeSlide') }) }; function getTimeout(a, b, c, d) { if (c.timeoutFn) { var t = c.timeoutFn(a, b, c, d); while ((t - c.speed) < 250) t += c.speed; debug('calculated timeout: ' + t + '; speed: ' + c.speed); if (t !== false) return t } return c.timeout }; $.fn.cycle.next = function(a) { advance(a, a.rev ? -1 : 1) }; $.fn.cycle.prev = function(a) { advance(a, a.rev ? 1 : -1) }; function advance(a, b) { var c = a.elements; var p = a.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0 } if (a.random && b < 0) { a.randomIndex--; if (--a.randomIndex == -2) a.randomIndex = c.length - 2; else if (a.randomIndex == -1) a.randomIndex = c.length - 1; a.nextSlide = a.randomMap[a.randomIndex] } else if (a.random) { if (++a.randomIndex == c.length) a.randomIndex = 0; a.nextSlide = a.randomMap[a.randomIndex] } else { a.nextSlide = a.currSlide + b; $(a.next).show(); $(a.prev).show(); if (a.nowrap && (a.nextSlide + b) < 0) $(a.prev).hide(); if ((a.nowrap && a.nextSlide + b) >= c.length) $(a.next).hide(); if (a.nextSlide < 0) { if (a.nowrap) return false; a.nextSlide = c.length - 1 } else if (a.nextSlide >= c.length) { if (a.nowrap) return false; a.nextSlide = 0 } } if ($.isFunction(a.prevNextClick)) a.prevNextClick(b > 0, a.nextSlide, c[a.nextSlide]); go(c, a, 1, b >= 0); return false }; function buildPager(a, b) { var c = $(b.pager); $.each(a, function(i, o) { $.fn.cycle.createPagerAnchor(i, o, c, a, b) }); $.fn.cycle.updateActivePagerLink(b.pager, b.startingSlide) }; $.fn.cycle.createPagerAnchor = function(i, b, c, d, f) { var a; if ($.isFunction(f.pagerAnchorBuilder)) a = f.pagerAnchorBuilder(i, b); else a = '<a href="#">' + (i + 1) + '</a>'; if (!a) return; var g = $(a); if (g.parents('body').length === 0) { var h = []; if (c.length > 1) { c.each(function() { var a = g.clone(true); $(this).append(a); h.push(a[0]) }); g = $(h) } else { g.appendTo(c) } } g.bind(f.pagerEvent, function(e) { e.preventDefault(); f.nextSlide = i; var p = f.$cont[0], timeout = p.cycleTimeout; if (timeout) { clearTimeout(timeout); p.cycleTimeout = 0 } if ($.isFunction(f.pagerClick)) f.pagerClick(f.nextSlide, d[f.nextSlide]); go(d, f, 1, f.currSlide < i); return false }); if (f.pagerEvent != 'click') g.click(function() { return false }); if (f.pauseOnPagerHover) g.hover(function() { f.$cont[0].cyclePause++ }, function() { f.$cont[0].cyclePause-- }) }; $.fn.cycle.hopsFromLast = function(a, b) { var d, l = a.lastSlide, c = a.currSlide; if (b) d = c > l ? c - l : a.slideCount - l; else d = c < l ? l - c : l + a.slideCount - c; return d }; function clearTypeFix(b) { function hex(s) { s = parseInt(s).toString(16); return s.length < 2 ? '0' + s : s }; function getBg(e) { for (; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { var v = $.css(e, 'background-color'); if (v.indexOf('rgb') >= 0) { var a = v.match(/\d+/g); return '#' + hex(a[0]) + hex(a[1]) + hex(a[2]) } if (v && v != 'transparent') return v } return '#ffffff' }; b.each(function() { $(this).css('background-color', getBg(this)) }) }; $.fn.cycle.commonReset = function(a, b, c, w, h, d) { $(c.elements).not(a).hide(); c.cssBefore.opacity = 1; c.cssBefore.display = 'block'; if (w !== false && b.cycleW > 0) c.cssBefore.width = b.cycleW; if (h !== false && b.cycleH > 0) c.cssBefore.height = b.cycleH; c.cssAfter = c.cssAfter || {}; c.cssAfter.display = 'none'; $(a).css('zIndex', c.slideCount + (d === true ? 1 : 0)); $(b).css('zIndex', c.slideCount + (d === true ? 0 : 1)) }; $.fn.cycle.custom = function(a, b, c, d, e) { var f = $(a), $n = $(b); var g = c.speedIn, speedOut = c.speedOut, easeIn = c.easeIn, easeOut = c.easeOut; $n.css(c.cssBefore); if (e) { if (typeof e == 'number') g = speedOut = e; else g = speedOut = 1; easeIn = easeOut = null } var h = function() { $n.animate(c.animIn, g, easeIn, d) }; f.animate(c.animOut, speedOut, easeOut, function() { if (c.cssAfter) f.css(c.cssAfter); if (!c.sync) h() }); if (c.sync) h() }; $.fn.cycle.transitions = { fade: function(d, e, f) { e.not(':eq(' + f.currSlide + ')').css('opacity', 0); f.before.push(function(a, b, c) { $.fn.cycle.commonReset(a, b, c); c.cssBefore.opacity = 0 }); f.animIn = { opacity: 1 }; f.animOut = { opacity: 0 }; f.cssBefore = { top: 0, left: 0} } }; $.fn.cycle.ver = function() { return x }; $.fn.cycle.defaults = { fx: 'fade', timeout: 4000, timeoutFn: null, continuous: 0, speed: 1000, speedIn: null, speedOut: null, next: null, prev: null, prevNextClick: null, prevNextEvent: 'click', pager: null, pagerClick: null, pagerEvent: 'click', pagerAnchorBuilder: null, before: null, after: null, end: null, easing: null, easeIn: null, easeOut: null, shuffle: null, animIn: null, animOut: null, cssBefore: null, cssAfter: null, fxFn: null, height: 'auto', startingSlide: 0, sync: 1, random: 0, fit: 0, containerResize: 1, pause: 0, pauseOnPagerHover: 0, autostop: 0, autostopCount: 0, delay: 0, slideExpr: null, cleartype: !$.support.opacity, cleartypeNoBg: false, nowrap: 0, fastOnEvent: 0, randomizeEffects: 1, rev: 0, manualTrump: true, requeueOnImageNotLoaded: true, requeueTimeout: 250} })(jQuery);