2  * jQuery Cycle Plugin (with Transition Definitions)
 
   3  * Examples and documentation at: http://jquery.malsup.com/cycle/
 
   4  * Copyright (c) 2007-2012 M. Alsup
 
   5  * Version: 2.9999.81 (15-JAN-2013)
 
   6  * Dual licensed under the MIT and GPL licenses.
 
   7  * http://jquery.malsup.com/license.html
 
   8  * Requires: jQuery v1.7.1 or later
 
  10 ;(function($, undefined) {
 
  13 var ver = '2.9999.81';
 
  20         if (window.console && console.log)
 
  21                 console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
 
  23 $.expr[':'].paused = function(el) {
 
  28 // the options arg can be...
 
  29 //   a number  - indicates an immediate transition should occur to the given slide index
 
  30 //   a string  - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
 
  31 //   an object - properties to control the slideshow
 
  33 // the arg2 arg can be...
 
  34 //   the name of an fx (only used in conjunction with a numeric value for 'options')
 
  35 //   the value true (only used in first arg == 'resume') and indicates
 
  36 //       that the resume should occur immediately (not wait for next timeout)
 
  38 $.fn.cycle = function(options, arg2) {
 
  39         var o = { s: this.selector, c: this.context };
 
  41         // in 1.3+ we can fix mistakes with the ready state
 
  42         if (this.length === 0 && options != 'stop') {
 
  43                 if (!$.isReady && o.s) {
 
  44                         log('DOM not ready, queuing slideshow');
 
  46                                 $(o.s,o.c).cycle(options,arg2);
 
  50                 // is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
 
  51                 log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
 
  55         // iterate the matched nodeset
 
  56         return this.each(function() {
 
  57                 var opts = handleArguments(this, options, arg2);
 
  61                 opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
 
  63                 // stop existing slideshow for this container (if there is one)
 
  64                 if (this.cycleTimeout)
 
  65                         clearTimeout(this.cycleTimeout);
 
  66                 this.cycleTimeout = this.cyclePause = 0;
 
  67                 this.cycleStop = 0; // issue #108
 
  70                 var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
 
  71                 var els = $slides.get();
 
  74                         log('terminating; too few slides: ' + els.length);
 
  78                 var opts2 = buildOptions($cont, $slides, els, opts, o);
 
  82                 var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);
 
  84                 // if it's an auto slideshow, kick it off
 
  86                         startTime += (opts2.delay || 0);
 
  89                         debug('first timeout: ' + startTime);
 
  90                         this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime);
 
  95 function triggerPause(cont, byHover, onPager) {
 
  96         var opts = $(cont).data('cycle.opts');
 
  99         var paused = !!cont.cyclePause;
 
 100         if (paused && opts.paused)
 
 101                 opts.paused(cont, opts, byHover, onPager);
 
 102         else if (!paused && opts.resumed)
 
 103                 opts.resumed(cont, opts, byHover, onPager);
 
 106 // process the args that were passed to the plugin fn
 
 107 function handleArguments(cont, options, arg2) {
 
 108         if (cont.cycleStop === undefined)
 
 110         if (options === undefined || options === null)
 
 112         if (options.constructor == String) {
 
 116                         var opts = $(cont).data('cycle.opts');
 
 119                         cont.cycleStop++; // callbacks look for change
 
 120                         if (cont.cycleTimeout)
 
 121                                 clearTimeout(cont.cycleTimeout);
 
 122                         cont.cycleTimeout = 0;
 
 124                                 $(opts.elements).stop();
 
 125                         $(cont).removeData('cycle.opts');
 
 126                         if (options == 'destroy')
 
 130                         cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
 
 131                         checkInstantResume(cont.cyclePause, arg2, cont);
 
 140                         checkInstantResume(false, arg2, cont);
 
 145                         opts = $(cont).data('cycle.opts');
 
 147                                 log('options not found, "prev/next" ignored');
 
 150                         $.fn.cycle[options](opts);
 
 153                         options = { fx: options };
 
 157         else if (options.constructor == Number) {
 
 158                 // go to the requested slide
 
 160                 options = $(cont).data('cycle.opts');
 
 162                         log('options not found, can not advance slide');
 
 165                 if (num < 0 || num >= options.elements.length) {
 
 166                         log('invalid slide index: ' + num);
 
 169                 options.nextSlide = num;
 
 170                 if (cont.cycleTimeout) {
 
 171                         clearTimeout(cont.cycleTimeout);
 
 172                         cont.cycleTimeout = 0;
 
 174                 if (typeof arg2 == 'string')
 
 175                         options.oneTimeFx = arg2;
 
 176                 go(options.elements, options, 1, num >= options.currSlide);
 
 181         function checkInstantResume(isPaused, arg2, cont) {
 
 182                 if (!isPaused && arg2 === true) { // resume now!
 
 183                         var options = $(cont).data('cycle.opts');
 
 185                                 log('options not found, can not resume');
 
 188                         if (cont.cycleTimeout) {
 
 189                                 clearTimeout(cont.cycleTimeout);
 
 190                                 cont.cycleTimeout = 0;
 
 192                         go(options.elements, options, 1, !options.backwards);
 
 197 function removeFilter(el, opts) {
 
 198         if (!$.support.opacity && opts.cleartype && el.style.filter) {
 
 199                 try { el.style.removeAttribute('filter'); }
 
 200                 catch(smother) {} // handle old opera versions
 
 204 // unbind event handlers
 
 205 function destroy(cont, opts) {
 
 207                 $(opts.next).unbind(opts.prevNextEvent);
 
 209                 $(opts.prev).unbind(opts.prevNextEvent);
 
 211         if (opts.pager || opts.pagerAnchorBuilder)
 
 212                 $.each(opts.pagerAnchors || [], function() {
 
 213                         this.unbind().remove();
 
 215         opts.pagerAnchors = null;
 
 216         $(cont).unbind('mouseenter.cycle mouseleave.cycle');
 
 217         if (opts.destroy) // callback
 
 221 // one-time initialization
 
 222 function buildOptions($cont, $slides, els, options, o) {
 
 223         var startingSlideSpecified;
 
 224         // support metadata plugin (v1.0 and v2.0)
 
 225         var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
 
 226         var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
 
 228                 opts = $.extend(opts, meta);
 
 230                 opts.countdown = opts.autostopCount || els.length;
 
 233         $cont.data('cycle.opts', opts);
 
 235         opts.stopCount = cont.cycleStop;
 
 237         opts.before = opts.before ? [opts.before] : [];
 
 238         opts.after = opts.after ? [opts.after] : [];
 
 240         // push some after callbacks
 
 241         if (!$.support.opacity && opts.cleartype)
 
 242                 opts.after.push(function() { removeFilter(this, opts); });
 
 244                 opts.after.push(function() { go(els,opts,0,!opts.backwards); });
 
 246         saveOriginalOpts(opts);
 
 248         // clearType corrections
 
 249         if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
 
 250                 clearTypeFix($slides);
 
 252         // container requires non-static position so that slides can be position within
 
 253         if ($cont.css('position') == 'static')
 
 254                 $cont.css('position', 'relative');
 
 256                 $cont.width(opts.width);
 
 257         if (opts.height && opts.height != 'auto')
 
 258                 $cont.height(opts.height);
 
 260         if (opts.startingSlide !== undefined) {
 
 261                 opts.startingSlide = parseInt(opts.startingSlide,10);
 
 262                 if (opts.startingSlide >= els.length || opts.startSlide < 0)
 
 263                         opts.startingSlide = 0; // catch bogus input
 
 265                         startingSlideSpecified = true;
 
 267         else if (opts.backwards)
 
 268                 opts.startingSlide = els.length - 1;
 
 270                 opts.startingSlide = 0;
 
 272         // if random, mix up the slide array
 
 275                 for (var i = 0; i < els.length; i++)
 
 276                         opts.randomMap.push(i);
 
 277                 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
 
 278                 if (startingSlideSpecified) {
 
 279                         // try to find the specified starting slide and if found set start slide index in the map accordingly
 
 280                         for ( var cnt = 0; cnt < els.length; cnt++ ) {
 
 281                                 if ( opts.startingSlide == opts.randomMap[cnt] ) {
 
 282                                         opts.randomIndex = cnt;
 
 287                         opts.randomIndex = 1;
 
 288                         opts.startingSlide = opts.randomMap[1];
 
 291         else if (opts.startingSlide >= els.length)
 
 292                 opts.startingSlide = 0; // catch bogus input
 
 293         opts.currSlide = opts.startingSlide || 0;
 
 294         var first = opts.startingSlide;
 
 296         // set position and zIndex on all the slides
 
 297         $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
 
 300                         z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
 
 302                         z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
 
 303                 $(this).css('z-index', z);
 
 306         // make sure first slide is visible
 
 307         $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
 
 308         removeFilter(els[first], opts);
 
 314                     $slides.width(opts.width);
 
 315                 if (opts.height && opts.height != 'auto')
 
 316                     $slides.height(opts.height);
 
 318                         $slides.each(function(){
 
 319                                 var $slide = $(this);
 
 320                                 var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
 
 321                                 if( opts.width && $slide.width() != opts.width ) {
 
 322                                         $slide.width( opts.width );
 
 323                                         $slide.height( opts.width / ratio );
 
 326                                 if( opts.height && $slide.height() < opts.height ) {
 
 327                                         $slide.height( opts.height );
 
 328                                         $slide.width( opts.height * ratio );
 
 334         if (opts.center && ((!opts.fit) || opts.aspect)) {
 
 335                 $slides.each(function(){
 
 336                         var $slide = $(this);
 
 338                                 "margin-left": opts.width ?
 
 339                                         ((opts.width - $slide.width()) / 2) + "px" :
 
 341                                 "margin-top": opts.height ?
 
 342                                         ((opts.height - $slide.height()) / 2) + "px" :
 
 348         if (opts.center && !opts.fit && !opts.slideResize) {
 
 349                 $slides.each(function(){
 
 350                         var $slide = $(this);
 
 352                                 "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
 
 353                                 "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
 
 359         var reshape = (opts.containerResize || opts.containerResizeHeight) && !$cont.innerHeight();
 
 360         if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
 
 361                 var maxw = 0, maxh = 0;
 
 362                 for(var j=0; j < els.length; j++) {
 
 363                         var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
 
 364                         if (!w) w = e.offsetWidth || e.width || $e.attr('width');
 
 365                         if (!h) h = e.offsetHeight || e.height || $e.attr('height');
 
 366                         maxw = w > maxw ? w : maxw;
 
 367                         maxh = h > maxh ? h : maxh;
 
 369                 if (opts.containerResize && maxw > 0 && maxh > 0)
 
 370                         $cont.css({width:maxw+'px',height:maxh+'px'});
 
 371                 if (opts.containerResizeHeight && maxh > 0)
 
 372                         $cont.css({height:maxh+'px'});
 
 375         var pauseFlag = false;  // https://github.com/malsup/cycle/issues/44
 
 377                 $cont.bind('mouseenter.cycle', function(){
 
 380                         triggerPause(cont, true);
 
 381                 }).bind('mouseleave.cycle', function(){
 
 384                                 triggerPause(cont, true);
 
 387         if (supportMultiTransitions(opts) === false)
 
 390         // apparently a lot of people use image slideshows without height/width attributes on the images.
 
 391         // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
 
 393         options.requeueAttempts = options.requeueAttempts || 0;
 
 394         $slides.each(function() {
 
 395                 // try to get height/width of each slide
 
 397                 this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
 
 398                 this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
 
 400                 if ( $el.is('img') ) {
 
 401                         var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete);
 
 402                         // don't requeue for images that are still loading but have a valid size
 
 404                                 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
 
 405                                         log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
 
 406                                         setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout);
 
 408                                         return false; // break each loop
 
 411                                         log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
 
 421         opts.cssBefore = opts.cssBefore || {};
 
 422         opts.cssAfter = opts.cssAfter || {};
 
 423         opts.cssFirst = opts.cssFirst || {};
 
 424         opts.animIn = opts.animIn || {};
 
 425         opts.animOut = opts.animOut || {};
 
 427         $slides.not(':eq('+first+')').css(opts.cssBefore);
 
 428         $($slides[first]).css(opts.cssFirst);
 
 431                 opts.timeout = parseInt(opts.timeout,10);
 
 432                 // ensure that timeout and speed settings are sane
 
 433                 if (opts.speed.constructor == String)
 
 434                         opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10);
 
 436                         opts.speed = opts.speed / 2;
 
 438                 var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
 
 439                 while((opts.timeout - opts.speed) < buffer) // sanitize timeout
 
 440                         opts.timeout += opts.speed;
 
 443                 opts.easeIn = opts.easeOut = opts.easing;
 
 445                 opts.speedIn = opts.speed;
 
 447                 opts.speedOut = opts.speed;
 
 449         opts.slideCount = els.length;
 
 450         opts.currSlide = opts.lastSlide = first;
 
 452                 if (++opts.randomIndex == els.length)
 
 453                         opts.randomIndex = 0;
 
 454                 opts.nextSlide = opts.randomMap[opts.randomIndex];
 
 456         else if (opts.backwards)
 
 457                 opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1;
 
 459                 opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
 
 461         // run transition init fn
 
 463                 var init = $.fn.cycle.transitions[opts.fx];
 
 464                 if ($.isFunction(init))
 
 465                         init($cont, $slides, opts);
 
 466                 else if (opts.fx != 'custom' && !opts.multiFx) {
 
 467                         log('unknown transition: ' + opts.fx,'; slideshow terminating');
 
 472         // fire artificial events
 
 473         var e0 = $slides[first];
 
 474         if (!opts.skipInitializationCallbacks) {
 
 475                 if (opts.before.length)
 
 476                         opts.before[0].apply(e0, [e0, e0, opts, true]);
 
 477                 if (opts.after.length)
 
 478                         opts.after[0].apply(e0, [e0, e0, opts, true]);
 
 481                 $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);});
 
 483                 $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);});
 
 484         if (opts.pager || opts.pagerAnchorBuilder)
 
 485                 buildPager(els,opts);
 
 487         exposeAddSlide(opts, els);
 
 492 // save off original opts so we can restore after clearing state
 
 493 function saveOriginalOpts(opts) {
 
 494         opts.original = { before: [], after: [] };
 
 495         opts.original.cssBefore = $.extend({}, opts.cssBefore);
 
 496         opts.original.cssAfter  = $.extend({}, opts.cssAfter);
 
 497         opts.original.animIn    = $.extend({}, opts.animIn);
 
 498         opts.original.animOut   = $.extend({}, opts.animOut);
 
 499         $.each(opts.before, function() { opts.original.before.push(this); });
 
 500         $.each(opts.after,  function() { opts.original.after.push(this); });
 
 503 function supportMultiTransitions(opts) {
 
 504         var i, tx, txs = $.fn.cycle.transitions;
 
 505         // look for multiple effects
 
 506         if (opts.fx.indexOf(',') > 0) {
 
 508                 opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
 
 509                 // discard any bogus effect names
 
 510                 for (i=0; i < opts.fxs.length; i++) {
 
 511                         var fx = opts.fxs[i];
 
 513                         if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
 
 514                                 log('discarding unknown transition: ',fx);
 
 515                                 opts.fxs.splice(i,1);
 
 519                 // if we have an empty list then we threw everything away!
 
 520                 if (!opts.fxs.length) {
 
 521                         log('No valid transitions named; slideshow terminating.');
 
 525         else if (opts.fx == 'all') {  // auto-gen the list of transitions
 
 529                         if (txs.hasOwnProperty(p)) {
 
 531                                 if (txs.hasOwnProperty(p) && $.isFunction(tx))
 
 536         if (opts.multiFx && opts.randomizeEffects) {
 
 537                 // munge the fxs array to make effect selection random
 
 538                 var r1 = Math.floor(Math.random() * 20) + 30;
 
 539                 for (i = 0; i < r1; i++) {
 
 540                         var r2 = Math.floor(Math.random() * opts.fxs.length);
 
 541                         opts.fxs.push(opts.fxs.splice(r2,1)[0]);
 
 543                 debug('randomized fx sequence: ',opts.fxs);
 
 548 // provide a mechanism for adding slides after the slideshow has started
 
 549 function exposeAddSlide(opts, els) {
 
 550         opts.addSlide = function(newSlide, prepend) {
 
 551                 var $s = $(newSlide), s = $s[0];
 
 552                 if (!opts.autostopCount)
 
 554                 els[prepend?'unshift':'push'](s);
 
 556                         opts.els[prepend?'unshift':'push'](s); // shuffle needs this
 
 557                 opts.slideCount = els.length;
 
 559                 // add the slide to the random map and resort
 
 561                         opts.randomMap.push(opts.slideCount-1);
 
 562                         opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
 
 565                 $s.css('position','absolute');
 
 566                 $s[prepend?'prependTo':'appendTo'](opts.$cont);
 
 573                 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
 
 576                 if (opts.fit && opts.width)
 
 577                         $s.width(opts.width);
 
 578                 if (opts.fit && opts.height && opts.height != 'auto')
 
 579                         $s.height(opts.height);
 
 580                 s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
 
 581                 s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
 
 583                 $s.css(opts.cssBefore);
 
 585                 if (opts.pager || opts.pagerAnchorBuilder)
 
 586                         $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
 
 588                 if ($.isFunction(opts.onAddSlide))
 
 591                         $s.hide(); // default behavior
 
 595 // reset internal state; we do this on every pass in order to support multiple effects
 
 596 $.fn.cycle.resetState = function(opts, fx) {
 
 598         opts.before = []; opts.after = [];
 
 599         opts.cssBefore = $.extend({}, opts.original.cssBefore);
 
 600         opts.cssAfter  = $.extend({}, opts.original.cssAfter);
 
 601         opts.animIn     = $.extend({}, opts.original.animIn);
 
 602         opts.animOut   = $.extend({}, opts.original.animOut);
 
 604         $.each(opts.original.before, function() { opts.before.push(this); });
 
 605         $.each(opts.original.after,  function() { opts.after.push(this); });
 
 608         var init = $.fn.cycle.transitions[fx];
 
 609         if ($.isFunction(init))
 
 610                 init(opts.$cont, $(opts.elements), opts);
 
 613 // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
 
 614 function go(els, opts, manual, fwd) {
 
 615         var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
 
 617         // opts.busy is true if we're in the middle of an animation
 
 618         if (manual && opts.busy && opts.manualTrump) {
 
 619                 // let manual transitions requests trump active ones
 
 620                 debug('manualTrump in go(), stopping active transition');
 
 621                 $(els).stop(true,true);
 
 623                 clearTimeout(p.cycleTimeout);
 
 626         // don't begin another timeout-based transition if there is one active
 
 628                 debug('transition active, ignoring new tx request');
 
 633         // stop cycling if we have an outstanding stop request
 
 634         if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
 
 637         // check to see if we should stop cycling based on autostop options
 
 638         if (!manual && !p.cyclePause && !opts.bounce &&
 
 639                 ((opts.autostop && (--opts.countdown <= 0)) ||
 
 640                 (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
 
 646         // if slideshow is paused, only transition on a manual trigger
 
 648         if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
 
 651                 // keep trying to get the slide size if we don't have it yet
 
 652                 curr.cycleH = curr.cycleH || $(curr).height();
 
 653                 curr.cycleW = curr.cycleW || $(curr).width();
 
 654                 next.cycleH = next.cycleH || $(next).height();
 
 655                 next.cycleW = next.cycleW || $(next).width();
 
 657                 // support multiple transition types
 
 659                         if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length))
 
 661                         else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0))
 
 662                                 opts.lastFx = opts.fxs.length - 1;
 
 663                         fx = opts.fxs[opts.lastFx];
 
 666                 // one-time fx overrides apply to:  $('div').cycle(3,'zoom');
 
 667                 if (opts.oneTimeFx) {
 
 669                         opts.oneTimeFx = null;
 
 672                 $.fn.cycle.resetState(opts, fx);
 
 674                 // run the before callbacks
 
 675                 if (opts.before.length)
 
 676                         $.each(opts.before, function(i,o) {
 
 677                                 if (p.cycleStop != opts.stopCount) return;
 
 678                                 o.apply(next, [curr, next, opts, fwd]);
 
 681                 // stage the after callacks
 
 682                 var after = function() {
 
 684                         $.each(opts.after, function(i,o) {
 
 685                                 if (p.cycleStop != opts.stopCount) return;
 
 686                                 o.apply(next, [curr, next, opts, fwd]);
 
 689                                 // queue next transition
 
 694                 debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
 
 696                 // get ready to perform the transition
 
 698                 if (opts.fxFn) // fx function provided?
 
 699                         opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
 
 700                 else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
 
 701                         $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
 
 703                         $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
 
 709         if (changed || opts.nextSlide == opts.currSlide) {
 
 710                 // calculate the next slide
 
 712                 opts.lastSlide = opts.currSlide;
 
 714                         opts.currSlide = opts.nextSlide;
 
 715                         if (++opts.randomIndex == els.length) {
 
 716                                 opts.randomIndex = 0;
 
 717                                 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
 
 719                         opts.nextSlide = opts.randomMap[opts.randomIndex];
 
 720                         if (opts.nextSlide == opts.currSlide)
 
 721                                 opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
 
 723                 else if (opts.backwards) {
 
 724                         roll = (opts.nextSlide - 1) < 0;
 
 725                         if (roll && opts.bounce) {
 
 726                                 opts.backwards = !opts.backwards;
 
 731                                 opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
 
 732                                 opts.currSlide = roll ? 0 : opts.nextSlide+1;
 
 736                         roll = (opts.nextSlide + 1) == els.length;
 
 737                         if (roll && opts.bounce) {
 
 738                                 opts.backwards = !opts.backwards;
 
 739                                 opts.nextSlide = els.length-2;
 
 740                                 opts.currSlide = els.length-1;
 
 743                                 opts.nextSlide = roll ? 0 : opts.nextSlide+1;
 
 744                                 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
 
 748         if (changed && opts.pager)
 
 749                 opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
 
 751         function queueNext() {
 
 752                 // stage the next transition
 
 753                 var ms = 0, timeout = opts.timeout;
 
 754                 if (opts.timeout && !opts.continuous) {
 
 755                         ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
 
 756          if (opts.fx == 'shuffle')
 
 759                 else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
 
 762                         p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms);
 
 766 // invoked after transition
 
 767 $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
 
 768    $(pager).each(function() {
 
 769        $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
 
 773 // calculate timeout value for current transition
 
 774 function getTimeout(curr, next, opts, fwd) {
 
 775         if (opts.timeoutFn) {
 
 776                 // call user provided calc fn
 
 777                 var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
 
 778                 while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
 
 780                 debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
 
 787 // expose next/prev function, caller must pass in state
 
 788 $.fn.cycle.next = function(opts) { advance(opts,1); };
 
 789 $.fn.cycle.prev = function(opts) { advance(opts,0);};
 
 791 // advance slide forward or back
 
 792 function advance(opts, moveForward) {
 
 793         var val = moveForward ? 1 : -1;
 
 794         var els = opts.elements;
 
 795         var p = opts.$cont[0], timeout = p.cycleTimeout;
 
 797                 clearTimeout(timeout);
 
 800         if (opts.random && val < 0) {
 
 801                 // move back to the previously display slide
 
 803                 if (--opts.randomIndex == -2)
 
 804                         opts.randomIndex = els.length-2;
 
 805                 else if (opts.randomIndex == -1)
 
 806                         opts.randomIndex = els.length-1;
 
 807                 opts.nextSlide = opts.randomMap[opts.randomIndex];
 
 809         else if (opts.random) {
 
 810                 opts.nextSlide = opts.randomMap[opts.randomIndex];
 
 813                 opts.nextSlide = opts.currSlide + val;
 
 814                 if (opts.nextSlide < 0) {
 
 815                         if (opts.nowrap) return false;
 
 816                         opts.nextSlide = els.length - 1;
 
 818                 else if (opts.nextSlide >= els.length) {
 
 819                         if (opts.nowrap) return false;
 
 824         var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
 
 825         if ($.isFunction(cb))
 
 826                 cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
 
 827         go(els, opts, 1, moveForward);
 
 831 function buildPager(els, opts) {
 
 832         var $p = $(opts.pager);
 
 833         $.each(els, function(i,o) {
 
 834                 $.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
 
 836         opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
 
 839 $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
 
 841         if ($.isFunction(opts.pagerAnchorBuilder)) {
 
 842                 a = opts.pagerAnchorBuilder(i,el);
 
 843                 debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
 
 846                 a = '<a href="#">'+(i+1)+'</a>';
 
 851         // don't reparent if anchor is in the dom
 
 852         if ($a.parents('body').length === 0) {
 
 856                                 var $clone = $a.clone(true);
 
 857                                 $(this).append($clone);
 
 867         opts.pagerAnchors =  opts.pagerAnchors || [];
 
 868         opts.pagerAnchors.push($a);
 
 870         var pagerFn = function(e) {
 
 873                 var p = opts.$cont[0], timeout = p.cycleTimeout;
 
 875                         clearTimeout(timeout);
 
 878                 var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
 
 879                 if ($.isFunction(cb))
 
 880                         cb(opts.nextSlide, els[opts.nextSlide]);
 
 881                 go(els,opts,1,opts.currSlide < i); // trigger the trans
 
 882 //              return false; // <== allow bubble
 
 885         if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) {
 
 886                 $a.hover(pagerFn, function(){/* no-op */} );
 
 889                 $a.bind(opts.pagerEvent, pagerFn);
 
 892         if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
 
 893                 $a.bind('click.cycle', function(){return false;}); // suppress click
 
 895         var cont = opts.$cont[0];
 
 896         var pauseFlag = false; // https://github.com/malsup/cycle/issues/44
 
 897         if (opts.pauseOnPagerHover) {
 
 902                                 triggerPause(cont,true,true);
 
 906                                 triggerPause(cont,true,true);
 
 912 // helper fn to calculate the number of slides between the current and the next
 
 913 $.fn.cycle.hopsFromLast = function(opts, fwd) {
 
 914         var hops, l = opts.lastSlide, c = opts.currSlide;
 
 916                 hops = c > l ? c - l : opts.slideCount - l;
 
 918                 hops = c < l ? l - c : l + opts.slideCount - c;
 
 922 // fix clearType problems in ie6 by setting an explicit bg color
 
 923 // (otherwise text slides look horrible during a fade transition)
 
 924 function clearTypeFix($slides) {
 
 925         debug('applying clearType background-color hack');
 
 927                 s = parseInt(s,10).toString(16);
 
 928                 return s.length < 2 ? '0'+s : s;
 
 931                 for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
 
 932                         var v = $.css(e,'background-color');
 
 933                         if (v && v.indexOf('rgb') >= 0 ) {
 
 934                                 var rgb = v.match(/\d+/g);
 
 935                                 return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
 
 937                         if (v && v != 'transparent')
 
 942         $slides.each(function() { $(this).css('background-color', getBg(this)); });
 
 945 // reset common props before the next transition
 
 946 $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
 
 947         $(opts.elements).not(curr).hide();
 
 948         if (typeof opts.cssBefore.opacity == 'undefined')
 
 949                 opts.cssBefore.opacity = 1;
 
 950         opts.cssBefore.display = 'block';
 
 951         if (opts.slideResize && w !== false && next.cycleW > 0)
 
 952                 opts.cssBefore.width = next.cycleW;
 
 953         if (opts.slideResize && h !== false && next.cycleH > 0)
 
 954                 opts.cssBefore.height = next.cycleH;
 
 955         opts.cssAfter = opts.cssAfter || {};
 
 956         opts.cssAfter.display = 'none';
 
 957         $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
 
 958         $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
 
 961 // the actual fn for effecting a transition
 
 962 $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
 
 963         var $l = $(curr), $n = $(next);
 
 964         var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
 
 965         $n.css(opts.cssBefore);
 
 967                 if (typeof speedOverride == 'number')
 
 968                         speedIn = speedOut = speedOverride;
 
 970                         speedIn = speedOut = 1;
 
 971                 easeIn = easeOut = null;
 
 973         var fn = function() {
 
 974                 $n.animate(opts.animIn, speedIn, easeIn, function() {
 
 978         $l.animate(opts.animOut, speedOut, easeOut, function() {
 
 979                 $l.css(opts.cssAfter);
 
 986 // transition definitions - only fade is defined here, transition pack defines the rest
 
 987 $.fn.cycle.transitions = {
 
 988         fade: function($cont, $slides, opts) {
 
 989                 $slides.not(':eq('+opts.currSlide+')').css('opacity',0);
 
 990                 opts.before.push(function(curr,next,opts) {
 
 991                         $.fn.cycle.commonReset(curr,next,opts);
 
 992                         opts.cssBefore.opacity = 0;
 
 994                 opts.animIn        = { opacity: 1 };
 
 995                 opts.animOut   = { opacity: 0 };
 
 996                 opts.cssBefore = { top: 0, left: 0 };
 
1000 $.fn.cycle.ver = function() { return ver; };
 
1002 // override these globally if you like (they are all optional)
 
1003 $.fn.cycle.defaults = {
 
1004     activePagerClass: 'activeSlide', // class name used for the active pager link
 
1005     after:            null,     // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
 
1006     allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
 
1007     animIn:           null,     // properties that define how the slide animates in
 
1008     animOut:          null,     // properties that define how the slide animates out
 
1009     aspect:           false,    // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option)
 
1010     autostop:         0,        // true to end slideshow after X transitions (where X == slide count)
 
1011     autostopCount:    0,        // number of transitions (optionally used with autostop to define X)
 
1012     backwards:        false,    // true to start slideshow at last slide and move backwards through the stack
 
1013     before:           null,     // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag)
 
1014     center:           null,     // set to true to have cycle add top/left margin to each slide (use with width and height options)
 
1015     cleartype:        !$.support.opacity,  // true if clearType corrections should be applied (for IE)
 
1016     cleartypeNoBg:    false,    // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
 
1017     containerResize:  1,        // resize container to fit largest slide
 
1018     containerResizeHeight:  0,  // resize containers height to fit the largest slide but leave the width dynamic
 
1019     continuous:       0,        // true to start next transition immediately after current one completes
 
1020     cssAfter:         null,     // properties that defined the state of the slide after transitioning out
 
1021     cssBefore:        null,     // properties that define the initial state of the slide before transitioning in
 
1022     delay:            0,        // additional delay (in ms) for first transition (hint: can be negative)
 
1023     easeIn:           null,     // easing for "in" transition
 
1024     easeOut:          null,     // easing for "out" transition
 
1025     easing:           null,     // easing method for both in and out transitions
 
1026     end:              null,     // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
 
1027     fastOnEvent:      0,        // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
 
1028     fit:              0,        // force slides to fit container
 
1029     fx:               'fade',   // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
 
1030     fxFn:             null,     // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
 
1031     height:           'auto',   // container height (if the 'fit' option is true, the slides will be set to this height as well)
 
1032     manualTrump:      true,     // causes manual transition to stop an active transition instead of being ignored
 
1033     metaAttr:         'cycle',  // data- attribute that holds the option data for the slideshow
 
1034     next:             null,     // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide
 
1035     nowrap:           0,        // true to prevent slideshow from wrapping
 
1036     onPagerEvent:     null,     // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
 
1037     onPrevNextEvent:  null,     // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
 
1038     pager:            null,     // element, jQuery object, or jQuery selector string for the element to use as pager container
 
1039     pagerAnchorBuilder: null,   // callback fn for building anchor links:  function(index, DOMelement)
 
1040     pagerEvent:       'click.cycle', // name of event which drives the pager navigation
 
1041     pause:            0,        // true to enable "pause on hover"
 
1042     pauseOnPagerHover: 0,       // true to pause when hovering over pager link
 
1043     prev:             null,     // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide
 
1044     prevNextEvent:    'click.cycle',// event which drives the manual transition to the previous or next slide
 
1045     random:           0,        // true for random, false for sequence (not applicable to shuffle fx)
 
1046     randomizeEffects: 1,        // valid when multiple effects are used; true to make the effect sequence random
 
1047     requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
 
1048     requeueTimeout:   250,      // ms delay for requeue
 
1049     rev:              0,        // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle)
 
1050     shuffle:          null,     // coords for shuffle animation, ex: { top:15, left: 200 }
 
1051     skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition
 
1052     slideExpr:        null,     // expression for selecting slides (if something other than all children is required)
 
1053     slideResize:      1,        // force slide width/height to fixed size before every transition
 
1054     speed:            1000,     // speed of the transition (any valid fx speed value)
 
1055     speedIn:          null,     // speed of the 'in' transition
 
1056     speedOut:         null,     // speed of the 'out' transition
 
1057     startingSlide:    undefined,// zero-based index of the first slide to be displayed
 
1058     sync:             1,        // true if in/out transitions should occur simultaneously
 
1059     timeout:          4000,     // milliseconds between slide transitions (0 to disable auto advance)
 
1060     timeoutFn:        null,     // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
 
1061     updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style)
 
1062     width:            null      // container width (if the 'fit' option is true, the slides will be set to this width as well)
 
1069  * jQuery Cycle Plugin Transition Definitions
 
1070  * This script is a plugin for the jQuery Cycle Plugin
 
1071  * Examples and documentation at: http://malsup.com/jquery/cycle/
 
1072  * Copyright (c) 2007-2010 M. Alsup
 
1074  * Dual licensed under the MIT and GPL licenses:
 
1075  * http://www.opensource.org/licenses/mit-license.php
 
1076  * http://www.gnu.org/licenses/gpl.html
 
1082 // These functions define slide initialization and properties for the named
 
1083 // transitions. To save file size feel free to remove any of these that you
 
1086 $.fn.cycle.transitions.none = function($cont, $slides, opts) {
 
1087         opts.fxFn = function(curr,next,opts,after){
 
1094 // not a cross-fade, fadeout only fades out the top slide
 
1095 $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
 
1096         $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 });
 
1097         opts.before.push(function(curr,next,opts,w,h,rev) {
 
1098                 $(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0));
 
1099                 $(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1));
 
1101         opts.animIn.opacity = 1;
 
1102         opts.animOut.opacity = 0;
 
1103         opts.cssBefore.opacity = 1;
 
1104         opts.cssBefore.display = 'block';
 
1105         opts.cssAfter.zIndex = 0;
 
1108 // scrollUp/Down/Left/Right
 
1109 $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
 
1110         $cont.css('overflow','hidden');
 
1111         opts.before.push($.fn.cycle.commonReset);
 
1112         var h = $cont.height();
 
1113         opts.cssBefore.top = h;
 
1114         opts.cssBefore.left = 0;
 
1115         opts.cssFirst.top = 0;
 
1116         opts.animIn.top = 0;
 
1117         opts.animOut.top = -h;
 
1119 $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
 
1120         $cont.css('overflow','hidden');
 
1121         opts.before.push($.fn.cycle.commonReset);
 
1122         var h = $cont.height();
 
1123         opts.cssFirst.top = 0;
 
1124         opts.cssBefore.top = -h;
 
1125         opts.cssBefore.left = 0;
 
1126         opts.animIn.top = 0;
 
1127         opts.animOut.top = h;
 
1129 $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
 
1130         $cont.css('overflow','hidden');
 
1131         opts.before.push($.fn.cycle.commonReset);
 
1132         var w = $cont.width();
 
1133         opts.cssFirst.left = 0;
 
1134         opts.cssBefore.left = w;
 
1135         opts.cssBefore.top = 0;
 
1136         opts.animIn.left = 0;
 
1137         opts.animOut.left = 0-w;
 
1139 $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
 
1140         $cont.css('overflow','hidden');
 
1141         opts.before.push($.fn.cycle.commonReset);
 
1142         var w = $cont.width();
 
1143         opts.cssFirst.left = 0;
 
1144         opts.cssBefore.left = -w;
 
1145         opts.cssBefore.top = 0;
 
1146         opts.animIn.left = 0;
 
1147         opts.animOut.left = w;
 
1149 $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
 
1150         $cont.css('overflow','hidden').width();
 
1151         opts.before.push(function(curr, next, opts, fwd) {
 
1154                 $.fn.cycle.commonReset(curr,next,opts);
 
1155                 opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
 
1156                 opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
 
1158         opts.cssFirst.left = 0;
 
1159         opts.cssBefore.top = 0;
 
1160         opts.animIn.left = 0;
 
1161         opts.animOut.top = 0;
 
1163 $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
 
1164         $cont.css('overflow','hidden');
 
1165         opts.before.push(function(curr, next, opts, fwd) {
 
1168                 $.fn.cycle.commonReset(curr,next,opts);
 
1169                 opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
 
1170                 opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
 
1172         opts.cssFirst.top = 0;
 
1173         opts.cssBefore.left = 0;
 
1174         opts.animIn.top = 0;
 
1175         opts.animOut.left = 0;
 
1179 $.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
 
1180         opts.before.push(function(curr, next, opts) {
 
1181                 $(opts.elements).not(curr).hide();
 
1182                 $.fn.cycle.commonReset(curr,next,opts,false,true);
 
1183                 opts.animIn.width = next.cycleW;
 
1185         opts.cssBefore.left = 0;
 
1186         opts.cssBefore.top = 0;
 
1187         opts.cssBefore.width = 0;
 
1188         opts.animIn.width = 'show';
 
1189         opts.animOut.width = 0;
 
1191 $.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
 
1192         opts.before.push(function(curr, next, opts) {
 
1193                 $(opts.elements).not(curr).hide();
 
1194                 $.fn.cycle.commonReset(curr,next,opts,true,false);
 
1195                 opts.animIn.height = next.cycleH;
 
1197         opts.cssBefore.left = 0;
 
1198         opts.cssBefore.top = 0;
 
1199         opts.cssBefore.height = 0;
 
1200         opts.animIn.height = 'show';
 
1201         opts.animOut.height = 0;
 
1205 $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
 
1206         var i, w = $cont.css('overflow', 'visible').width();
 
1207         $slides.css({left: 0, top: 0});
 
1208         opts.before.push(function(curr,next,opts) {
 
1209                 $.fn.cycle.commonReset(curr,next,opts,true,true,true);
 
1211         // only adjust speed once!
 
1212         if (!opts.speedAdjusted) {
 
1213                 opts.speed = opts.speed / 2; // shuffle has 2 transitions
 
1214                 opts.speedAdjusted = true;
 
1217         opts.shuffle = opts.shuffle || {left:-w, top:15};
 
1219         for (i=0; i < $slides.length; i++)
 
1220                 opts.els.push($slides[i]);
 
1222         for (i=0; i < opts.currSlide; i++)
 
1223                 opts.els.push(opts.els.shift());
 
1225         // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
 
1226         opts.fxFn = function(curr, next, opts, cb, fwd) {
 
1229                 var $el = fwd ? $(curr) : $(next);
 
1230                 $(next).css(opts.cssBefore);
 
1231                 var count = opts.slideCount;
 
1232                 $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
 
1233                         var hops = $.fn.cycle.hopsFromLast(opts, fwd);
 
1234                         for (var k=0; k < hops; k++) {
 
1236                                         opts.els.push(opts.els.shift());
 
1238                                         opts.els.unshift(opts.els.pop());
 
1241                                 for (var i=0, len=opts.els.length; i < len; i++)
 
1242                                         $(opts.els[i]).css('z-index', len-i+count);
 
1245                                 var z = $(curr).css('z-index');
 
1246                                 $el.css('z-index', parseInt(z,10)+1+count);
 
1248                         $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
 
1249                                 $(fwd ? this : curr).hide();
 
1254         $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
 
1257 // turnUp/Down/Left/Right
 
1258 $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
 
1259         opts.before.push(function(curr, next, opts) {
 
1260                 $.fn.cycle.commonReset(curr,next,opts,true,false);
 
1261                 opts.cssBefore.top = next.cycleH;
 
1262                 opts.animIn.height = next.cycleH;
 
1263                 opts.animOut.width = next.cycleW;
 
1265         opts.cssFirst.top = 0;
 
1266         opts.cssBefore.left = 0;
 
1267         opts.cssBefore.height = 0;
 
1268         opts.animIn.top = 0;
 
1269         opts.animOut.height = 0;
 
1271 $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
 
1272         opts.before.push(function(curr, next, opts) {
 
1273                 $.fn.cycle.commonReset(curr,next,opts,true,false);
 
1274                 opts.animIn.height = next.cycleH;
 
1275                 opts.animOut.top   = curr.cycleH;
 
1277         opts.cssFirst.top = 0;
 
1278         opts.cssBefore.left = 0;
 
1279         opts.cssBefore.top = 0;
 
1280         opts.cssBefore.height = 0;
 
1281         opts.animOut.height = 0;
 
1283 $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
 
1284         opts.before.push(function(curr, next, opts) {
 
1285                 $.fn.cycle.commonReset(curr,next,opts,false,true);
 
1286                 opts.cssBefore.left = next.cycleW;
 
1287                 opts.animIn.width = next.cycleW;
 
1289         opts.cssBefore.top = 0;
 
1290         opts.cssBefore.width = 0;
 
1291         opts.animIn.left = 0;
 
1292         opts.animOut.width = 0;
 
1294 $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
 
1295         opts.before.push(function(curr, next, opts) {
 
1296                 $.fn.cycle.commonReset(curr,next,opts,false,true);
 
1297                 opts.animIn.width = next.cycleW;
 
1298                 opts.animOut.left = curr.cycleW;
 
1300         $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
 
1301         opts.animIn.left = 0;
 
1302         opts.animOut.width = 0;
 
1306 $.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
 
1307         opts.before.push(function(curr, next, opts) {
 
1308                 $.fn.cycle.commonReset(curr,next,opts,false,false,true);
 
1309                 opts.cssBefore.top = next.cycleH/2;
 
1310                 opts.cssBefore.left = next.cycleW/2;
 
1311                 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
 
1312                 $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
 
1314         opts.cssFirst.top = 0;
 
1315         opts.cssFirst.left = 0;
 
1316         opts.cssBefore.width = 0;
 
1317         opts.cssBefore.height = 0;
 
1321 $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
 
1322         opts.before.push(function(curr, next, opts) {
 
1323                 $.fn.cycle.commonReset(curr,next,opts,false,false);
 
1324                 opts.cssBefore.left = next.cycleW/2;
 
1325                 opts.cssBefore.top = next.cycleH/2;
 
1326                 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
 
1328         opts.cssBefore.width = 0;
 
1329         opts.cssBefore.height = 0;
 
1330         opts.animOut.opacity = 0;
 
1334 $.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
 
1335         var w = $cont.css('overflow','hidden').width();
 
1336         opts.before.push(function(curr, next, opts) {
 
1337                 $.fn.cycle.commonReset(curr,next,opts);
 
1338                 opts.animIn.width = next.cycleW;
 
1339                 opts.animOut.left   = curr.cycleW;
 
1341         opts.cssBefore.left = w;
 
1342         opts.cssBefore.top = 0;
 
1343         opts.animIn.left = 0;
 
1344         opts.animOut.left = w;
 
1347 $.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
 
1348         var h = $cont.css('overflow','hidden').height();
 
1349         opts.before.push(function(curr, next, opts) {
 
1350                 $.fn.cycle.commonReset(curr,next,opts);
 
1351                 opts.animIn.height = next.cycleH;
 
1352                 opts.animOut.top   = curr.cycleH;
 
1354         opts.cssBefore.top = h;
 
1355         opts.cssBefore.left = 0;
 
1356         opts.animIn.top = 0;
 
1357         opts.animOut.top = h;
 
1360 $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
 
1361         var h = $cont.css('overflow','hidden').height();
 
1362         var w = $cont.width();
 
1363         opts.before.push(function(curr, next, opts) {
 
1364                 $.fn.cycle.commonReset(curr,next,opts);
 
1365                 opts.animIn.height = next.cycleH;
 
1366                 opts.animOut.top   = curr.cycleH;
 
1368         opts.cssBefore.top = h;
 
1369         opts.cssBefore.left = w;
 
1370         opts.animIn.top = 0;
 
1371         opts.animIn.left = 0;
 
1372         opts.animOut.top = h;
 
1373         opts.animOut.left = w;
 
1376 // growX - grow horizontally from centered 0 width
 
1377 $.fn.cycle.transitions.growX = function($cont, $slides, opts) {
 
1378         opts.before.push(function(curr, next, opts) {
 
1379                 $.fn.cycle.commonReset(curr,next,opts,false,true);
 
1380                 opts.cssBefore.left = this.cycleW/2;
 
1381                 opts.animIn.left = 0;
 
1382                 opts.animIn.width = this.cycleW;
 
1383                 opts.animOut.left = 0;
 
1385         opts.cssBefore.top = 0;
 
1386         opts.cssBefore.width = 0;
 
1388 // growY - grow vertically from centered 0 height
 
1389 $.fn.cycle.transitions.growY = function($cont, $slides, opts) {
 
1390         opts.before.push(function(curr, next, opts) {
 
1391                 $.fn.cycle.commonReset(curr,next,opts,true,false);
 
1392                 opts.cssBefore.top = this.cycleH/2;
 
1393                 opts.animIn.top = 0;
 
1394                 opts.animIn.height = this.cycleH;
 
1395                 opts.animOut.top = 0;
 
1397         opts.cssBefore.height = 0;
 
1398         opts.cssBefore.left = 0;
 
1401 // curtainX - squeeze in both edges horizontally
 
1402 $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
 
1403         opts.before.push(function(curr, next, opts) {
 
1404                 $.fn.cycle.commonReset(curr,next,opts,false,true,true);
 
1405                 opts.cssBefore.left = next.cycleW/2;
 
1406                 opts.animIn.left = 0;
 
1407                 opts.animIn.width = this.cycleW;
 
1408                 opts.animOut.left = curr.cycleW/2;
 
1409                 opts.animOut.width = 0;
 
1411         opts.cssBefore.top = 0;
 
1412         opts.cssBefore.width = 0;
 
1414 // curtainY - squeeze in both edges vertically
 
1415 $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
 
1416         opts.before.push(function(curr, next, opts) {
 
1417                 $.fn.cycle.commonReset(curr,next,opts,true,false,true);
 
1418                 opts.cssBefore.top = next.cycleH/2;
 
1419                 opts.animIn.top = 0;
 
1420                 opts.animIn.height = next.cycleH;
 
1421                 opts.animOut.top = curr.cycleH/2;
 
1422                 opts.animOut.height = 0;
 
1424         opts.cssBefore.height = 0;
 
1425         opts.cssBefore.left = 0;
 
1428 // cover - curr slide covered by next slide
 
1429 $.fn.cycle.transitions.cover = function($cont, $slides, opts) {
 
1430         var d = opts.direction || 'left';
 
1431         var w = $cont.css('overflow','hidden').width();
 
1432         var h = $cont.height();
 
1433         opts.before.push(function(curr, next, opts) {
 
1434                 $.fn.cycle.commonReset(curr,next,opts);
 
1435                 opts.cssAfter.display = '';
 
1437                         opts.cssBefore.left = -w;
 
1439                         opts.cssBefore.top = h;
 
1440                 else if (d == 'down')
 
1441                         opts.cssBefore.top = -h;
 
1443                         opts.cssBefore.left = w;
 
1445         opts.animIn.left = 0;
 
1446         opts.animIn.top = 0;
 
1447         opts.cssBefore.top = 0;
 
1448         opts.cssBefore.left = 0;
 
1451 // uncover - curr slide moves off next slide
 
1452 $.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
 
1453         var d = opts.direction || 'left';
 
1454         var w = $cont.css('overflow','hidden').width();
 
1455         var h = $cont.height();
 
1456         opts.before.push(function(curr, next, opts) {
 
1457                 $.fn.cycle.commonReset(curr,next,opts,true,true,true);
 
1459                         opts.animOut.left = w;
 
1461                         opts.animOut.top = -h;
 
1462                 else if (d == 'down')
 
1463                         opts.animOut.top = h;
 
1465                         opts.animOut.left = -w;
 
1467         opts.animIn.left = 0;
 
1468         opts.animIn.top = 0;
 
1469         opts.cssBefore.top = 0;
 
1470         opts.cssBefore.left = 0;
 
1473 // toss - move top slide and fade away
 
1474 $.fn.cycle.transitions.toss = function($cont, $slides, opts) {
 
1475         var w = $cont.css('overflow','visible').width();
 
1476         var h = $cont.height();
 
1477         opts.before.push(function(curr, next, opts) {
 
1478                 $.fn.cycle.commonReset(curr,next,opts,true,true,true);
 
1479                 // provide default toss settings if animOut not provided
 
1480                 if (!opts.animOut.left && !opts.animOut.top)
 
1481                         $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
 
1483                         opts.animOut.opacity = 0;
 
1485         opts.cssBefore.left = 0;
 
1486         opts.cssBefore.top = 0;
 
1487         opts.animIn.left = 0;
 
1490 // wipe - clip animation
 
1491 $.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
 
1492         var w = $cont.css('overflow','hidden').width();
 
1493         var h = $cont.height();
 
1494         opts.cssBefore = opts.cssBefore || {};
 
1497                 if (/l2r/.test(opts.clip))
 
1498                         clip = 'rect(0px 0px '+h+'px 0px)';
 
1499                 else if (/r2l/.test(opts.clip))
 
1500                         clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
 
1501                 else if (/t2b/.test(opts.clip))
 
1502                         clip = 'rect(0px '+w+'px 0px 0px)';
 
1503                 else if (/b2t/.test(opts.clip))
 
1504                         clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
 
1505                 else if (/zoom/.test(opts.clip)) {
 
1506                         var top = parseInt(h/2,10);
 
1507                         var left = parseInt(w/2,10);
 
1508                         clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
 
1512         opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';
 
1514         var d = opts.cssBefore.clip.match(/(\d+)/g);
 
1515         var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10);
 
1517         opts.before.push(function(curr, next, opts) {
 
1518                 if (curr == next) return;
 
1519                 var $curr = $(curr), $next = $(next);
 
1520                 $.fn.cycle.commonReset(curr,next,opts,true,true,false);
 
1521                 opts.cssAfter.display = 'block';
 
1523                 var step = 1, count = parseInt((opts.speedIn / 13),10) - 1;
 
1525                         var tt = t ? t - parseInt(step * (t/count),10) : 0;
 
1526                         var ll = l ? l - parseInt(step * (l/count),10) : 0;
 
1527                         var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h;
 
1528                         var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w;
 
1529                         $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
 
1530                         (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
 
1533         $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
 
1534         opts.animIn        = { left: 0 };
 
1535         opts.animOut   = { left: 0 };