//window.log = function(){
//  log.history = log.history || [];
//  log.history.push(arguments);
//  arguments.callee = arguments.callee.caller;
//  if(this.console) console.log( Array.prototype.slice.call(arguments) );
//};
//(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


/*!
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.9993 (26-MAY-2011)
 * Dual licensed under the MIT and GPL licenses.
 * http://jquery.malsup.com/license.html
 * Requires: jQuery v1.3.2 or later
 */
(function($) {

  var ver = '2.9992';

  // if $.support is not defined (pre jQuery 1.3) add what I need
  if ($.support == undefined) {
    $.support = {
      opacity: !($.browser.msie)
    };
  }

  function debug(s) {
    $.fn.cycle.debug && log(s);
  }
  function log() {
    window.console && console.log && console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
  }
  $.expr[':'].paused = function(el) {
    return el.cyclePause;
  }


  // the options arg can be...
  //   a number  - indicates an immediate transition should occur to the given slide index
  //   a string  - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
  //   an object - properties to control the slideshow
  //
  // the arg2 arg can be...
  //   the name of an fx (only used in conjunction with a numeric value for 'options')
  //   the value true (only used in first arg == 'resume') and indicates
  //	 that the resume should occur immediately (not wait for next timeout)

  $.fn.cycle = function(options, arg2) {
	
    var o = { s: this.selector, c: this.context };

    // in 1.3+ we can fix mistakes with the ready state
    if (this.length === 0 && options != 'stop') {
      if (!$.isReady && o.s) {
        log('DOM not ready, queuing slideshow');
        $(function() {
          $(o.s,o.c).cycle(options,arg2);
        });
        return this;
      }
      // is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
      log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
      return this;
    }

    // iterate the matched nodeset
    return this.each(function() {
      var opts = handleArguments(this, options, arg2);
      if (opts === false)
        return;

      opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;

      // stop existing slideshow for this container (if there is one)
      if (this.cycleTimeout)
        clearTimeout(this.cycleTimeout);
      this.cycleTimeout = this.cyclePause = 0;

      var $cont = $(this);
      var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
      var els = $slides.get();

      var opts2 = buildOptions($cont, $slides, els, opts, o);
      if (opts2 === false)
        return;

      if (els.length < 2) {
        log('terminating; too few slides: ' + els.length);
        return;
      }

      var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);

      // if it's an auto slideshow, kick it off
      if (startTime) {
        startTime += (opts2.delay || 0);
        if (startTime < 10)
          startTime = 10;
        debug('first timeout: ' + startTime);
        this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards)}, startTime);
      }
    });
  };

  function triggerPause(cont, byHover, onPager) {
    var opts = $(cont).data('cycle.opts');
    var paused = !!cont.cyclePause;
    if (paused && opts.paused)
      opts.paused(cont, opts, byHover, onPager);
    else if (!paused && opts.resumed)
      opts.resumed(cont, opts, byHover, onPager);
  }

  // process the args that were passed to the plugin fn
  function handleArguments(cont, options, arg2) {
    if (cont.cycleStop == undefined)
      cont.cycleStop = 0;
    if (options === undefined || options === null)
      options = {};
    if (options.constructor == String) {
      switch(options) {
        case 'destroy':
        case 'stop':
          var opts = $(cont).data('cycle.opts');
          if (!opts)
            return false;
          cont.cycleStop++; // callbacks look for change
          if (cont.cycleTimeout)
            clearTimeout(cont.cycleTimeout);
          cont.cycleTimeout = 0;
          opts.elements && $(opts.elements).stop();
          $(cont).removeData('cycle.opts');
          if (options == 'destroy')
            destroy(opts);
          return false;
        case 'toggle':
          cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
          checkInstantResume(cont.cyclePause, arg2, cont);
          triggerPause(cont);
          return false;
        case 'pause':
          cont.cyclePause = 1;
          triggerPause(cont);
          return false;
        case 'resume':
          cont.cyclePause = 0;
          checkInstantResume(false, arg2, cont);
          triggerPause(cont);
          return false;
        case 'prev':
        case 'next':
          var opts = $(cont).data('cycle.opts');
          if (!opts) {
            log('options not found, "prev/next" ignored');
            return false;
          }
          $.fn.cycle[options](opts);
          return false;
        default:
          options = { fx: options };
      };
      return options;
    }
    else if (options.constructor == Number) {
      // go to the requested slide
      var num = options;
      options = $(cont).data('cycle.opts');
      if (!options) {
        log('options not found, can not advance slide');
        return false;
      }
      if (num < 0 || num >= options.elements.length) {
        log('invalid slide index: ' + num);
        return false;
      }
      options.nextSlide = num;
      if (cont.cycleTimeout) {
        clearTimeout(cont.cycleTimeout);
        cont.cycleTimeout = 0;
      }
      if (typeof arg2 == 'string')
        options.oneTimeFx = arg2;
      go(options.elements, options, 1, num >= options.currSlide);
      return false;
    }
    return options;

    function checkInstantResume(isPaused, arg2, cont) {
      if (!isPaused && arg2 === true) { // resume now!
        var options = $(cont).data('cycle.opts');
        if (!options) {
          log('options not found, can not resume');
          return false;
        }
        if (cont.cycleTimeout) {
          clearTimeout(cont.cycleTimeout);
          cont.cycleTimeout = 0;
        }
        go(options.elements, options, 1, !options.backwards);
      }
    }
  };

  function removeFilter(el, opts) {
    if (!$.support.opacity && opts.cleartype && el.style.filter) {
      try { el.style.removeAttribute('filter'); }
      catch(smother) {} // handle old opera versions
    }
  };

  // unbind event handlers
  function destroy(opts) {
    if (opts.next)
      $(opts.next).unbind(opts.prevNextEvent);
    if (opts.prev)
      $(opts.prev).unbind(opts.prevNextEvent);

    if (opts.pager || opts.pagerAnchorBuilder)
      $.each(opts.pagerAnchors || [], function() {
        this.unbind().remove();
      });
    opts.pagerAnchors = null;
    if (opts.destroy) // callback
      opts.destroy(opts);
  };

  // one-time initialization
  function buildOptions($cont, $slides, els, options, o) {
    // support metadata plugin (v1.0 and v2.0)
    var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
    var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
    if (meta)
      opts = $.extend(opts, meta);
    if (opts.autostop)
      opts.countdown = opts.autostopCount || els.length;

    var cont = $cont[0];
    $cont.data('cycle.opts', opts);
    opts.$cont = $cont;
    opts.stopCount = cont.cycleStop;
    opts.elements = els;
    opts.before = opts.before ? [opts.before] : [];
    opts.after = opts.after ? [opts.after] : [];

    // push some after callbacks
    if (!$.support.opacity && opts.cleartype)
      opts.after.push(function() { removeFilter(this, opts); });
    if (opts.continuous)
      opts.after.push(function() { go(els,opts,0,!opts.backwards); });

    saveOriginalOpts(opts);

    // clearType corrections
    if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
      clearTypeFix($slides);

    // container requires non-static position so that slides can be position within
    if ($cont.css('position') == 'static')
      $cont.css('position', 'relative');
    if (opts.width)
      $cont.width(opts.width);
    if (opts.height && opts.height != 'auto')
      $cont.height(opts.height);

    if (opts.startingSlide)
      opts.startingSlide = parseInt(opts.startingSlide,10);
    else if (opts.backwards)
      opts.startingSlide = els.length - 1;

    // if random, mix up the slide array
    if (opts.random) {
      opts.randomMap = [];
      for (var i = 0; i < els.length; i++)
        opts.randomMap.push(i);
      opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
      opts.randomIndex = 1;
      opts.startingSlide = opts.randomMap[1];
    }
    else if (opts.startingSlide >= els.length)
      opts.startingSlide = 0; // catch bogus input
    opts.currSlide = opts.startingSlide || 0;
    var first = opts.startingSlide;

    // set position and zIndex on all the slides
    $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
      var z;
      if (opts.backwards)
        z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
      else
        z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
      $(this).css('z-index', z)
    });

    // make sure first slide is visible
    $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
    removeFilter(els[first], opts);

    // stretch slides
    if (opts.fit) {
      if (!opts.aspect) {
        if (opts.width)
          $slides.width(opts.width);
        if (opts.height && opts.height != 'auto')
          $slides.height(opts.height);
      } else {
        $slides.each(function(){
          var $slide = $(this);
          var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
          if( opts.width && $slide.width() != opts.width ) {
            $slide.width( opts.width );
            $slide.height( opts.width / ratio );
          }

          if( opts.height && $slide.height() < opts.height ) {
            $slide.height( opts.height );
            $slide.width( opts.height * ratio );
          }
        });
      }
    }

    if (opts.center && ((!opts.fit) || opts.aspect)) {
      $slides.each(function(){
        var $slide = $(this);
        $slide.css({
          "margin-left": opts.width ?
            ((opts.width - $slide.width()) / 2) + "px" :
            0,
          "margin-top": opts.height ?
            ((opts.height - $slide.height()) / 2) + "px" :
            0
        });
      });
    }

    if (opts.center && !opts.fit && !opts.slideResize) {
      $slides.each(function(){
        var $slide = $(this);
        $slide.css({
          "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
          "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
        });
      });
    }

    // stretch container
    var reshape = opts.containerResize && !$cont.innerHeight();
    if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
      var maxw = 0, maxh = 0;
      for(var j=0; j < els.length; j++) {
        var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
        if (!w) w = e.offsetWidth || e.width || $e.attr('width');
        if (!h) h = e.offsetHeight || e.height || $e.attr('height');
        maxw = w > maxw ? w : maxw;
        maxh = h > maxh ? h : maxh;
      }
      if (maxw > 0 && maxh > 0)
        $cont.css({width:maxw+'px',height:maxh+'px'});
    }

    var pauseFlag = false;  // https://github.com/malsup/cycle/issues/44
    if (opts.pause)
      $cont.hover(
        function(){
          pauseFlag = true;
          this.cyclePause++;
          triggerPause(cont, true);
        },
        function(){
          pauseFlag && this.cyclePause--;
          triggerPause(cont, true);
        }
      );

    if (supportMultiTransitions(opts) === false)
      return false;

    // apparently a lot of people use image slideshows without height/width attributes on the images.
    // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
    var requeue = false;
    options.requeueAttempts = options.requeueAttempts || 0;
    $slides.each(function() {
      // try to get height/width of each slide
      var $el = $(this);
      this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
      this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);

      if ( $el.is('img') ) {
        // sigh..  sniffing, hacking, shrugging...  this crappy hack tries to account for what browsers do when
        // an image is being downloaded and the markup did not include sizing info (height/width attributes);
        // there seems to be some "default" sizes used in this situation
        var loadingIE	= ($.browser.msie  && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
        var loadingFF	= ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
        var loadingOp	= ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
        var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
        // don't requeue for images that are still loading but have a valid size
        if (loadingIE || loadingFF || loadingOp || loadingOther) {
          if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
            log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
            setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
            requeue = true;
            return false; // break each loop
          }
          else {
            log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
          }
        }
      }
      return true;
    });

    if (requeue)
      return false;

    opts.cssBefore = opts.cssBefore || {};
    opts.cssAfter = opts.cssAfter || {};
    opts.cssFirst = opts.cssFirst || {};
    opts.animIn = opts.animIn || {};
    opts.animOut = opts.animOut || {};

    $slides.not(':eq('+first+')').css(opts.cssBefore);
    $($slides[first]).css(opts.cssFirst);

    if (opts.timeout) {
      opts.timeout = parseInt(opts.timeout,10);
      // ensure that timeout and speed settings are sane
      if (opts.speed.constructor == String)
        opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10);
      if (!opts.sync)
        opts.speed = opts.speed / 2;

      var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
      while((opts.timeout - opts.speed) < buffer) // sanitize timeout
        opts.timeout += opts.speed;
    }
    if (opts.easing)
      opts.easeIn = opts.easeOut = opts.easing;
    if (!opts.speedIn)
      opts.speedIn = opts.speed;
    if (!opts.speedOut)
      opts.speedOut = opts.speed;

    opts.slideCount = els.length;
    opts.currSlide = opts.lastSlide = first;
    if (opts.random) {
      if (++opts.randomIndex == els.length)
        opts.randomIndex = 0;
      opts.nextSlide = opts.randomMap[opts.randomIndex];
    }
    else if (opts.backwards)
      opts.nextSlide = opts.startingSlide == 0 ? (els.length-1) : opts.startingSlide-1;
    else
      opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;

    // run transition init fn
    if (!opts.multiFx) {
      var init = $.fn.cycle.transitions[opts.fx];
      if ($.isFunction(init))
        init($cont, $slides, opts);
      else if (opts.fx != 'custom' && !opts.multiFx) {
        log('unknown transition: ' + opts.fx,'; slideshow terminating');
        return false;
      }
    }

    // fire artificial events
    var e0 = $slides[first];
    if (!opts.skipInitializationCallbacks) {
      if (opts.before.length)
        opts.before[0].apply(e0, [e0, e0, opts, true]);
      if (opts.after.length)
        opts.after[0].apply(e0, [e0, e0, opts, true]);
    }
    if (opts.next)
      $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1)});
    if (opts.prev)
      $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0)});
    if (opts.pager || opts.pagerAnchorBuilder)
      buildPager(els,opts);

    exposeAddSlide(opts, els);

    return opts;
  };

  // save off original opts so we can restore after clearing state
  function saveOriginalOpts(opts) {
    opts.original = { before: [], after: [] };
    opts.original.cssBefore = $.extend({}, opts.cssBefore);
    opts.original.cssAfter  = $.extend({}, opts.cssAfter);
    opts.original.animIn	= $.extend({}, opts.animIn);
    opts.original.animOut   = $.extend({}, opts.animOut);
    $.each(opts.before, function() { opts.original.before.push(this); });
    $.each(opts.after,  function() { opts.original.after.push(this); });
  };

  function supportMultiTransitions(opts) {
    var i, tx, txs = $.fn.cycle.transitions;
    // look for multiple effects
    if (opts.fx.indexOf(',') > 0) {
      opts.multiFx = true;
      opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
      // discard any bogus effect names
      for (i=0; i < opts.fxs.length; i++) {
        var fx = opts.fxs[i];
        tx = txs[fx];
        if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
          log('discarding unknown transition: ',fx);
          opts.fxs.splice(i,1);
          i--;
        }
      }
      // if we have an empty list then we threw everything away!
      if (!opts.fxs.length) {
        log('No valid transitions named; slideshow terminating.');
        return false;
      }
    }
    else if (opts.fx == 'all') {  // auto-gen the list of transitions
      opts.multiFx = true;
      opts.fxs = [];
      for (p in txs) {
        tx = txs[p];
        if (txs.hasOwnProperty(p) && $.isFunction(tx))
          opts.fxs.push(p);
      }
    }
    if (opts.multiFx && opts.randomizeEffects) {
      // munge the fxs array to make effect selection random
      var r1 = Math.floor(Math.random() * 20) + 30;
      for (i = 0; i < r1; i++) {
        var r2 = Math.floor(Math.random() * opts.fxs.length);
        opts.fxs.push(opts.fxs.splice(r2,1)[0]);
      }
      debug('randomized fx sequence: ',opts.fxs);
    }
    return true;
  };

  // provide a mechanism for adding slides after the slideshow has started
  function exposeAddSlide(opts, els) {
    opts.addSlide = function(newSlide, prepend) {
      var $s = $(newSlide), s = $s[0];
      if (!opts.autostopCount)
        opts.countdown++;
      els[prepend?'unshift':'push'](s);
      if (opts.els)
        opts.els[prepend?'unshift':'push'](s); // shuffle needs this
      opts.slideCount = els.length;

      $s.css('position','absolute');
      $s[prepend?'prependTo':'appendTo'](opts.$cont);

      if (prepend) {
        opts.currSlide++;
        opts.nextSlide++;
      }

      if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
        clearTypeFix($s);

      if (opts.fit && opts.width)
        $s.width(opts.width);
      if (opts.fit && opts.height && opts.height != 'auto')
        $s.height(opts.height);
      s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
      s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();

      $s.css(opts.cssBefore);

      if (opts.pager || opts.pagerAnchorBuilder)
        $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);

      if ($.isFunction(opts.onAddSlide))
        opts.onAddSlide($s);
      else
        $s.hide(); // default behavior
    };
  }

  // reset internal state; we do this on every pass in order to support multiple effects
  $.fn.cycle.resetState = function(opts, fx) {
    fx = fx || opts.fx;
    opts.before = []; opts.after = [];
    opts.cssBefore = $.extend({}, opts.original.cssBefore);
    opts.cssAfter  = $.extend({}, opts.original.cssAfter);
    opts.animIn	= $.extend({}, opts.original.animIn);
    opts.animOut   = $.extend({}, opts.original.animOut);
    opts.fxFn = null;
    $.each(opts.original.before, function() { opts.before.push(this); });
    $.each(opts.original.after,  function() { opts.after.push(this); });

    // re-init
    var init = $.fn.cycle.transitions[fx];
    if ($.isFunction(init))
      init(opts.$cont, $(opts.elements), opts);
  };

  // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
  function go(els, opts, manual, fwd) {
    // opts.busy is true if we're in the middle of an animation
    if (manual && opts.busy && opts.manualTrump) {
      // let manual transitions requests trump active ones
      debug('manualTrump in go(), stopping active transition');
      $(els).stop(true,true);
      opts.busy = 0;
    }
    // don't begin another timeout-based transition if there is one active
    if (opts.busy) {
      debug('transition active, ignoring new tx request');
      return;
    }

    var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];

    // stop cycling if we have an outstanding stop request
    if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
      return;

    // check to see if we should stop cycling based on autostop options
    if (!manual && !p.cyclePause && !opts.bounce &&
      ((opts.autostop && (--opts.countdown <= 0)) ||
        (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
      if (opts.end)
        opts.end(opts);
      return;
    }

    // if slideshow is paused, only transition on a manual trigger
    var changed = false;
    if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
      changed = true;
      var fx = opts.fx;
      // keep trying to get the slide size if we don't have it yet
      curr.cycleH = curr.cycleH || $(curr).height();
      curr.cycleW = curr.cycleW || $(curr).width();
      next.cycleH = next.cycleH || $(next).height();
      next.cycleW = next.cycleW || $(next).width();

      // support multiple transition types
      if (opts.multiFx) {
        if (fwd && (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length))
          opts.lastFx = 0;
        else if (!fwd && (opts.lastFx == undefined || --opts.lastFx < 0))
          opts.lastFx = opts.fxs.length - 1;
        fx = opts.fxs[opts.lastFx];
      }

      // one-time fx overrides apply to:  $('div').cycle(3,'zoom');
      if (opts.oneTimeFx) {
        fx = opts.oneTimeFx;
        opts.oneTimeFx = null;
      }

      $.fn.cycle.resetState(opts, fx);

      // run the before callbacks
      if (opts.before.length)
        $.each(opts.before, function(i,o) {
          if (p.cycleStop != opts.stopCount) return;
          o.apply(next, [curr, next, opts, fwd]);
        });

      // stage the after callacks
      var after = function() {
        opts.busy = 0;
        $.each(opts.after, function(i,o) {
          if (p.cycleStop != opts.stopCount) return;
          o.apply(next, [curr, next, opts, fwd]);
        });
      };

      debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);

      // get ready to perform the transition
      opts.busy = 1;
      if (opts.fxFn) // fx function provided?
        opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
      else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
        $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
      else
        $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
    }

    if (changed || opts.nextSlide == opts.currSlide) {
      // calculate the next slide
      opts.lastSlide = opts.currSlide;
      if (opts.random) {
        opts.currSlide = opts.nextSlide;
        if (++opts.randomIndex == els.length)
          opts.randomIndex = 0;
        opts.nextSlide = opts.randomMap[opts.randomIndex];
        if (opts.nextSlide == opts.currSlide)
          opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
      }
      else if (opts.backwards) {
        var roll = (opts.nextSlide - 1) < 0;
        if (roll && opts.bounce) {
          opts.backwards = !opts.backwards;
          opts.nextSlide = 1;
          opts.currSlide = 0;
        }
        else {
          opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
          opts.currSlide = roll ? 0 : opts.nextSlide+1;
        }
      }
      else { // sequence
        var roll = (opts.nextSlide + 1) == els.length;
        if (roll && opts.bounce) {
          opts.backwards = !opts.backwards;
          opts.nextSlide = els.length-2;
          opts.currSlide = els.length-1;
        }
        else {
          opts.nextSlide = roll ? 0 : opts.nextSlide+1;
          opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
        }
      }
    }
    if (changed && opts.pager)
      opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);

    // stage the next transition
    var ms = 0;
    if (opts.timeout && !opts.continuous)
      ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
    else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
      ms = 10;
    if (ms > 0)
      p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards) }, ms);
  };

  // invoked after transition
  $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
    $(pager).each(function() {
      $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
    });
  };

  // calculate timeout value for current transition
  function getTimeout(curr, next, opts, fwd) {
    if (opts.timeoutFn) {
      // call user provided calc fn
      var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
      while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
        t += opts.speed;
      debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
      if (t !== false)
        return t;
    }
    return opts.timeout;
  };

  // expose next/prev function, caller must pass in state
  $.fn.cycle.next = function(opts) { advance(opts,1); };
  $.fn.cycle.prev = function(opts) { advance(opts,0);};

  // advance slide forward or back
  function advance(opts, moveForward) {
    var val = moveForward ? 1 : -1;
    var els = opts.elements;
    var p = opts.$cont[0], timeout = p.cycleTimeout;
    if (timeout) {
      clearTimeout(timeout);
      p.cycleTimeout = 0;
    }
    if (opts.random && val < 0) {
      // move back to the previously display slide
      opts.randomIndex--;
      if (--opts.randomIndex == -2)
        opts.randomIndex = els.length-2;
      else if (opts.randomIndex == -1)
        opts.randomIndex = els.length-1;
      opts.nextSlide = opts.randomMap[opts.randomIndex];
    }
    else if (opts.random) {
      opts.nextSlide = opts.randomMap[opts.randomIndex];
    }
    else {
      opts.nextSlide = opts.currSlide + val;
      if (opts.nextSlide < 0) {
        if (opts.nowrap) return false;
        opts.nextSlide = els.length - 1;
      }
      else if (opts.nextSlide >= els.length) {
        if (opts.nowrap) return false;
        opts.nextSlide = 0;
      }
    }

    var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
    if ($.isFunction(cb))
      cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
    go(els, opts, 1, moveForward);
    return false;
  };

  function buildPager(els, opts) {
    var $p = $(opts.pager);
    $.each(els, function(i,o) {
      $.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
    });
    opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
  };

  $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
    var a;
    if ($.isFunction(opts.pagerAnchorBuilder)) {
      a = opts.pagerAnchorBuilder(i,el);
      debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
    }
    else
      a = '<a href="#">'+(i+1)+'</a>';

    if (!a)
      return;
    var $a = $(a);
    // don't reparent if anchor is in the dom
    if ($a.parents('body').length === 0) {
      var arr = [];
      if ($p.length > 1) {
        $p.each(function() {
          var $clone = $a.clone(true);
          $(this).append($clone);
          arr.push($clone[0]);
        });
        $a = $(arr);
      }
      else {
        $a.appendTo($p);
      }
    }

    opts.pagerAnchors =  opts.pagerAnchors || [];
    opts.pagerAnchors.push($a);
    $a.bind(opts.pagerEvent, function(e) {
      e.preventDefault();
      opts.nextSlide = i;
      var p = opts.$cont[0], timeout = p.cycleTimeout;
      if (timeout) {
        clearTimeout(timeout);
        p.cycleTimeout = 0;
      }
      var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
      if ($.isFunction(cb))
        cb(opts.nextSlide, els[opts.nextSlide]);
      go(els,opts,1,opts.currSlide < i); // trigger the trans
      //		return false; // <== allow bubble
    });

    if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
      $a.bind('click.cycle', function(){return false;}); // suppress click

    var pauseFlag = false; // https://github.com/malsup/cycle/issues/44
    if (opts.pauseOnPagerHover) {
      $a.hover(
        function() {
          pauseFlag = true;
          opts.$cont[0].cyclePause++;
          triggerPause(cont,true,true);
        }, function() {
          pauseFlag && opts.$cont[0].cyclePause--;
          triggerPause(cont,true,true);
        }
      );
    }
  };

  // helper fn to calculate the number of slides between the current and the next
  $.fn.cycle.hopsFromLast = function(opts, fwd) {
    var hops, l = opts.lastSlide, c = opts.currSlide;
    if (fwd)
      hops = c > l ? c - l : opts.slideCount - l;
    else
      hops = c < l ? l - c : l + opts.slideCount - c;
    return hops;
  };

  // fix clearType problems in ie6 by setting an explicit bg color
  // (otherwise text slides look horrible during a fade transition)
  function clearTypeFix($slides) {
    debug('applying clearType background-color hack');
    function hex(s) {
      s = parseInt(s,10).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 && v.indexOf('rgb') >= 0 ) {
          var rgb = v.match(/\d+/g);
          return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
        }
        if (v && v != 'transparent')
          return v;
      }
      return '#ffffff';
    };
    $slides.each(function() { $(this).css('background-color', getBg(this)); });
  };

  // reset common props before the next transition
  $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
    $(opts.elements).not(curr).hide();
    if (typeof opts.cssBefore.opacity == 'undefined')
      opts.cssBefore.opacity = 1;
    opts.cssBefore.display = 'block';
    if (opts.slideResize && w !== false && next.cycleW > 0)
      opts.cssBefore.width = next.cycleW;
    if (opts.slideResize && h !== false && next.cycleH > 0)
      opts.cssBefore.height = next.cycleH;
    opts.cssAfter = opts.cssAfter || {};
    opts.cssAfter.display = 'none';
    $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
    $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
  };

  // the actual fn for effecting a transition
  $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
    var $l = $(curr), $n = $(next);
    var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
    $n.css(opts.cssBefore);
    if (speedOverride) {
      if (typeof speedOverride == 'number')
        speedIn = speedOut = speedOverride;
      else
        speedIn = speedOut = 1;
      easeIn = easeOut = null;
    }
    var fn = function() {
      $n.animate(opts.animIn, speedIn, easeIn, function() {
        cb();
      });
    };
    $l.animate(opts.animOut, speedOut, easeOut, function() {
      $l.css(opts.cssAfter);
      if (!opts.sync)
        fn();
    });
    if (opts.sync) fn();
  };

  // transition definitions - only fade is defined here, transition pack defines the rest
  $.fn.cycle.transitions = {
    fade: function($cont, $slides, opts) {
      $slides.not(':eq('+opts.currSlide+')').css('opacity',0);
      opts.before.push(function(curr,next,opts) {
        $.fn.cycle.commonReset(curr,next,opts);
        opts.cssBefore.opacity = 0;
      });
      opts.animIn	   = { opacity: 1 };
      opts.animOut   = { opacity: 0 };
      opts.cssBefore = { top: 0, left: 0 };
    }
  };

  $.fn.cycle.ver = function() { return ver; };

  // override these globally if you like (they are all optional)
  $.fn.cycle.defaults = {
    activePagerClass: 'activeSlide', // class name used for the active pager link
    after:		   null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
    allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
    animIn:		   null,  // properties that define how the slide animates in
    animOut:	   null,  // properties that define how the slide animates out
    aspect:		   false,  // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option)
    autostop:	   0,	  // true to end slideshow after X transitions (where X == slide count)
    autostopCount: 0,	  // number of transitions (optionally used with autostop to define X)
    backwards:     false, // true to start slideshow at last slide and move backwards through the stack
    before:		   null,  // transition callback (scope set to element to be shown):	 function(currSlideElement, nextSlideElement, options, forwardFlag)
    center: 	   null,  // set to true to have cycle add top/left margin to each slide (use with width and height options)
    cleartype:	   !$.support.opacity,  // true if clearType corrections should be applied (for IE)
    cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
    containerResize: 1,	  // resize container to fit largest slide
    continuous:	   0,	  // true to start next transition immediately after current one completes
    cssAfter:	   null,  // properties that defined the state of the slide after transitioning out
    cssBefore:	   null,  // properties that define the initial state of the slide before transitioning in
    delay:		   0,	  // additional delay (in ms) for first transition (hint: can be negative)
    easeIn:		   null,  // easing for "in" transition
    easeOut:	   null,  // easing for "out" transition
    easing:		   null,  // easing method for both in and out transitions
    end:		   null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
    fastOnEvent:   0,	  // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
    fit:		   0,	  // force slides to fit container
    fx:			  'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
    fxFn:		   null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
    height:		  'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well)
    manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored
    metaAttr:     'cycle',// data- attribute that holds the option data for the slideshow
    next:		   null,  // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide
    nowrap:		   0,	  // true to prevent slideshow from wrapping
    onPagerEvent:  null,  // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
    onPrevNextEvent: null,// callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
    pager:		   null,  // element, jQuery object, or jQuery selector string for the element to use as pager container
    pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement)
    pagerEvent:	  'click.cycle', // name of event which drives the pager navigation
    pause:		   0,	  // true to enable "pause on hover"
    pauseOnPagerHover: 0, // true to pause when hovering over pager link
    prev:		   null,  // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide
    prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide
    random:		   0,	  // true for random, false for sequence (not applicable to shuffle fx)
    randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random
    requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
    requeueTimeout: 250,  // ms delay for requeue
    rev:		   0,	  // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle)
    shuffle:	   null,  // coords for shuffle animation, ex: { top:15, left: 200 }
    skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition
    slideExpr:	   null,  // expression for selecting slides (if something other than all children is required)
    slideResize:   1,     // force slide width/height to fixed size before every transition
    speed:		   1000,  // speed of the transition (any valid fx speed value)
    speedIn:	   null,  // speed of the 'in' transition
    speedOut:	   null,  // speed of the 'out' transition
    startingSlide: 0,	  // zero-based index of the first slide to be displayed
    sync:		   1,	  // true if in/out transitions should occur simultaneously
    timeout:	   4000,  // milliseconds between slide transitions (0 to disable auto advance)
    timeoutFn:     null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
    updateActivePagerLink: null, // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
    width:         null   // container width (if the 'fit' option is true, the slides will be set to this width as well)
  };

})(jQuery);


