﻿(function ($) {
 $.fn.slideshow = function (option) {
 var config = {
 current: 0, // current selected index
 max: 0, // how many 
 duration: 2000, // speed between animation
 slideUpSpeed: "fast", //
 slideDownSpeed: "fast", //
 fadeInSpeed: "fast", //
 fadeOutSpeed: "fast", //
 easing: null, // not in use
 callback: null// not in use
 }
 config = $.extend(config, option);
 var self = this,
timer = null;
 $(self).find(".paragraph .text").hide().eq(0).fadeIn(0);
 $(self).find(".paragraph img").hide().eq(0).fadeIn(0);
 config.current = 0;
 config.max = self.find("div .text").length;
 doAnimate = function (current, next) {
 setTimeout(function () {
 $(self).find(".paragraph .text").eq(current).fadeOut(config.fadeOutSpeed);
 $(self).find(".paragraph .text").eq(next).fadeIn(config.fadeInSpeed);
 }, 300);
 $(self).find(".paragraph img").eq(current).fadeOut(config.fadeOutSpeed);
 $(self).find(".paragraph img").eq(next).fadeIn(config.fadeInSpeed);
 }
 start = function () {
 timer = setTimeout(function () {
 var next = config.current + 1;
 if (next >= config.max) {
 next = 0;
 }
 doAnimate(config.current, next);
 config.current = next;
 start();
 }, config.duration);
 }
 start();
 return self;
 };
})(jQuery);
