jQuery.fn.imageSwitcher = function(timeoutStart, timeoutEnd) {
  var elem = jQuery(this);
  
  setInterval(
    function() {
      //Get the first image if no one is showing
      if (elem.find('ul li.show')) {
        var current = elem.find('ul li.show');
      } else {
        var current = elem.find('ul li:first');
      }
      
      //Get next image. When it reaches the end, rotate it back to the first image
      if (current.next().length && !current.next().hasClass(' show')) {
        var next = current.next()
      } else {
        var next = elem.find('ul li:first');
      }
      
      //Set the fade in effect for the next image, the show class has higher z-index
      next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0});
      
      //Hide the current image
      current.animate({opacity: 0.0}).removeClass('show');
    },
    (Number(timeoutStart) + Number((Math.random() * (timeoutEnd - timeoutStart)).toFixed(0)))
  );
};