/*!
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version:	 2.73
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function($) {

//
// These functions define slide initialization and properties for the named
// transitions. To save file size feel free to remove any of these that you
// don't need.
//
  $.fn.cycle.transitions.none = function($cont, $slides, opts) {
    opts.fxFn = function(curr,next,opts,after){
      $(next).show();
      $(curr).hide();
      after();
    };
  };

// not a cross-fade, fadeout only fades out the top slide
  $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
    $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 });
    opts.before.push(function(curr,next,opts,w,h,rev) {
      $(curr).css('zIndex',opts.slideCount + (!rev === true ? 1 : 0));
      $(next).css('zIndex',opts.slideCount + (!rev === true ? 0 : 1));
    });
    opts.animIn.opacity = 1;
    opts.animOut.opacity = 0;
    opts.cssBefore.opacity = 1;
    opts.cssBefore.display = 'block';
    opts.cssAfter.zIndex = 0;
  };

// scrollUp/Down/Left/Right
  $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
    $cont.css('overflow','hidden');
    opts.before.push($.fn.cycle.commonReset);
    var h = $cont.height();
    opts.cssBefore.top = h;
    opts.cssBefore.left = 0;
    opts.cssFirst.top = 0;
    opts.animIn.top = 0;
    opts.animOut.top = -h;
  };
  $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
    $cont.css('overflow','hidden');
    opts.before.push($.fn.cycle.commonReset);
    var h = $cont.height();
    opts.cssFirst.top = 0;
    opts.cssBefore.top = -h;
    opts.cssBefore.left = 0;
    opts.animIn.top = 0;
    opts.animOut.top = h;
  };
  $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
    $cont.css('overflow','hidden');
    opts.before.push($.fn.cycle.commonReset);
    var w = $cont.width();
    opts.cssFirst.left = 0;
    opts.cssBefore.left = w;
    opts.cssBefore.top = 0;
    opts.animIn.left = 0;
    opts.animOut.left = 0-w;
  };
  $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
    $cont.css('overflow','hidden');
    opts.before.push($.fn.cycle.commonReset);
    var w = $cont.width();
    opts.cssFirst.left = 0;
    opts.cssBefore.left = -w;
    opts.cssBefore.top = 0;
    opts.animIn.left = 0;
    opts.animOut.left = w;
  };
  var win = $(window);
  $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
    $cont.css('overflow','hidden').width();
    cycleW = win.width();
    opts.before.push(function(curr, next, opts, fwd) {
      if (opts.rev)
        fwd = !fwd;
      $.fn.cycle.commonReset(curr,next,opts);
      opts.cssBefore.left = fwd ? (cycleW-1) : (1-cycleW);
      opts.animOut.left = fwd ? -cycleW : cycleW;
    });
    opts.cssFirst.left = 0;
    opts.cssBefore.top = 0;
    opts.animIn.left = 0;
    opts.animOut.top = 0;
  };
  $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
    $cont.css('overflow','hidden');
    opts.before.push(function(curr, next, opts, fwd) {
      if (opts.rev)
        fwd = !fwd;
      $.fn.cycle.commonReset(curr,next,opts);
      opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
      opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
    });
    opts.cssFirst.top = 0;
    opts.cssBefore.left = 0;
    opts.animIn.top = 0;
    opts.animOut.left = 0;
  };

// slideX/slideY
  $.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $(opts.elements).not(curr).hide();
      $.fn.cycle.commonReset(curr,next,opts,false,true);
      opts.animIn.width = next.cycleW;
    });
    opts.cssBefore.left = 0;
    opts.cssBefore.top = 0;
    opts.cssBefore.width = 0;
    opts.animIn.width = 'show';
    opts.animOut.width = 0;
  };
  $.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $(opts.elements).not(curr).hide();
      $.fn.cycle.commonReset(curr,next,opts,true,false);
      opts.animIn.height = next.cycleH;
    });
    opts.cssBefore.left = 0;
    opts.cssBefore.top = 0;
    opts.cssBefore.height = 0;
    opts.animIn.height = 'show';
    opts.animOut.height = 0;
  };

// shuffle
  $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
    var i, w = $cont.css('overflow', 'visible').width();
    $slides.css({left: 0, top: 0});
    opts.before.push(function(curr,next,opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,true,true);
    });
    // only adjust speed once!
    if (!opts.speedAdjusted) {
      opts.speed = opts.speed / 2; // shuffle has 2 transitions
      opts.speedAdjusted = true;
    }
    opts.random = 0;
    opts.shuffle = opts.shuffle || {left:-w, top:15};
    opts.els = [];
    for (i=0; i < $slides.length; i++)
      opts.els.push($slides[i]);

    for (i=0; i < opts.currSlide; i++)
      opts.els.push(opts.els.shift());

    // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
    opts.fxFn = function(curr, next, opts, cb, fwd) {
      if (opts.rev)
        fwd = !fwd;
      var $el = fwd ? $(curr) : $(next);
      $(next).css(opts.cssBefore);
      var count = opts.slideCount;
      $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
        var hops = $.fn.cycle.hopsFromLast(opts, fwd);
        for (var k=0; k < hops; k++)
          fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
        if (fwd) {
          for (var i=0, len=opts.els.length; i < len; i++)
            $(opts.els[i]).css('z-index', len-i+count);
        }
        else {
          var z = $(curr).css('z-index');
          $el.css('z-index', parseInt(z,10)+1+count);
        }
        $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
          $(fwd ? this : curr).hide();
          if (cb) cb();
        });
      });
    };
    $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
  };

// turnUp/Down/Left/Right
  $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,false);
      opts.cssBefore.top = next.cycleH;
      opts.animIn.height = next.cycleH;
      opts.animOut.width = next.cycleW;
    });
    opts.cssFirst.top = 0;
    opts.cssBefore.left = 0;
    opts.cssBefore.height = 0;
    opts.animIn.top = 0;
    opts.animOut.height = 0;
  };
  $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,false);
      opts.animIn.height = next.cycleH;
      opts.animOut.top   = curr.cycleH;
    });
    opts.cssFirst.top = 0;
    opts.cssBefore.left = 0;
    opts.cssBefore.top = 0;
    opts.cssBefore.height = 0;
    opts.animOut.height = 0;
  };
  $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,true);
      opts.cssBefore.left = next.cycleW;
      opts.animIn.width = next.cycleW;
    });
    opts.cssBefore.top = 0;
    opts.cssBefore.width = 0;
    opts.animIn.left = 0;
    opts.animOut.width = 0;
  };
  $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,true);
      opts.animIn.width = next.cycleW;
      opts.animOut.left = curr.cycleW;
    });
    $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
    opts.animIn.left = 0;
    opts.animOut.width = 0;
  };

// zoom
  $.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,false,true);
      opts.cssBefore.top = next.cycleH/2;
      opts.cssBefore.left = next.cycleW/2;
      $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
      $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
    });
    opts.cssFirst.top = 0;
    opts.cssFirst.left = 0;
    opts.cssBefore.width = 0;
    opts.cssBefore.height = 0;
  };

// fadeZoom
  $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,false);
      opts.cssBefore.left = next.cycleW/2;
      opts.cssBefore.top = next.cycleH/2;
      $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
    });
    opts.cssBefore.width = 0;
    opts.cssBefore.height = 0;
    opts.animOut.opacity = 0;
  };

// blindX
  $.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
    var w = $cont.css('overflow','hidden').width();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts);
      opts.animIn.width = next.cycleW;
      opts.animOut.left   = curr.cycleW;
    });
    opts.cssBefore.left = w;
    opts.cssBefore.top = 0;
    opts.animIn.left = 0;
    opts.animOut.left = w;
  };
// blindY
  $.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
    var h = $cont.css('overflow','hidden').height();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts);
      opts.animIn.height = next.cycleH;
      opts.animOut.top   = curr.cycleH;
    });
    opts.cssBefore.top = h;
    opts.cssBefore.left = 0;
    opts.animIn.top = 0;
    opts.animOut.top = h;
  };
// blindZ
  $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
    var h = $cont.css('overflow','hidden').height();
    var w = $cont.width();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts);
      opts.animIn.height = next.cycleH;
      opts.animOut.top   = curr.cycleH;
    });
    opts.cssBefore.top = h;
    opts.cssBefore.left = w;
    opts.animIn.top = 0;
    opts.animIn.left = 0;
    opts.animOut.top = h;
    opts.animOut.left = w;
  };

// growX - grow horizontally from centered 0 width
  $.fn.cycle.transitions.growX = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,true);
      opts.cssBefore.left = this.cycleW/2;
      opts.animIn.left = 0;
      opts.animIn.width = this.cycleW;
      opts.animOut.left = 0;
    });
    opts.cssBefore.top = 0;
    opts.cssBefore.width = 0;
  };
// growY - grow vertically from centered 0 height
  $.fn.cycle.transitions.growY = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,false);
      opts.cssBefore.top = this.cycleH/2;
      opts.animIn.top = 0;
      opts.animIn.height = this.cycleH;
      opts.animOut.top = 0;
    });
    opts.cssBefore.height = 0;
    opts.cssBefore.left = 0;
  };

// curtainX - squeeze in both edges horizontally
  $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,false,true,true);
      opts.cssBefore.left = next.cycleW/2;
      opts.animIn.left = 0;
      opts.animIn.width = this.cycleW;
      opts.animOut.left = curr.cycleW/2;
      opts.animOut.width = 0;
    });
    opts.cssBefore.top = 0;
    opts.cssBefore.width = 0;
  };
// curtainY - squeeze in both edges vertically
  $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,false,true);
      opts.cssBefore.top = next.cycleH/2;
      opts.animIn.top = 0;
      opts.animIn.height = next.cycleH;
      opts.animOut.top = curr.cycleH/2;
      opts.animOut.height = 0;
    });
    opts.cssBefore.height = 0;
    opts.cssBefore.left = 0;
  };

// cover - curr slide covered by next slide
  $.fn.cycle.transitions.cover = function($cont, $slides, opts) {
    var d = opts.direction || 'left';
    var w = $cont.css('overflow','hidden').width();
    var h = $cont.height();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts);
      if (d == 'right')
        opts.cssBefore.left = -w;
      else if (d == 'up')
        opts.cssBefore.top = h;
      else if (d == 'down')
        opts.cssBefore.top = -h;
      else
        opts.cssBefore.left = w;
    });
    opts.animIn.left = 0;
    opts.animIn.top = 0;
    opts.cssBefore.top = 0;
    opts.cssBefore.left = 0;
  };

// uncover - curr slide moves off next slide
  $.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
    var d = opts.direction || 'left';
    var w = $cont.css('overflow','hidden').width();
    var h = $cont.height();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,true,true);
      if (d == 'right')
        opts.animOut.left = w;
      else if (d == 'up')
        opts.animOut.top = -h;
      else if (d == 'down')
        opts.animOut.top = h;
      else
        opts.animOut.left = -w;
    });
    opts.animIn.left = 0;
    opts.animIn.top = 0;
    opts.cssBefore.top = 0;
    opts.cssBefore.left = 0;
  };

// toss - move top slide and fade away
  $.fn.cycle.transitions.toss = function($cont, $slides, opts) {
    var w = $cont.css('overflow','visible').width();
    var h = $cont.height();
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,true,true);
      // provide default toss settings if animOut not provided
      if (!opts.animOut.left && !opts.animOut.top)
        $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
      else
        opts.animOut.opacity = 0;
    });
    opts.cssBefore.left = 0;
    opts.cssBefore.top = 0;
    opts.animIn.left = 0;
  };

// wipe - clip animation
  $.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
    var w = $cont.css('overflow','hidden').width();
    var h = $cont.height();
    opts.cssBefore = opts.cssBefore || {};
    var clip;
    if (opts.clip) {
      if (/l2r/.test(opts.clip))
        clip = 'rect(0px 0px '+h+'px 0px)';
      else if (/r2l/.test(opts.clip))
        clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
      else if (/t2b/.test(opts.clip))
        clip = 'rect(0px '+w+'px 0px 0px)';
      else if (/b2t/.test(opts.clip))
        clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
      else if (/zoom/.test(opts.clip)) {
        var top = parseInt(h/2,10);
        var left = parseInt(w/2,10);
        clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
      }
    }

    opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';

    var d = opts.cssBefore.clip.match(/(\d+)/g);
    var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10);

    opts.before.push(function(curr, next, opts) {
      if (curr == next) return;
      var $curr = $(curr), $next = $(next);
      $.fn.cycle.commonReset(curr,next,opts,true,true,false);
      opts.cssAfter.display = 'block';

      var step = 1, count = parseInt((opts.speedIn / 13),10) - 1;
      (function f() {
        var tt = t ? t - parseInt(step * (t/count),10) : 0;
        var ll = l ? l - parseInt(step * (l/count),10) : 0;
        var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h;
        var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w;
        $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
        (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
      })();
    });
    $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
    opts.animIn	   = { left: 0 };
    opts.animOut   = { left: 0 };
  };

})(jQuery);

jQuery.fn.sandbox = function(fn) {
  var element = $(this).clone(), result;
  // make the element take space in the page but invisible
  element.css({visibility: 'hidden', display: 'block', position: 'absolute'}).insertAfter(this);
  // to override any display: none !important you may have been using
  element.attr('style', element.attr('style').replace('block', 'block !important'));
  result = fn.apply(element);
  element.remove();
  return result;
};

/*
 * jQuery UI Effects 1.8.13
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Effects/
 */
jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
  16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
  a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d=
  a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor",
  "borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
  0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
  211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easding:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})};
  f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,
    [{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.13",save:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.data("ec.storage."+a[b],c[0].style[a[b]])},restore:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))},setMode:function(c,a){if(a=="toggle")a=c.is(":hidden")?"show":"hide";return a},getBaseline:function(c,a){var b;switch(c[0]){case "top":b=
    0;break;case "middle":b=0.5;break;case "bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case "left":c=0;break;case "center":c=0.5;break;case "right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent();var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});
    c.wrap(b);b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(d,e){a[e]=c.css(e);if(isNaN(parseInt(a[e],10)))a[e]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent().replaceWith(c);return c},setTransition:function(c,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)});return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);
    a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%",
    "pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*
    ((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=
    e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=
    e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/
    h);return-(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e/2)==2)return b+d;g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);if(a<1)return-0.5*
    h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b;return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;if((a/=e/2)<1)return d/2*a*a*(((g*=1.525)+1)*a-g)+b;return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,
    e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2)return f.easing.easeInBounce(c,a*2,0,d,e)*0.5+b;return f.easing.easeOutBounce(c,a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);
;

/*
 Thumbnail scroller jQuery plugin
 Author: malihu [http://manos.malihu.gr]
 Homepage: manos.malihu.gr/jquery-thumbnail-scroller
 */
