/*sertificate*/
function theRotator() {
	$('div#sertificate ul li').css({opacity: 0.0});
	$('div#sertificate ul li:first').css({opacity: 1.0});
	setInterval('rotate()',5000);
}

function rotate() {
	$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
	
	var current = ($('div#sertificate ul li.show')?  $('div#sertificate ul li.show') : $('div#sertificate ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#sertificate ul li:first') :current.next()) : $('div#sertificate ul li:first'));	
 
	// Расскомментируйте, чтобы показвать картинки в случайном порядке
	// var sibs = current.siblings();
	 //var rndNum = Math.floor(Math.random() * sibs.length );
	 // var next = $( sibs[ rndNum ] );
	next.wait(1500,'fx');
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000);
	current.animate({opacity: 0.0}, 1000).removeClass('show');
};
 
 
/*proizvoditel*/
function theRotator2() {
	$('div#rotator ul li').css({opacity: 0.0});
	$('div#rotator ul li:first').css({opacity: 1.0});
	setInterval('rotate2()',5000);
}

function rotate2() {
	
	$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
	
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
 
	// Расскомментируйте, чтобы показвать картинки в случайном порядке
	// var sibs = current.siblings();
	 //var rndNum = Math.floor(Math.random() * sibs.length );
	 // var next = $( sibs[ rndNum ] );
	
	next.wait(1500,'fx');
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000);
	current.animate({opacity: 0.0}, 1000).removeClass('show');
};
 
$(document).ready(function() {		
	theRotator();
	theRotator2();
});
