(function($) {
    // définition du plugin
    $.fn.switchtext = function(options) {  
        var defaults = {
            classText: ".text",
            duration: 2000,
            outText:"plaqueRue",
	        wait: 5000
        };   

    var opts = $.extend(defaults, options); 
	var textes = new Array();
	var current = 0;
	var slide = this;

	function init(){		
		 $(opts.classText).each(function(i){
		  	textes.push($(this).html());
		 });
	}

	function start(){
		var text = textes[current];
		var self = $(this);		
		$(slide).html(text);
		$(slide).fadeIn("slow");
		current++;
		if(current==textes.length)
			current=0;
		$(this).queue(function () {setTimeout(function() {$(self).dequeue();}, opts.wait);});

		$(slide).fadeOut(opts.duration,start);	
			
	}

	init();
	start();
        return $(this);      
    };
})(jQuery);