(function($){
  $.fn.thumbnailScroller=function(options){
    var defaults={ //default options
      scrollerType:"hoverPrecise", //values: "hoverPrecise", "hoverAccelerate", "clickButtons"
      scrollerOrientation:"horizontal", //values: "horizontal", "vertical"
      scrollEasing:"easeOutCirc", //easing type
      scrollEasingAmount:800, //value: milliseconds
      acceleration:2, //value: integer
      scrollSpeed:600, //value: milliseconds
      noScrollCenterSpace:0, //value: pixels
      autoScrolling:0, //value: integer
      autoScrollingSpeed:8000, //value: milliseconds
      autoScrollingEasing:"easeInOutQuad", //easing type
      autoScrollingDelay:2500 //value: milliseconds
    };
    var options=$.extend(defaults,options);
    return this.each(function(){
      //cache vars
      var $this=$(this);
      var $scrollerContainer=$this.children(".jTscrollerContainer");
      var $scroller=$this.children(".jTscrollerContainer").children(".jTscroller");
      var $scrollerNextButton=$this.children(".jTscrollerNextButton");
      var $scrollerPrevButton=$this.children(".jTscrollerPrevButton");
      //set scroller width
      if(options.scrollerOrientation=="horizontal"){
        $scrollerContainer.css("width",999999);
        var totalWidth=$scroller.outerWidth(true);
        $scrollerContainer.css("width",totalWidth);
      }else{
        var totalWidth=$scroller.outerWidth(true);
      }
      var totalHeight=$scroller.outerHeight(true); //scroller height
      //do the scrolling
      if(totalWidth>$this.width() || totalHeight>$this.height()){ //needs scrolling
        var pos;
        var mouseCoords;
        var mouseCoordsY;
        if(options.scrollerType=="hoverAccelerate"){ //type hoverAccelerate
          var animTimer;
          var interval=8;
          $this.hover(function(){ //mouse over
            $this.mousemove(function(e){
              pos=findPos(this);
              mouseCoords=(e.pageX-pos[1]);
              mouseCoordsY=(e.pageY-pos[0]);
            });
            clearInterval(animTimer);
            animTimer = setInterval(Scrolling,interval);
          },function(){  //mouse out
            clearInterval(animTimer);
            $scroller.stop();
          });
          $scrollerPrevButton.add($scrollerNextButton).hide(); //hide buttons
        }else if(options.scrollerType=="clickButtons"){
          ClickScrolling();
        }else{ //type hoverPrecise
          pos=findPos(this);
          $this.mousemove(function(e){
            mouseCoords=(e.pageX-pos[1]);
            mouseCoordsY=(e.pageY-pos[0]);
            var mousePercentX=mouseCoords/$this.width(); if(mousePercentX>1){mousePercentX=1;}
            var mousePercentY=mouseCoordsY/$this.height(); if(mousePercentY>1){mousePercentY=1;}
            var destX=Math.round(-((totalWidth-$this.width())*(mousePercentX)));
            var destY=Math.round(-((totalHeight-$this.height())*(mousePercentY)));
            $scroller.stop(true,false).animate({left:destX,top:destY},options.scrollEasingAmount,options.scrollEasing);
          });
          $scrollerPrevButton.add($scrollerNextButton).hide(); //hide buttons
        }
        //auto scrolling
        if(options.autoScrolling>0){
          AutoScrolling();
        }
      } else {
        //no scrolling needed
        $scrollerPrevButton.add($scrollerNextButton).hide(); //hide buttons
      }
      //"hoverAccelerate" scrolling fn
      var scrollerPos;
      var scrollerPosY;
      function Scrolling(){
        if((mouseCoords<$this.width()/2) && ($scroller.position().left>=0)){
          $scroller.stop(true,true).css("left",0);
        }else if((mouseCoords>$this.width()/2) && ($scroller.position().left<=-(totalWidth-$this.width()))){
          $scroller.stop(true,true).css("left",-(totalWidth-$this.width()));
        }else{
          if((mouseCoords<=($this.width()/2)-options.noScrollCenterSpace) || (mouseCoords>=($this.width()/2)+options.noScrollCenterSpace)){
            scrollerPos=Math.round(Math.cos((mouseCoords/$this.width())*Math.PI)*(interval+options.acceleration));
            $scroller.stop(true,true).animate({left:"+="+scrollerPos},interval,"linear");
          }else{
            $scroller.stop(true,true);
          }
        }
        if((mouseCoordsY<$this.height()/2) && ($scroller.position().top>=0)){
          $scroller.stop(true,true).css("top",0);
        }else if((mouseCoordsY>$this.height()/2) && ($scroller.position().top<=-(totalHeight-$this.height()))){
          $scroller.stop(true,true).css("top",-(totalHeight-$this.height()));
        }else{
          if((mouseCoordsY<=($this.height()/2)-options.noScrollCenterSpace) || (mouseCoordsY>=($this.height()/2)+options.noScrollCenterSpace)){
            scrollerPosY=Math.cos((mouseCoordsY/$this.height())*Math.PI)*(interval+options.acceleration);
            $scroller.stop(true,true).animate({top:"+="+scrollerPosY},interval,"linear");
          }else{
            $scroller.stop(true,true);
          }
        }
      }
      //auto scrolling fn
      var autoScrollingCount=0;
      function AutoScrolling(){
        $scroller.delay(options.autoScrollingDelay).animate({left:-(totalWidth-$this.width()),top:-(totalHeight-$this.height())},options.autoScrollingSpeed,options.autoScrollingEasing,function(){
          $scroller.animate({left:0,top:0},options.autoScrollingSpeed,options.autoScrollingEasing,function(){
            autoScrollingCount++;
            if(options.autoScrolling>1 && options.autoScrolling!=autoScrollingCount){
              AutoScrolling();
            }
          });
        });
      }
      //click scrolling fn
      function ClickScrolling(){
        $scrollerPrevButton.hide();
        $scrollerNextButton.show();
        $scrollerNextButton.click(function(e){ //next button
          e.preventDefault();
          var posX=$scroller.position().left;
          var diffX=totalWidth+(posX-$this.width());
          var posY=$scroller.position().top;
          var diffY=totalHeight+(posY-$this.height());
          $scrollerPrevButton.stop().show("fast");
          if(options.scrollerOrientation=="horizontal"){
            if(diffX>=$this.width()){
              $scroller.stop().animate({left:"-="+$this.width()},options.scrollSpeed,options.scrollEasing,function(){
                if(diffX==$this.width()){
                  $scrollerNextButton.stop().hide("fast");
                }
              });
            } else {
              $scrollerNextButton.stop().hide("fast");
              $scroller.stop().animate({left:$this.width()-totalWidth},options.scrollSpeed,options.scrollEasing);
            }
          }else{
            if(diffY>=$this.height()){
              $scroller.stop().animate({top:"-="+$this.height()},options.scrollSpeed,options.scrollEasing,function(){
                if(diffY==$this.height()){
                  $scrollerNextButton.stop().hide("fast");
                }
              });
            } else {
              $scrollerNextButton.stop().hide("fast");
              $scroller.stop().animate({top:$this.height()-totalHeight},options.scrollSpeed,options.scrollEasing);
            }
          }
        });
        $scrollerPrevButton.click(function(e){ //previous button
          e.preventDefault();
          var posX=$scroller.position().left;
          var diffX=totalWidth+(posX-$this.width());
          var posY=$scroller.position().top;
          var diffY=totalHeight+(posY-$this.height());
          $scrollerNextButton.stop().show("fast");
          if(options.scrollerOrientation=="horizontal"){
            if(posX+$this.width()<=0){
              $scroller.stop().animate({left:"+="+$this.width()},options.scrollSpeed,options.scrollEasing,function(){
                if(posX+$this.width()==0){
                  $scrollerPrevButton.stop().hide("fast");
                }
              });
            } else {
              $scrollerPrevButton.stop().hide("fast");
              $scroller.stop().animate({left:0},options.scrollSpeed,options.scrollEasing);
            }
          }else{
            if(posY+$this.height()<=0){
              $scroller.stop().animate({top:"+="+$this.height()},options.scrollSpeed,options.scrollEasing,function(){
                if(posY+$this.height()==0){
                  $scrollerPrevButton.stop().hide("fast");
                }
              });
            } else {
              $scrollerPrevButton.stop().hide("fast");
              $scroller.stop().animate({top:0},options.scrollSpeed,options.scrollEasing);
            }
          }
        });
      }
    });
  };
})(jQuery);
//global js functions
//find element Position
function findPos(obj){
  var curleft=curtop=0;
  if (obj.offsetParent){
    curleft=obj.offsetLeft
    curtop=obj.offsetTop
    while(obj=obj.offsetParent){
      curleft+=obj.offsetLeft
      curtop+=obj.offsetTop
    }
  }
  return [curtop,curleft];
}

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 * 
 * Requires: 1.2.2+
 */

