/*
* SimpleSlideshow, a basic crossfade slideshow for jQuery
* http://snook.ca/archives/javascript/simplest-jquery-slideshow
* By: Jonathan Snook
* 
* Converted to jQuery function by Mathias Bynens
* http://snook.ca/archives/javascript/simplest-jquery-slideshow#c64387
*/

$.fn.simpleslideshow = function(transitionInterval, transitionSpeed) {
  var $elem = this;
  this.children(':gt(0)').hide();
  
  /*
  * GravDept
  * Copy <img> source to each slide's background-image style
  * Required for background-size:cover behavior
  * <img> is hidden via CSS
  */
  this.children().each(function () {
    $(this).css('background-image', 'url('+ $(this).children(':first').attr('src') +')');
  });
  
  // SimpleSlideshow
  setInterval(function() {
    $elem.children().eq(0).fadeOut(transitionSpeed).next().fadeIn(transitionSpeed).end().appendTo($elem);
  }, transitionInterval || 3000);
};
