var slideParrafos = {
    num : -1,
    parrafo : 0,
    parrafos : [],

    delay : 8000,
    timeout : null,

    run : function ( obj, delay ) {
        this.delay = delay || this.delay;

        var parrafos = obj.children('p');
        for (var p=0; p<parrafos.length; p++) {
            this.parrafos[p] = $(parrafos[p]).remove().html();
        }

        this.parrafo = $( document.createElement('p') );
        obj.append( this.parrafo );

        this.cambiar();
	if (this.parrafos.length > 1) {
            this.timeout = window.setInterval(function () { slideParrafos.cambiar(); }, this.delay);
	}
    },
    getTexto : function () {
        if ( (++this.num) >= this.parrafos.length) {
            this.num = 0;
        }
        return this.parrafos[ this.num ];
    },
    cambiar : function () {
        if (slideParrafos.parrafos.length <= 0) { return false;}

        slideParrafos.parrafo.fadeOut('slow', function () {
            slideParrafos.parrafo.html( slideParrafos.getTexto() ).fadeIn('slow');
        });
    }
}

$(document).ready(function () {
    slideParrafos.run( $('#noticias'), 8000 );
});