(function($) {

  var types = ['DOMMouseScroll', 'mousewheel'];

  $.event.special.mousewheel = {
    setup: function() {
      if ( this.addEventListener ) {
        for ( var i=types.length; i; ) {
          this.addEventListener( types[--i], handler, false );
        }
      } else {
        this.onmousewheel = handler;
      }
    },

    teardown: function() {
      if ( this.removeEventListener ) {
        for ( var i=types.length; i; ) {
          this.removeEventListener( types[--i], handler, false );
        }
      } else {
        this.onmousewheel = null;
      }
    }
  };

  $.fn.extend({
    mousewheel: function(fn) {
      return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },

    unmousewheel: function(fn) {
      return this.unbind("mousewheel", fn);
    }
  });


  function handler(event) {
    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
    event = $.event.fix(orgEvent);
    event.type = "mousewheel";

    // Old school scrollwheel delta
    if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
    if ( event.detail     ) { delta = -event.detail/3; }

    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;

    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
      deltaY = 0;
      deltaX = -1*delta;
    }

    // Webkit
    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }

    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);

    return $.event.handle.apply(this, args);
  }

})(jQuery);

/*
 * jScrollPane - v2.0.0beta11 - 2011-07-04
 * http://jscrollpane.kelvinluck.com/
 *
 * Copyright (c) 2010 Kelvin Luck
 * Dual licensed under the MIT and GPL licenses.
 */
(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var az,Q=this,Y,ak,v,am,T,Z,y,q,aA,aF,av,i,I,h,j,aa,U,aq,X,t,A,ar,af,an,G,l,au,ay,x,aw,aI,f,L,aj=true,P=true,aH=false,k=false,ap=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aI=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function at(aR){var aM,aO,aN,aK,aJ,aQ,aP=false,aL=false;az=aR;if(Y===c){aJ=D.scrollTop();aQ=D.scrollLeft();D.css({overflow:"hidden",padding:0});ak=D.innerWidth()+f;v=D.innerHeight();D.width(ak);Y=b('<div class="jspPane" />').css("padding",aI).append(D.children());am=b('<div class="jspContainer" />').css({width:ak+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aP=az.stickToBottom&&K();aL=az.stickToRight&&B();aK=D.innerWidth()+f!=ak||D.outerHeight()!=v;if(aK){ak=D.innerWidth()+f;v=D.innerHeight();am.css({width:ak+"px",height:v+"px"})}if(!aK&&L==T&&Y.outerHeight()==Z){D.width(ak);return}L=T;Y.css("width","");D.width(ak);am.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aR.contentWidth){T=aR.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/ak;q=Z/v;aA=q>1;aF=y>1;if(!(aF||aA)){D.removeClass("jspScrollable");Y.css({top:0,width:am.width()-f});n();E();R();w();ai()}else{D.addClass("jspScrollable");aM=az.maintainPosition&&(I||aa);if(aM){aO=aD();aN=aB()}aG();z();F();if(aM){N(aL?(T-ak):aO,false);M(aP?(Z-v):aN,false)}J();ag();ao();if(az.enableKeyboardNavigation){S()}if(az.clickOnTrack){p()}C();if(az.hijackInternalLinks){m()}}if(az.autoReinitialise&&!aw){aw=setInterval(function(){at(az)},az.autoReinitialiseDelay)}else{if(!az.autoReinitialise&&aw){clearInterval(aw)}}aJ&&D.scrollTop(0)&&M(aJ,false);aQ&&D.scrollLeft(0)&&N(aQ,false);D.trigger("jsp-initialised",[aF||aA])}function aG(){if(aA){am.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=am.find(">.jspVerticalBar");aq=U.find(">.jspTrack");av=aq.find(">.jspDrag");if(az.showArrows){ar=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aE(0,-1)).bind("click.jsp",aC);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aE(0,1)).bind("click.jsp",aC);if(az.arrowScrollOnHover){ar.bind("mouseover.jsp",aE(0,-1,ar));af.bind("mouseover.jsp",aE(0,1,af))}al(aq,az.verticalArrowPositions,ar,af)}t=v;am.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});av.hover(function(){av.addClass("jspHover")},function(){av.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);av.addClass("jspActive");var s=aJ.pageY-av.position().top;b("html").bind("mousemove.jsp",function(aK){V(aK.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});o()}}function o(){aq.height(t+"px");I=0;X=az.verticalGutter+aq.outerWidth();Y.width(ak-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aF){am.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));an=am.find(">.jspHorizontalBar");G=an.find(">.jspTrack");h=G.find(">.jspDrag");if(az.showArrows){ay=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aE(-1,0)).bind("click.jsp",aC);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aE(1,0)).bind("click.jsp",aC);
  if(az.arrowScrollOnHover){ay.bind("mouseover.jsp",aE(-1,0,ay));x.bind("mouseover.jsp",aE(1,0,x))}al(G,az.horizontalArrowPositions,ay,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aJ){b("html").bind("dragstart.jsp selectstart.jsp",aC);h.addClass("jspActive");var s=aJ.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aK){W(aK.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});l=am.innerWidth();ah()}}function ah(){am.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aF&&aA){var aJ=G.outerHeight(),s=aq.outerWidth();t-=aJ;b(an).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;ak-=aJ;G.parent().append(b('<div class="jspCorner" />').css("width",aJ+"px"));o();ah()}if(aF){Y.width((am.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aF){au=Math.ceil(1/y*l);if(au>az.horizontalDragMaxWidth){au=az.horizontalDragMaxWidth}else{if(au<az.horizontalDragMinWidth){au=az.horizontalDragMinWidth}}h.width(au+"px");j=l-au;ae(aa)}if(aA){A=Math.ceil(1/q*t);if(A>az.verticalDragMaxHeight){A=az.verticalDragMaxHeight}else{if(A<az.verticalDragMinHeight){A=az.verticalDragMinHeight}}av.height(A+"px");i=t-A;ad(I)}}function al(aK,aM,aJ,s){var aO="before",aL="after",aN;if(aM=="os"){aM=/Mac/.test(navigator.platform)?"after":"split"}if(aM==aO){aL=aM}else{if(aM==aL){aO=aM;aN=aJ;aJ=s;s=aN}}aK[aO](aJ)[aL](s)}function aE(aJ,s,aK){return function(){H(aJ,s,this,aK);this.blur();return false}}function H(aM,aL,aP,aO){aP=b(aP).addClass("jspActive");var aN,aK,aJ=true,s=function(){if(aM!==0){Q.scrollByX(aM*az.arrowButtonSpeed)}if(aL!==0){Q.scrollByY(aL*az.arrowButtonSpeed)}aK=setTimeout(s,aJ?az.initialDelay:az.arrowRepeatFreq);aJ=false};s();aN=aO?"mouseout.jsp":"mouseup.jsp";aO=aO||b("html");aO.bind(aN,function(){aP.removeClass("jspActive");aK&&clearTimeout(aK);aK=null;aO.unbind(aN)})}function p(){w();if(aA){aq.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageY-aP.top-I,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageY-aS.top-A/2,aQ=v*az.scrollPagePercent,aR=i*aQ/(Z-v);if(aN<0){if(I-aR>aT){Q.scrollByY(-aQ)}else{V(aT)}}else{if(aN>0){if(I+aR<aT){Q.scrollByY(aQ)}else{V(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}if(aF){G.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageX-aP.left-aa,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageX-aS.left-au/2,aQ=ak*az.scrollPagePercent,aR=j*aQ/(T-ak);if(aN<0){if(aa-aR>aT){Q.scrollByX(-aQ)}else{W(aT)}}else{if(aN>0){if(aa+aR<aT){Q.scrollByX(aQ)}else{W(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(aq){aq.unbind("mousedown.jsp")}}function ax(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(av){av.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aJ){if(!aA){return}if(s<0){s=0}else{if(s>i){s=i}}if(aJ===c){aJ=az.animateScroll}if(aJ){Q.animate(av,"top",s,ad)}else{av.css("top",s);ad(s)}}function ad(aJ){if(aJ===c){aJ=av.position().top}am.scrollTop(0);I=aJ;var aM=I===0,aK=I==i,aL=aJ/i,s=-aL*(Z-v);if(aj!=aM||aH!=aK){aj=aM;aH=aK;D.trigger("jsp-arrow-change",[aj,aH,P,k])}u(aM,aK);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aM,aK]).trigger("scroll")}function W(aJ,s){if(!aF){return}if(aJ<0){aJ=0}else{if(aJ>j){aJ=j}}if(s===c){s=az.animateScroll}if(s){Q.animate(h,"left",aJ,ae)
}else{h.css("left",aJ);ae(aJ)}}function ae(aJ){if(aJ===c){aJ=h.position().left}am.scrollTop(0);aa=aJ;var aM=aa===0,aL=aa==j,aK=aJ/j,s=-aK*(T-ak);if(P!=aM||k!=aL){P=aM;k=aL;D.trigger("jsp-arrow-change",[aj,aH,P,k])}r(aM,aL);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aM,aL]).trigger("scroll")}function u(aJ,s){if(az.showArrows){ar[aJ?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aJ,s){if(az.showArrows){ay[aJ?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aJ){var aK=s/(Z-v);V(aK*i,aJ)}function N(aJ,s){var aK=aJ/(T-ak);W(aK*j,s)}function ab(aW,aR,aK){var aO,aL,aM,s=0,aV=0,aJ,aQ,aP,aT,aS,aU;try{aO=b(aW)}catch(aN){return}aL=aO.outerHeight();aM=aO.outerWidth();am.scrollTop(0);am.scrollLeft(0);while(!aO.is(".jspPane")){s+=aO.position().top;aV+=aO.position().left;aO=aO.offsetParent();if(/^body|html$/i.test(aO[0].nodeName)){return}}aJ=aB();aP=aJ+v;if(s<aJ||aR){aS=s-az.verticalGutter}else{if(s+aL>aP){aS=s-v+aL+az.verticalGutter}}if(aS){M(aS,aK)}aQ=aD();aT=aQ+ak;if(aV<aQ||aR){aU=aV-az.horizontalGutter}else{if(aV+aM>aT){aU=aV-ak+aM+az.horizontalGutter}}if(aU){N(aU,aK)}}function aD(){return -Y.position().left}function aB(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aB()<10)}function B(){var s=T-ak;return(s>20)&&(s-aD()<10)}function ag(){am.unbind(ac).bind(ac,function(aM,aN,aL,aJ){var aK=aa,s=I;Q.scrollBy(aL*az.mouseWheelSpeed,-aJ*az.mouseWheelSpeed,false);return aK==aa&&s==I})}function n(){am.unbind(ac)}function aC(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aJ,aL=[];aF&&aL.push(an[0]);aA&&aL.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aO){if(aO.target!==this&&!(aL.length&&b(aO.target).closest(aL).length)){return}var aN=aa,aM=I;switch(aO.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aO.keyCode;aK();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aJ=aO.keyCode==s&&aN!=aa||aM!=I;return !aJ}).bind("keypress.jsp",function(aM){if(aM.keyCode==s){aK()}return !aJ});if(az.hideFocus){D.css("outline","none");if("hideFocus" in am[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in am[0]){D.attr("hideFocus",false)}}function aK(){var aN=aa,aM=I;switch(s){case 40:Q.scrollByY(az.keyboardSpeed,false);break;case 38:Q.scrollByY(-az.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*az.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*az.scrollPagePercent,false);break;case 39:Q.scrollByX(az.keyboardSpeed,false);break;case 37:Q.scrollByX(-az.keyboardSpeed,false);break}aJ=aN!=aa||aM!=I;return aJ}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aL,aJ,aK=escape(location.hash);try{aL=b(aK)}catch(s){return}if(aL.length&&Y.find(aK)){if(am.scrollTop()===0){aJ=setInterval(function(){if(am.scrollTop()>0){ab(aK,true);b(document).scrollTop(am.position().top);clearInterval(aJ)}},50)}else{ab(aK,true);b(document).scrollTop(am.position().top)}}}}function ai(){b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function m(){ai();b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aJ;if(s.length>1){aJ=s[1];if(aJ.length>0&&Y.find("#"+aJ).length>0){ab("#"+aJ,true);return false}}})}function ao(){var aK,aJ,aM,aL,aN,s=false;am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aO){var aP=aO.originalEvent.touches[0];aK=aD();aJ=aB();aM=aP.pageX;aL=aP.pageY;aN=false;s=true}).bind("touchmove.jsp",function(aR){if(!s){return}var aQ=aR.originalEvent.touches[0],aP=aa,aO=I;Q.scrollTo(aK+aM-aQ.pageX,aJ+aL-aQ.pageY);aN=aN||Math.abs(aM-aQ.pageX)>5||Math.abs(aL-aQ.pageY)>5;
  return aP==aa&&aO==I}).bind("touchend.jsp",function(aO){s=false}).bind("click.jsp-touchclick",function(aO){if(aN){aN=false;return false}})}function g(){var s=aB(),aJ=aD();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ap.append(Y.children()));ap.scrollTop(s);ap.scrollLeft(aJ)}b.extend(Q,{reinitialise:function(aJ){aJ=b.extend({},az,aJ);at(aJ)},scrollToElement:function(aK,aJ,s){ab(aK,aJ,s)},scrollTo:function(aK,s,aJ){N(aK,aJ);M(s,aJ)},scrollToX:function(aJ,s){N(aJ,s)},scrollToY:function(s,aJ){M(s,aJ)},scrollToPercentX:function(aJ,s){N(aJ*(T-ak),s)},scrollToPercentY:function(aJ,s){M(aJ*(Z-v),s)},scrollBy:function(aJ,s,aK){Q.scrollByX(aJ,aK);Q.scrollByY(s,aK)},scrollByX:function(s,aK){var aJ=aD()+Math[s<0?"floor":"ceil"](s),aL=aJ/(T-ak);W(aL*j,aK)},scrollByY:function(s,aK){var aJ=aB()+Math[s<0?"floor":"ceil"](s),aL=aJ/(Z-v);V(aL*i,aK)},positionDragX:function(s,aJ){W(s,aJ)},positionDragY:function(aJ,s){V(aJ,s)},animate:function(aJ,aM,s,aL){var aK={};aK[aM]=s;aJ.animate(aK,{duration:az.animateDuration,easing:az.animateEase,queue:false,step:aL})},getContentPositionX:function(){return aD()},getContentPositionY:function(){return aB()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aD()/(T-ak)},getPercentScrolledY:function(){return aB()/(Z-v)},getIsScrollableH:function(){return aF},getIsScrollableV:function(){return aA},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:function(){m()},destroy:function(){g()}});at(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);




(function($){

$.fn.center = function(fn) {
  $(this).each(function() {
    var pH, pW;
    if(fn == 'window') {
      pH = $(window).height();
      pW = $(window).width();
    }
    else {
      pH = $(this).parent().height();
      pW = $(this).parent().width();
    }

    var mT = (pH - $(this).outerHeight())/2;
    if(fn != 'vertical') {
      var mL = (pW - $(this).outerWidth())/2;
    }

	// If the width of the overlay large, we're on a product detail page, remove margin-top
	if ($(this).find('.pd').width() >= 1300)
	{
		mT = mL = '40'
	}

    $(this).css({marginTop:mT, marginLeft:mL});
  });
};

})(jQuery);

/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 *
 * @projectDescription Easy element scrolling using jQuery.
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP.
 *
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * @id jQuery.scrollTo
 * @id jQuery.fn.scrollTo
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
 *	  The different options for target are:
 *		- A number position (will be applied to all axes).
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
*		- A percentage of the container's dimension/s, for example: 50% to go to the middle.
 *		- The string 'max' for go-to-end.
 * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *	 @option {Number} duration The OVERALL length of the animation.
 *	 @option {String} easing The easing method for the animation.
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
 *	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *	 @option {Function} onAfter Function to be called after the scrolling ends.
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @desc Scroll to a fixed position
 * @example $('div').scrollTo( 340 );
 *
 * @desc Scroll relatively to the actual position
 * @example $('div').scrollTo( '+=340px', { axis:'y' } );
 *
 * @dec Scroll using a selector (relative to the scrolled element)
 * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
 *
 * @ Scroll to a DOM element (same for jQuery object)
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
 *			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
 *				alert('scrolled!!');
 *			}});
 *
 * @desc Scroll on both axes, to different values
 * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
 */
;(function( $ ){

	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'xy',
		duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
	$scrollTo.window = function( scope ){
		return $(window)._scrollable();
	};

	// Hack, hack, hack :)
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn._scrollable = function(){
		return this.map(function(){
			var elem = this,
				isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;

				if( !isWin )
					return elem;

			var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;

			return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body :
				doc.documentElement;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };

		if( target == 'max' )
			target = 9e9;

		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue && settings.axis.length > 1;

		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this._scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					max = $scrollTo.max(elem, axis);

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}

					attr[key] += settings.offset[pos] || 0;

					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
				}else{
					var val = targ[pos];
					// Handle percentage values
					attr[key] = val.slice && val.slice(-1) == '%' ?
						parseFloat(val) / 100 * max
						: val;
				}

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );

				// Queueing axes
				if( !i && settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});

			animate( settings.onAfter );

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback && function(){
					callback.call(this, target, settings);
				});
			};

		}).end();
	};

	// Max scrolling position, works on quirks mode
	// It only fails (not too badly) on IE, quirks mode.
	$scrollTo.max = function( elem, axis ){
		var Dim = axis == 'x' ? 'Width' : 'Height',
			scroll = 'scroll'+Dim;

		if( !$(elem).is('html,body') )
			return elem[scroll] - $(elem)[Dim.toLowerCase()]();

		var size = 'client' + Dim,
			html = elem.ownerDocument.documentElement,
			body = elem.ownerDocument.body;

		return Math.max( html[scroll], body[scroll] )
			 - Math.min( html[size]  , body[size]   );

	};

	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};

})( jQuery );

