// quotes rotator
// iwp.su
(function($) {
	$.fn.quotator = function(settings) {
		var config = {'interval': 10000};

		if (settings)
			$.extend(config, settings);
		
		var set = this;
		
		if (set.length > 1) {
			$(set).each(function(i) {
				if (i == 0)
					$(this).addClass('quotator_active').show();
				else
					$(this).hide();
			});
			
			setInterval(function() {
				var current = null;
				var next = null;
				$(set).each(function(i) {
					if ($(this).hasClass('quotator_active'))
					{
						current = this;
						next = (set[i+1]) ? set[i+1] : set[0];
					}
				});
				$(current).removeClass('quotator_active').fadeOut(1000);
				$(next).addClass('quotator_active').fadeIn(1000);
			}, config.interval);
		}
		
		return this;
	};
})(jQuery);
