// JavaScript Document
(function() {
  var $;
  $ = jQuery;
  $.fn.slideshowify = function(options) {
    var settings;
    settings = $.extend({}, $.fn.slideshowify.defaults, options);
    return this.each(function() {
      var $clickers, $g, $next, $prev, $slides, animating, autoplay, currentClicker, currentSlide, o;
      $g = $(this);
      o = settings;
      $slides = $g.addClass("slideshow-active").find("ul>li").hide();
      $clickers = $("<div class='slideshow-links'></div>");
      currentSlide = animating = currentClicker = false;
      autoplay = 0;
      $next = $("<a href='#' class='next-slide'>Next slide</a>").click(function() {
        if (currentClicker.length && currentClicker.next().length) {
          currentClicker.next().click();
        } else {
          $clickers.find("a:first").click();
        }
        return false;
      });
      $prev = $("<a href='#' class='prev-slide'>Previous slide</a>").click(function() {
        if (currentClicker.length && currentClicker.prev().length) {
          currentClicker.prev().click();
        } else {
          $clickers.find("a:last").click();
        }
        return false;
      });
      if (o.autoplay > 0 && o.hoverToPause) {
        $g.hover(function() {
          clearTimeout(autoplay);
        }, function() {
          autoplay = setTimeout((function() {
            return $next.click();
          }), o.autoplay * 1000);
        });
      }
      $slides.each(function(i) {
        var $clicker, $slide;
        $slide = $(this);
        return $clicker = $("<a href='#slide-" + (i + 1) + "' class='slide" + (i + 1) + "'>Show slide " + (i + 1) + "</a>").click(function() {
          if (animating || currentSlide === $slide.index()) {
            return false;
          }
          if (o.autoplay > 0) {
            clearInterval(autoplay);
            autoplay = setTimeout((function() {
              return $next.click();
            }), o.autoplay * 1000);
          }
          animating = true;
          currentClicker = $clicker;
          if ($clicker.next().length) {
            $next.show();
          } else {
            $next.hide();
          }
          if ($clicker.prev().length) {
            $prev.show();
          } else {
            $prev.hide();
          }
          $clicker.addClass("current").siblings().removeClass("current");
          $slide.css({
            zIndex: 2
          }).fadeIn(250, function() {
            $slide.css({
              zIndex: 1
            }).siblings().hide();
            return animating = false;
          });
          currentSlide = $slide.index();
          return false;
        }).appendTo($clickers);
      });
      if ($slides.length > 1) {
        $g.append($clickers);
      }
      $clickers.find("a:first").click();
      if (o.autoplay > 0) {
        autoplay = setTimeout((function() {
          return $next.click();
        }), o.autoplay * 1000);
      }
      return this;
    });
  };
  $.fn.slideshowify.defaults = {
    autoplay: 0,
    hoverToPause: true
  };
  $(document).ready(function() {
    var objImage;
    if (navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
      $('html').addClass('idevice');
    }
    objImage = new Image();
    objImage.src = 'http://new.ricebowls.org/static/img/logo-shadow.png';
    return $(objImage).load(function() {
      $('#container>header h1 div').delay(100).fadeIn(1600);
    });
  });
}).call(this);