/*!
 * jQuery.SerialScroll
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 06/14/2009
 *
 * @projectDescription Animated scrolling of series.
 * @author Ariel Flesler
 * @version 1.2.2
 *
 * @id jQuery.serialScroll
 * @id jQuery.fn.serialScroll
 * @param {Object} settings Hash of settings, it is passed in to jQuery.ScrollTo, none is required.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @link {http://flesler.blogspot.com/2008/02/jqueryserialscroll.html Homepage}
 *
 * Notes:
 *	- The plugin requires jQuery.ScrollTo.
 *	- The hash of settings, is passed to jQuery.ScrollTo, so its settings can be used as well.
 */
;(function( $ ){

	var $serialScroll = $.serialScroll = function( settings ){
		return $(window).serialScroll( settings );
	};

	// Many of these defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
	// @link {http://demos.flesler.com/jquery/scrollTo/ ScrollTo's Demo}
	$serialScroll.defaults = {// the defaults are public and can be overriden.
		duration:1000, // how long to animate.
		axis:'x', // which of top and left should be scrolled
		event:'click', // on which event to react.
		start:0, // first element (zero-based index)
		step:1, // how many elements to scroll on each action
		lock:true,// ignore events if already animating
		cycle:true, // cycle endlessly ( constant velocity )
		constant:true // use contant speed ?
		/*
		navigation:null,// if specified, it's a selector a collection of items to navigate the container
		target:window, // if specified, it's a selector to the element to be scrolled.
		interval:0, // it's the number of milliseconds to automatically go to the next
		lazy:false,// go find the elements each time (allows AJAX or JS content, or reordering)
		stop:false, // stop any previous animations to avoid queueing
		force:false,// force the scroll to the first element on start ?
		jump: false,// if true, when the event is triggered on an element, the pane scrolls to it
		items:null, // selector to the items (relative to the matched elements)
		prev:null, // selector to the 'prev' button
		next:null, // selector to the 'next' button
		onBefore: function(){}, // function called before scrolling, if it returns false, the event is ignored
		exclude:0 // exclude the last x elements, so we cannot scroll past the end
		*/
	};

	$.fn.serialScroll = function( options ){

		return this.each(function(){
			var
				settings = $.extend( {}, $serialScroll.defaults, options ),
				event = settings.event, // this one is just to get shorter code when compressed
				step = settings.step, // ditto
				lazy = settings.lazy, // ditto
				context = settings.target ? this : document, // if a target is specified, then everything's relative to 'this'.
				$pane = $(settings.target || this, context),// the element to be scrolled (will carry all the events)
				pane = $pane[0], // will be reused, save it into a variable
				items = settings.items, // will hold a lazy list of elements
				active = settings.start, // active index
				auto = settings.interval, // boolean, do auto or not
				nav = settings.navigation, // save it now to make the code shorter
				timer; // holds the interval id

			if( !lazy )// if not lazy, save the items now
				items = getItems();

			if( settings.force )
				jump( {}, active );// generate an initial call

			// Button binding, optional
			$(settings.prev||[], context).bind( event, -step, move );
			$(settings.next||[], context).bind( event, step, move );

			// Custom events bound to the container
			if( !pane.ssbound )// don't bind more than once
				$pane
					.bind('prev.serialScroll', -step, move ) // you can trigger with just 'prev'
					.bind('next.serialScroll', step, move ) // f.e: $(container).trigger('next');
					.bind('goto.serialScroll', jump ); // f.e: $(container).trigger('goto', 4 );

			if( auto )
				$pane
					.bind('start.serialScroll', function(e){
						if( !auto ){
							clear();
							auto = true;
							next();
						}
					 })
					.bind('stop.serialScroll', function(){// stop a current animation
						clear();
						auto = false;
					});

			$pane.bind('notify.serialScroll', function(e, elem){// let serialScroll know that the index changed externally
				var i = index(elem);
				if( i > -1 )
					active = i;
			});

			pane.ssbound = true;// avoid many bindings

			if( settings.jump )// can't use jump if using lazy items and a non-bubbling event
				(lazy ? $pane : getItems()).bind( event, function( e ){
					jump( e, index(e.target) );
				});

			if( nav )
				nav = $(nav, context).bind(event, function( e ){
					e.data = Math.round(getItems().length / nav.length) * nav.index(this);
					jump( e, this );
				});

			function move( e ){
				e.data += active;
				jump( e, this );
			};
			function jump( e, button ){
				if( !isNaN(button) ){// initial or special call from the outside $(container).trigger('goto',[index]);
					e.data = button;
					button = pane;
				}

				var
					pos = e.data, n,
					real = e.type, // is a real event triggering ?
					$items = settings.exclude ? getItems().slice(0,-settings.exclude) : getItems(),// handle a possible exclude
					limit = $items.length,
					elem = $items[pos],
					duration = settings.duration;

				if( real )// real event object
					e.preventDefault();

				if( auto ){
					clear();// clear any possible automatic scrolling.
					timer = setTimeout( next, settings.interval );
				}

				if( !elem ){ // exceeded the limits
					n = pos < 0 ? 0 : limit - 1;
					if( active != n )// we exceeded for the first time
						pos = n;
					else if( !settings.cycle )// this is a bad case
						return;
					else
						pos = limit - n - 1;// invert, go to the other side
					elem = $items[pos];
				}

				if( !elem || settings.lock && $pane.is(':animated') || // no animations while busy
					real && settings.onBefore &&
					settings.onBefore(e, elem, $pane, getItems(), pos) === false ) return;

				if( settings.stop )
					$pane.queue('fx',[]).stop();// remove all its animations

				if( settings.constant )
					duration = Math.abs(duration/step * (active - pos ));// keep constant velocity

				$pane
					.scrollTo( elem, duration, settings )// do scroll
					.trigger('notify.serialScroll',[pos]);// in case serialScroll was called on this elem more than once.
			};

			function next(){// I'll use the namespace to avoid conflicts
				$pane.trigger('next.serialScroll');
			};

			function clear(){
				clearTimeout(timer);
			};

			function getItems(){
				return $( items, pane );
			};

			function index( elem ){
				if( !isNaN(elem) ) return elem;// number
				var $items = getItems(), i;
				while(( i = $items.index(elem)) == -1 && elem != pane )// see if it matches or one of its ancestors
					elem = elem.parentNode;
				return i;
			};
		});
	};

  $.InFieldLabels = function (label, field, options) {
    // To avoid scope issues, use 'base' instead of 'this'
    // to reference this class from internal events and functions.
    var base = this;

    // Access to jQuery and DOM versions of each element
    base.$label = $(label);
    base.label  = label;

    base.$field = $(field);
    base.field  = field;

    base.$label.data("InFieldLabels", base);
    base.showing = true;

    base.init = function () {
      // Merge supplied options with default options
      base.options = $.extend({}, $.InFieldLabels.defaultOptions, options);

      // Check if the field is already filled in
      if (base.$field.val() !== "") {
        base.$label.hide();
        base.showing = false;
      }

      base.$field.focus(function () {
        base.fadeOnFocus();
      }).blur(function () {
        base.checkForEmpty(true);
      }).bind('keydown.infieldlabel', function (e) {
        // Use of a namespace (.infieldlabel) allows us to
        // unbind just this method later
        base.hideOnChange(e);
      }).bind('paste', function (e) {
        // Since you can not paste an empty string we can assume
        // that the fieldis not empty and the label can be cleared.
        base.setOpacity(0.0);
      }).change(function (e) {
        base.checkForEmpty();
      }).bind('onPropertyChange', function () {
        base.checkForEmpty();
      });
    };

    // If the label is currently showing
    // then fade it down to the amount
    // specified in the settings
    base.fadeOnFocus = function () {
      if (base.showing) {
        base.setOpacity(base.options.fadeOpacity);
      }
    };

    base.setOpacity = function (opacity) {
      base.$label.stop().animate({ opacity: opacity }, base.options.fadeDuration);
      base.showing = (opacity > 0.0);
    };

    // Checks for empty as a fail safe
    // set blur to true when passing from
    // the blur event
    base.checkForEmpty = function (blur) {
      if (base.$field.val() === "") {
        base.prepForShow();
        base.setOpacity(blur ? 1.0 : base.options.fadeOpacity);
      } else {
        base.setOpacity(0.0);
      }
    };

    base.prepForShow = function (e) {
      if (!base.showing) {
        // Prepare for a animate in...
        base.$label.css({opacity: 0.0}).show();

        // Reattach the keydown event
        base.$field.bind('keydown.infieldlabel', function (e) {
          base.hideOnChange(e);
        });
      }
    };

    base.hideOnChange = function (e) {
      if (
          (e.keyCode === 16) || // Skip Shift
          (e.keyCode === 9) // Skip Tab
        ) {
        return;
      }

      if (base.showing) {
        base.$label.hide();
        base.showing = false;
      }

      // Remove keydown event to save on CPU processing
      base.$field.unbind('keydown.infieldlabel');
    };

    // Run the initialization method
    base.init();
  };

  $.InFieldLabels.defaultOptions = {
    fadeOpacity: 0.5, // Once a field has focus, how transparent should the label be
    fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity
  };


  $.fn.inFieldLabels = function (options) {
    return this.each(function () {
      // Find input or textarea based on for= attribute
      // The for attribute on the label must contain the ID
      // of the input or textarea element
      var for_attr = $(this).attr('for'), $field;
      if (!for_attr) {
        return; // Nothing to attach, since the for field wasn't used
      }

      // Find the referenced input or textarea element
      $field = $(
        "input#" + for_attr + "[type='text']," +
        "input#" + for_attr + "[type='search']," +
        "input#" + for_attr + "[type='tel']," +
        "input#" + for_attr + "[type='url']," +
        "input#" + for_attr + "[type='email']," +
        "input#" + for_attr + "[type='password']," +
        "textarea#" + for_attr
      );

      if ($field.length === 0) {
        return; // Again, nothing to attach
      }

      // Only create object for input[text], input[password], or textarea
      (new $.InFieldLabels(this, $field[0], options));
    });
  };


})( jQuery );

