/*
 * Yagooar JQuery Generic Banner
 * Jquery simple banner implementation
 *
 * @author Mateusz Sojka yagooar@gmail.com
 * @version 0.1
 *
 * @license Released under the GNU General Public License v3.0
 *
 */
var J = jQuery.noConflict();

J(document).ready(function() {
    init();
});

function init() {
    config = {
        "width"     :    "942", // Ancho del banner
        "height"    :    "141", // Altura del banner
        "effect"    :    "fade", // Efecto de transición (por ahora sólo está disponible fade)
        "speed"     :    3000 // Tiempo en pantalla de cada elemento
    };

    bannerYJQG(config);
}

function bannerYJQG(config) {

    banner = J('#bannerYJQG');
    elements = J('#image_list_YJQG');

    banner.css('width', config.width);
    banner.css('height', config.height);

    J(elements).find('li:not(.activeYJQG)').hide();

    if (config.effect == 'fade') {
        fade(elements, config);
    }

}

function fade(elements, config) {

    var toggleFade = function() {
        if (elements.find('.activeYJQG'))
        elements.find('.activeYJQG')
            .fadeOut('slow', function() {
                J(this).removeClass('activeYJQG');
                if (J(this).next('li').length > 0) {
                    J(this)
                    .next('li')
                    .fadeIn('slow')
                    .addClass('activeYJQG');
                } else {
                    J(elements).find('li:first')
                    .fadeIn('slow')
                    .addClass('activeYJQG');
                }

            })
    }
    
    setInterval(toggleFade, config.speed);

}




