(function($){  

    $.fn.slideContent = function(vars) {
        var element     = this;
        var timeOut     = (vars.timeOut != undefined) ? vars.timeOut : 4000;
        var transition 	= (vars.transition != undefined) ? vars.transition : 1000;
        var elementId = $(this).attr('id');
        
        var next = function() {
        	activeSlide = $('#' + elementId + ' div.slide.active');
        	nextSlide = $('#' + elementId + ' div.slide:not(.active)').first();
        	activeSlide.fadeOut(transition, function(e){
        		cloneSlide = activeSlide.removeClass('active').clone();
        		activeSlide.remove();
                nextSlide.fadeIn(transition).addClass('active');
                $('#' + elementId).append(cloneSlide); 
                setTimeout( function(){ next() }, timeOut );
        	});
        }
        $('#' + elementId + ' .slide:first').addClass('active');
        setTimeout( function(){ next() }, timeOut );
    };
    
    $.fn.reloadContent = function(vars) {
        var element     = this;
        var timeOut     = (vars.timeOut != undefined) ? vars.timeOut : 4000;
        var elementId = $(this).attr('id');
        
        var next = function() {
        	$('#' + elementId).load('widget.php', function() {
        		$('#' + elementId + ' .slide:first').addClass('active');
        		setTimeout( function(){ next() }, timeOut );
        	});
        }
        setTimeout( function(){ next() }, timeOut );    	
    };
    
})(jQuery);