;
(function($, Drupal) {
	
	Drupal.hunterTheme = Drupal.hunterTheme || {};
	
	var win, container, pd, reWidths, reHeights, minWidth, minHeight, shopping_page, order_status_page, order_conf_page;
	$(document).ready(function() {
		win = $(window);
      	container = $("body:not(.node-type-page) #container");
      	pd = $(".node-type-product-display #overlay");
      	reWidths = $(".w");
      	reHeights = $(".h");
      	minWidth = 1150;
      	minHeight = 800;
      	menuHeight = 120;
      	shopping_page = false;
      	order_status_page = false;
      	order_conf_page = false;
		
		if ($('body').hasClass('page-shop')) {
	      shopping_page = true;
	    }
	
		if($('body').hasClass('page-user')) {
	      order_status_page = true;
	    }
	
		if($('body').hasClass('page-checkout')) {
	      order_conf_page = true;
	    }
	
		resize(true);
		
		$(window).resize(function() {
			resize();
	    });

		/* Product Detail */
		$('.scroller').jScrollPane();
		
		// Product landing
		// If we are in older browsers, let's put the image directly into the DOM instead of a background image. This gets us close to the desired functionality
		if (!$('html').hasClass('backgroundsize'))
		{
			$('.landing-image').each(function() {
        var src = $(this).css('background-image').split('"')[1];
        if (typeof(src) != 'undefined') {
          $(this).css('background-image','../images.bg.jpg').html('<img class="legacyImage" src="' + src + '" alt="Landing Image">');
        }
      });
		}

		/* Product Listing */
		$(".modal_link").click(function(e) {
			e.preventDefault();

			var id = $(this).attr('id').substr(7);

			$("#dim").fadeIn();
			$("#"+id).fadeIn();

			resize();
			if (id == 'about_us') {
				$('#about_us .scroller').jScrollPane();
			}
		});// modal_link

		$(".closex, #dim").click(function() {
			if ($(this).attr('id') != "dim") {
				$(this).parent().fadeOut();
			} else {
				$('.modal, #my_bag').fadeOut();
			}
			$("#dim").fadeOut();
			$("header").css('zIndex', 11);
		});// closex, #dim

		$(".quad4").click(function() {
			$("#dim").fadeIn();
			$("#story_of_wellies").fadeIn();
			resize();
		});

		$("#scrollholder").thumbnailScroller({
			scrollerType:"hoverAccelerate",
			scrollerOrientation:"horizontal",
			scrollSpeed:2,
			scrollEasing:"easeOutCirc",
			scrollEasingAmount:600,
			acceleration:4,
			scrollSpeed:800,
			noScrollCenterSpace:10,
			autoScrolling:0,
			autoScrollingSpeed:2000,
			autoScrollingEasing:"easeInOutQuad",
			autoScrollingDelay:500
		});// scrollholder
		
		$(".fancy_button span, .fancy_button .arrow").click(function() {
			var p = $(this).parents('.fancy_button');

			if (!p.hasClass('open')) {
				var h = p.find('ul').height() + 35;
				p.find('.arrow').attr('src', 'img/womens/down-arrow.png');

				p.animate({height: h});
				p.find('.meat').animate({height: h-1});
				p.find('ul').slideDown();

				p.addClass('open');
			} else {
				var h = 35;

				p.find('.arrow').attr('src', 'img/womens/right-arrow.png');
				p.find('ul').slideUp();
				p.animate({height: h});
				p.find('.meat').animate({height: h-1});
				p.removeClass('open');
			}
		});
		
		$(".press-item img, .press-item a").hover(
			function() {
				$(this).parents('.press-item').siblings('.press-item').css('opacity', .4);
			},
			function() {
				$('.press-item').css('opacity', 1);
			}
		);
		
		$(".fancy_button ul li").click(function() {
			if ($(this).hasClass('selected')) {
				$(this).removeClass('selected');
			} else {
				$(this).addClass('selected');
			}
		});
		
		// loop through all links which should use a custom template file
		$('.colorbox-template').each( function() {
			// get the current URL
			var oldUrl = $(this).attr('href');
			// append the required parameters
			var newUrl = oldUrl + '&template=modal';
			// update the links href
			$(this).attr('href', newUrl);
		});
	
    $('.share-this-link').click(function() {
      $('.addthis_toolbox').slideToggle();
    });
	});
	
	function resize(firsttime)
	{
		
		var wH = win.height();
		var wW = win.width();
		
		//  Width resizing 
		if(wW > minWidth) {
			// Resize menus
			$("header").width(wW - 54);
			$("footer").width(wW - 54);
			container.css({width:'100%'});

			//Center Menu Centering
			var mL = ($("header").width() - ($("header .logo_cntr").outerWidth() + $("header .rightmenu").outerWidth()) - $(".centermenu").outerWidth())/2;
			$('.centermenu').css('marginLeft', mL);

			// Product Detail
			$(".node-type-product-display #overlay").width(wW - 160);
			$(".node-type-product-display #overlay .right").width($(".node-type-product-display #overlay").width() - $(".node-type-product-display #overlay .left").outerWidth() - 44);

			// Product listing
			$(".page-shop.sidebar-first #content").width($("#main").width() - $(".sidebar-first #sidebar").width() - 15);

			// Product landing
			$(".page-shop.sidebar-first.page-manager-page #content").width($("#main").width() - $(".sidebar-first #sidebar").width() - 2);
			$(".node-type-sub-landing-page #content").width($("#main").width() - $(".sidebar-first #sidebar").width() - 2);
			//        $(".threecol").width($("#content").width() - $('.onecol').outerWidth() - $(".twocol").outerWidth() - 24);
			$(".pos_center").center();

			// Front page
			$("#panels").css({width:wW});
			$(".panel").css({width:wW});

			/* The brand */
			var aboutW = wW-42;
			$(".fullpage").width(aboutW);
			$(".quad1").width(aboutW/2-1);
			$(".quad3").width(aboutW/2-1);

			$(".quad2").width(aboutW/2);
			$(".quad4").width(aboutW/2);

			/* Store Finder */
			//$(".finder .right").width(wW - $(".finder .left").width() - 67)
      $('#storefinder-map').width(wW - $('.view-id-store_locations').width() - 10);

  } else {
			if (firsttime) {
				$("header, footer").width(minWidth - 54);

				/* The brand */
				var aboutW = minWidth-42;
				$(".fullpage").width(aboutW);
				$(".quad1").width(aboutW/2-1);
				$(".quad3").width(aboutW/2-1);

				$(".quad2").width(aboutW/2);
				$(".quad4").width(aboutW/2);
			}// firsttime
			container.css({width:minWidth});
			$(".node-type-product-display #overlay").width(minWidth-160);
			$('.node-type-product-display #overlay .right').width(499);

			$(".sidebar-first #content").width(minWidth - $('.sidebar-first #sidebar').outerWidth());
			//        $(".threecol").width($("#content").width() - $('.onecol').outerWidth() - $(".twocol").outerWidth() - 24);

			/* Store Finder */
			//$('.view-id-store_locations').height(wH - 300);
      $('#storefinder-map').width(wW - $('.view-id-store_locations').width());
		}// width resizing
		
		/* Height Resizing */
		if (wH > minHeight) {
			
			container.css({height:'100%'});

			// Center Menu Centering
			var mL = ($("header").width() - ($("header .logo_cntr").outerWidth() + $("header .rightmenu").outerWidth()) - $(".centermenu").outerWidth())/2;
			$('.centermenu').css('marginLeft', mL);

			// Product Detail
			$(".pd").css({height:wH-167});
			$(".pd .left").height($(".pd").height());
			$(".pd .right").height($(".pd").height());

			// Product Listing
			$(".sidebar-first #sidebar").height($(".sidebar-first #content").height());
			if(shopping_page) {
				container.css({height:$(".sidebar-first #content").height() + 250});
			}

			if(order_conf_page) {
				container.css({height:$("#content").height() + 250});
			}
			if(order_status_page) {
				container.css({height:$("#content").height() + 250});
			}

			// Front page
			$("#panels").css({height:wH});
			$(".panel .main_image").height(wH);
			$(".cycle_arrow").css({top: wH/2});

			// Product sub-landing pages
			$(".sidebar-first.page-shop #content").height(wH-menuHeight-40);
			$(".node-type-sub-landing-page #content").height(wH-menuHeight-40);

			/* Product Landing */
			//$(".sidebar-first.page-manager-page.page-shop #content").height($('#content').width() * .66);
			$(".sidebar-first.page-manager-page.page-shop #content").height((wH - menuHeight) - 40);
      
      if ($('.page-cart #overlay').height() > wH - 200) {
        $('.page-cart #overlay').height(wH - 200);
        $('.page-cart #overlay').css('margin-top', 100);

        $('.page-cart #overlay').css('overflow-y', 'scroll');
        //$('.page-cart #overlay').center(window);
      }
      
      
			/* The brand */
			var aboutH = wH-142;
			$(".fullpage").height(aboutH);
			$(".quad1").height(aboutH/2-1);
			$(".quad2").height(aboutH/2-1);
			$(".quad3").height(aboutH/2);
			$(".quad4").height(aboutH/2);


			/* Store Finder */
			$('.view-id-store_locations').height(wH - 225);
			$('#storefinder-map').height(wH - 225);
		} else {
			
			container.css({height:minHeight});

			if(shopping_page) {
				container.css({height:$(".sidebar-first #content").height() + 250});
			}
			if(order_conf_page) {
				container.css({height:$("#content").height() + 250});
			}
			if(order_status_page) {
				container.css({height:$("#content").height() + 250});
			}

			// Product detail
			$(".pd").height(minHeight-167);
			$(".pd .left").height($(".pd").height());
			$(".pd .right").height($(".pd").height());

			if (firsttime) {
				// Front page
				$("#panels").css({height:minHeight});
				$(".panel .main_image").height(minHeight);

				// Product landing
				$(".sidebar-first.page-manager-page.page-shop #content").height($('#content').width() * .66);

				// Product sub-landing pages
				$(".node-type-sub-landing-page #content").height(wH-menuHeight-40);

				/* The brand */
				var aboutH = minHeight-142;
				$(".fullpage").height(aboutH);
				$(".quad1").height(aboutH/2-1);
				$(".quad2").height(aboutH/2-1);
				$(".quad3").height(aboutH/2);
				$(".quad4").height(aboutH/2);
			} //firsttime

			/* Store Finder */
			$('.view-id-store_locations').height(wH - 225);
      $('#storefinder-map').height(wH - 225);

		}// height resizing
		
		// Front page
		$('.panel .tout').height(.2*wH);
		$('.panel .tout').width(.2*wH);
		$('.panel .tout').css('marginBottom', .035*wH);
		
		Drupal.hunterTheme.resizeMainImage();
		
	}// resize
	
	/*****************************************************************************
	Behaviors
	*/
	
	Drupal.hunterTheme.behaviors = Drupal.hunterTheme.behaviors || {};
	
	/**
	* Process all hunter theme specific behaviors
	*/
	Drupal.hunterTheme.attachBehaviors = function (context, settings) {
		$.each(this.behaviors, function () {
			this(context, settings);
		});
	}
	
	
	Drupal.hunterTheme.behaviors.catalogLanding = function(context, settings) {

		// Related product hover details
		$("#main-landing .pane-content").hover(
			function() {
				// First hide all hover links
        // and manage z-indexes for hover.
        // Parent .col is relatively positioned so we have to
        // manage it's z-index too to side step IE7 issues.
        $('#main-landing .planding .hover').hide();
				$('#main-landing .planding .hover').css({'z-index': '-1'});
				$('#main-landing .planding .hover').parents('.col').css({'z-index': '1'});

				var el = $(this).find('.hover');
				var pos = $(this).position();
				var height = $(this).height();
				var width = $(this).width();
				var elementHeight = el.height();
				var elementWidth = el.width();
				var top = pos.top + ((height / 2) - (elementHeight / 2));
				var left = pos.left + (width - (elementWidth / 2));
				
				// If we're over to the right of the page, flip the element
				if (el.parents('.threecol').length > 0)
				{
					left = 0 - ((elementWidth / 2) + 40);
				}

        el.parents('.col').css('z-index','500');
				el.css({ 'left':left+'px', 'top': top+'px', 'z-index':400 });
        el.show();
			}, 
			function() {
				// Do nothing on hover out
			}
		);
	}
	
	// Product detail overlay specific behaviors
	Drupal.hunterTheme.behaviors.productDetailOverlay = function(context, settings) {
    // Resize product image fields on product detail modal
		$('.field-name-field-product-image .field-item img', context).each(function(index, e){ 
      Drupal.hunterTheme.resizeImgToHeight($(e), 144);
    });

    // Move default product detail image to main area.
		$('.field-name-field-product-image img', context).eq(0).each(function(index, element){
			var imgSrc = $(element).attr('src');
			Drupal.hunterTheme.displayMainImage(imgSrc);
		});

		// Move the src of the clicked img into the main image area
		$('.field-name-field-product-image img', context).click(function(event){
			var imgSrc = event.target.src;
			Drupal.hunterTheme.displayMainImage(imgSrc);
		});

    // Handle the back button.
    $('a.overlay-back').click(function() {
      parent.history.back();
      return false;
    });

		// Handle size guide
		$("#size_guide_button").click(function() {
			$("#dim2").fadeIn();
			$("#exit").fadeIn();
			$("#size_chart").fadeIn();
		});

		$("#exit").click(function() {
			$("#exit").fadeOut();
			$("#size_chart").fadeOut();
			$("#dim2").fadeOut();
		});

		// Color switcher
		$(".color > .swatches > .swatch").click(function() {
						
			// If it's not switching colors and it has not already been selected
			if (!$(this).hasClass('selected') && $("#current_color").text() != $(this).children('.color-name').html()) {
				$('.swatch').removeClass('selected');
				$('.tick').removeClass('tick-mark');
				$(this).addClass('selected');

				var name = $(this).children('.color-name').html();
				var code = $(this).children('.color-code-lower').html();

				$(this).children('.tick').addClass('tick-mark');

				$("#current_color").text(name);
				$('#main_image').fadeOut('fast');
				$('.pd .alt_views').fadeOut('fast', function(){
					$('#edit-attributes-field-product-color-' + code).click().change();
				});
			}
		});

		// Related product hover details
		$(".rp").hover(
			function() {
				$(this).children('.hover').stop().fadeTo('fast', 1);
			}, 
			function() {
				$(this).children('.hover').stop().fadeTo('fast', 0);
			}
		);

		// Make sure this behavior is not processed more than once.
		if (this.processed) {
			return;
		}
		this.processed = true;

		// Setup the scroller for the Product thumbnails
		$('#alt_views_left_arrow').hide();
		$('.alt_views_cntr').serialScroll({
			items:'div.field-item',
			prev:'#alt_views_left_arrow',
			next:'#alt_views_right_arrow',
			offset:0,
			start:0,
			stop:true,
			lock:false,
			cycle:false,
			easing:'easeOutQuart',
			lazy: true,
			onBefore:function( e, elem, $pane, $items, pos ) {
				$('#alt_views_left_arrow,#alt_views_right_arrow').show();
				if (pos == 0) {
					$('#alt_views_left_arrow').hide();
				} else if( pos == $items.length-1 ) {
					$('#alt_views_right_arrow').hide();
				}
			}
		});
	}
	
	// Cart overlay behaviors
	Drupal.hunterTheme.behaviors.cartOverlay = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-cart #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({ 'width': '1178px' });
			$('.page-cart #overlay').center('window');
			$('#views-form-commerce-cart-form-default>div').css({'width': '1178px'});
		});
	}
	
	// About us overlay behaviors
	Drupal.hunterTheme.behaviors.aboutUs = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-node-1939 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '530px'
			});
			$('.page-node-1939 #overlay').center('window');
		});
	}
	
	// contact us overlay behaviors
	Drupal.hunterTheme.behaviors.contactUs = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-node-629 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '425px'
			});
			$('.page-node-629 #overlay').center('window');
		});
	}
	
	// Customer service overlay behaviors
	Drupal.hunterTheme.behaviors.customerService = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-node-1941 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '450px'
			});
			$('.page-node-1941 #overlay').center('window');
		});
	}
	
	// Customer service overlay behaviors
	Drupal.hunterTheme.behaviors.ownershipAndCare = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('body.page-node-3284 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '430px'
			});
			$('body.page-node-1941 #overlay').center('window');
		});
	}
	
	// Terms and Conditions overlay behaviors
	Drupal.hunterTheme.behaviors.termsConditions = function(context, settings) {
		// Adjust the Terms and Conditions overlay dimensions when it is opened.
		$('.page-node-1942 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '450px'
			});
			$('.page-node-1942 #overlay').center('window');
		});
	}

	// Shipping Info overlay behaviors
	Drupal.hunterTheme.behaviors.shippingInfo = function(context, settings) {
		// Adjust the Shipping Info overlay dimensions when it is opened.
		$('.page-node-2171 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '450px'
			});
			$('.page-node-2171 #overlay').center('window');
		});
	}

	// FAQ overlay behaviors
	Drupal.hunterTheme.behaviors.faq = function(context, settings) {
		// Adjust the FAQ overlay dimensions when it is opened.
		$('.page-node-2170 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '430px'
			});
			$('.page-node-2170 #overlay').center('window');
		});
	}
	
	// Legal overlay behaviors
	Drupal.hunterTheme.behaviors.legal = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-node-630 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '430px'
			});
			$('.page-node-630 #overlay').center('window');
		});
	}
	
	// Privacy policy overlay behaviors
	Drupal.hunterTheme.behaviors.privacy = function(context, settings) {
		// Adjust the cart overlay dimensions when it is opened.
		$('.page-node-1943 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '430px'
			});
			$('.page-node-1943 #overlay').center('window');
		});
	}
	
	// Explore the boot overlay behaviors
	Drupal.hunterTheme.behaviors.theboot = function(context, settings) {
		// Adjust the explore the boot overlay dimensions when it is opened.
		$('.page-node-1940 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '990px',
				'height': '533px'
			});
			$('.page-node-1940 #overlay').center('window');
		});
	}
	
	// Return Policy overlay behaviors
	Drupal.hunterTheme.behaviors.returnpolicy = function(context, settings) {
		// Adjust the explore the Return Policy overlay dimensions when it is opened.
		$('.page-node-628 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '430px'
			});
			$('.page-node-628 #overlay').center('window');
		});
	}

	// Site Map overlay behaviors
	Drupal.hunterTheme.behaviors.sitemap = function(context, settings) {
		// Adjust the Site Map overlay dimensions when it is opened.
		$('.page-node-3282 #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '800px',
				'height': '530px'
			});
			$('.page-node-3282 #overlay').center('window');
		});
	}
  
  // Site Map overlay behaviors
	Drupal.hunterTheme.behaviors.login = function(context, settings) {
		// Adjust the Site Map overlay dimensions when it is opened.
		$('body.page-user #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '900px',
				'height': '530px',
         'overflow': 'scroll'
			});
			$('body.page-user #overlay').center('window');
		});
	}
	
	Drupal.hunterTheme.behaviors.register = function(context, settings) {
		// Adjust the Site Map overlay dimensions when it is opened.
		$('body.page-user-register #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '900px',
				'height': '630px',
         'overflow': 'scroll'
			});
			$('.page-user #overlay').center('window');
		});
	}
	
	Drupal.hunterTheme.behaviors.userEdit = function(context, settings) {
		// Adjust the Site Map overlay dimensions when it is opened.
		$('body.page-user-edit #overlay', context).each(function() {
			// adjust the overlay
			$(this).css({
				'width': '900px',
				'height': '630px',
         'overflow': 'scroll'
			});
			$('.page-user #overlay').center('window');
		});
	}
	
	

