/**
	citation fader
	@author Christian Niedrich @farbwahl
	@mail christian.niedrich@highgain.de
	@date   10.2010

**/

(function($) {

	/* plugin for periodical fade of citation */
	$.fn.citations = function(settings, staticContentUrl) {

	settings = jQuery.extend({
		duration: 	5000 	// (int) display time of an citation
	},settings);

	var citations = $(this).find('blockquote');
	var active_citation = 0;
	var amount_citations = citations.length;

	//set styles to citations
	citations.each(function(){
		var e = $(this);
		var url = "url('" + staticContentUrl + "/themes/kde_2011/img/index/quotes/"+ e.attr('class')+".png')";
		e.css('backgroundImage',url).hide();
	});

	//fade in first
	$(citations[active_citation]).fadeIn();

	//crossfader
	var _fadeToNext = function(){
		$(citations[active_citation]).fadeOut();
		active_citation++;

		if(active_citation == amount_citations)
			active_citation = 0;

		$(citations[active_citation]).fadeIn();
	};

	//start intervall
	window.setInterval(_fadeToNext, settings.duration);
	return this;
	};


})(jQuery);
