$(function(){
  $("#hero .btn, a.cta, .feature .img").click(function(){
    $("#interslide").addClass("active");
    $("#page").addClass("whiteout");
  });
  $("#crunchies").click(function(){
    window.location = "http://crunchies2011.techcrunch.com/vote/?NzozOA==";
  });
  $("#interslide #closeslide").click(function(){
    $("#interslide").removeClass("active");
    $("#page").removeClass("whiteout");
  });
  $("#device #inner").crossSlide({
    sleep: 4,
    fade: 1
  },[
  { src: 'images/ios/1p-opening.png' },
  { src: 'images/ios/2p-single.png'  },
  { src: 'images/ios/3p-list.png'    },
  { src: 'images/ios/4p-voice.png'   },
  { src: 'images/ios/5p-create.png'  }
  ]);
  var quotes, quotate, curQuote, nextQuote;
  quotes    = $(".quoteset");
  curQuote  = -1;
  nextQuote = -0;
  quotate   = function(firstRun) {
    return function() {
      var jQuote, fadeIn, fadeOut;
      fadeOut = function(elm, fn) { $(elm).fadeOut(fn) };
      fadeIn  = function(elm, fn) { return function() { $(elm).fadeIn(fn) } };
      ++curQuote;
      ++nextQuote;
      if (nextQuote == quotes.length) {
        nextQuote = 0;
      }
      fadeOut(quotes[(curQuote)], fadeIn(quotes[nextQuote]));
      if (curQuote == (quotes.length - 1)) {
        curQuote = -1;
      }
    }
  }
  quotes.not(":first").hide();
  setInterval(quotate(), 5000);
});
