/**
* lanteraSlider.js special for Cata site.
* @copyright Lantera-Studio
* http://lantera-studio.com
* @author Mukovoz Oleg
*/

$.fn.slider = function(options) {
    
    var root = $(this);
    var current = 0;
    
    var slides = $(this).children();
    
    /*HIDE ALL SLIDES*/
    var temp  = 0;
    slides.each(function(){
        $(this).css('position','relative');
        if (temp!=0){
            $(this).css('top',-1*($(this).innerHeight())*temp+"px");
        }
        temp++;  
        $(this).animate({opacity:0},1);
    });
    
    
    
    /*Show first slide*/
    $(slides[current]).animate({opacity:1},1);
    
    
    function next()
    {
       
       $(slides[current]).animate({opacity: 0},1000); 
       
       current++;
       if (current == slides.length)
            current = 0; 
    
       $(slides[current]).animate({opacity: 1},1000); 
       
       setTimeout(function(){next();},options.delay);
    }
    
      setTimeout(function(){next();},options.delay);
  
}

