/**
* Slideshow
*
* Copyright (c) 2010 Denis Vishniakov
* 
* @author 	Denis Vishniajov denis.a.vishniakov@gmail.com
* @version 1.0.0
*/

function SlideShow(cfg) {
  cfg = cfg || {};
  this.show = cfg.show || 'slideshow'; 
  this.interval = cfg.interval || 1000;
  this.animInterval = cfg.animInterval || 500;
  var index = 0;

  var s = jQuery('.'+this.show);
  s.children('*:not(:first)').css({opacity: 0.0});  
  
  this.nextSlide = function() {
    var n = index + 1;
    if(n >= s.children('*').length) n = 0;    
    var next = s.children('*').eq(n);
    var prev = s.children('*').eq(index);
    prev.css({zIndex:0});
    next.css({zIndex:1});
    next.animate({opacity: 1.0}, this.animInterval, function() { prev.css({opacity: 0.0}); });
    index = n; 
  };
  
  this.start = function() {
    var scope = this;
    setInterval(function() { scope.nextSlide(); }, this.interval);
  }

}



  
  
  