////  Edited by Ridoy 21st November 2011 STARTS  /////////////////////////

  Drupal.hunterTheme.behaviors.ridoy = function(context, settings) {
    // Adjust the explore the boot overlay dimensions when it is opened.
    $('.page-node #overlay', context).each(function() {
      // adjust the overlay
      $(this).css({
		       
      });
      $('.page-node #overlay').center('window');
    });
  }
////  Edited by Ridoy 21st November 2011  END   /////////////////////////
	
	
	// Checkout page behaviors
	Drupal.hunterTheme.behaviors.checkout = function(context, settings) {
		// Infield labels
		$('#commerce-checkout-form-authenticate label').inFieldLabels();
		$('#commerce-checkout-form-checkout label').inFieldLabels();
		$('#commerce-checkout-form-payment label').inFieldLabels();
		$('body.page-user-register label').inFieldLabels();
		$('body.page-user-edit label').inFieldLabels();
		
		// Click handler for the checkbox to hide the billing address.
		$('#edit-customer-profile-billing-same,#billing-same').click(function() {
			if (this.checked) {
				$('#edit-customer-profile-billing-commerce-customer-address,#billing_profile_details').slideUp();
				$('#edit-customer-profile-billing-field-customer-phone').slideUp();
			} else {
				$('#edit-customer-profile-billing-commerce-customer-address,#billing_profile_details').slideDown();
				$('#edit-customer-profile-billing-field-customer-phone').slideDown();
			}
		});
		
		// Set the correct default state of the items based on the checkbox value.
		// This is only needed if the user navigates back with a browser that
		// preserves form values.
		if ($('#edit-customer-profile-billing-same').is(':checked')) {
			$('#edit-customer-profile-billing-commerce-customer-address').hide();
			$('#edit-customer-profile-billing-field-customer-phone').hide();
		}
	}
	
	// Reisze and image to a given height
	Drupal.hunterTheme.resizeImgToHeight = function(img, newHeight) {
		var width, height;
		$("<img/>") // Make in memory copy of image to avoid css issues
		.load(function() {
			width = this.width;   // Note: $(this).width() will not
			height = this.height; // work for in memory images.
			var ratio = newHeight / height;
			var newWidth = width * ratio;
			img.attr('height', newHeight);
			img.attr('width', newWidth);
			img.css('display', 'inline')
		})
    .attr("src", img.attr("src"));
	}
	
	// Handler to move set the SRC of the main image in product_display overlay
	Drupal.hunterTheme.displayMainImage = function(src) {
      $('#main_image').fadeOut('fast', function() {
			$('#main_image').attr('src', src);
			$("<img/>") // Make in memory copy of image to avoid css issues
			.load(function() {
				Drupal.hunterTheme.resizeMainImage();
				$('#main_image').fadeIn('fast');
				$('.pd .alt_views').fadeIn('fast');
			})
      .attr("src", src);
		});
	}
	
	// Resize the main image in the product display overlay. Called when window
	// is resized.
	Drupal.hunterTheme.resizeMainImage = function() {
		var right = $('.pd .right');
		var imgRatio = $("#main_image").width() / $("#main_image").height();
		var boxRatio = right.width() / $('.pd').height();

		if (imgRatio >= boxRatio) {
			$("#main_image").css({width: right.width()-40, height:'auto'});
		} else {
			$("#main_image").css({height: $('.pd').height(), width:'auto'});
		}
		$("#main_image").center();
	}
	
	Drupal.hunterTheme.inlineFieldLabel = function (textInput, label) {
		if (textInput.val() == "") {
			var fieldLabel = label;         // string to put in your text input

			/* add the field label css class to the form field and set the value */
			textInput.addClass("intra-field-label").val(fieldLabel);

			/* remove the placeholder string when field gets focus */
			textInput.focus(function() {
				if (this.value == fieldLabel ) {
					$(this).removeClass("intra-field-label").val("");
				}
			});

			/* add the field label string when field looses focus */
			textInput.blur(function() {
				if(this.value == "") {
					$(this).addClass("intra-field-label").val(fieldLabel );
				};
			});

			/* if the field is set to the fieldLabel on submit, clear the field */
			form = textInput.parents("form");
			form.submit(function() {
				if(textInput.val() == fieldLabel) {
					textInput.removeClass("intra-field-label").val("");
				};
			});
		}
	};

	// Main theme behaviors
	Drupal.behaviors.hunterTheme = {
		attach: function (context, settings) {
			// Attach all theme specific behaviors
			Drupal.hunterTheme.attachBehaviors(context, settings);
			Drupal.hunterTheme.inlineFieldLabel($("#search-block-form .form-text", context), 'Search');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-first-name", context), 'First Name*');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-last-name", context), 'Last Name*');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-e-mail-address", context), 'Email Address*');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-phone-number", context), 'Phone Number');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-order-number", context), 'Order Number');
			Drupal.hunterTheme.inlineFieldLabel($("#webform-client-form-1941 #edit-submitted-inquiry", context), 'Type Your Massage');
		}
	}
	

})(jQuery, Drupal);

















;

