﻿(function ($) {
    $.fn.jWIBannerCarousel = function (o) {
        o = $.extend({
            idBannerPosition: 0,
            cssClass: '',
            width: 0,
            height: 0
        }, o || {});
        maxHeight = 0;
        $(this).hide();
        $(this).children("a").each(function(index){
            var img = new Image();
            img.src = $(this).children("img").attr("src");
            if(img.height > maxHeight)
                maxHeight = img.height;

        });
        /*var divMain = $("<div>")
            .addClass("conteudo_pags_banners")
            .insertAfter($(this));

        var ul = $("<ul>")
            .attr("id", "ulBannerPosition" + o.idBannerPosition)
            .appendTo(divMain);*/

        $(this).css("width", o.width + "px");
        $(this).css("height", maxHeight + "px");
        $(this).cycle({
            fx: 'fade',
            speed: 'slow',
            timeout: 7000,
            pager: "#ulBannerPosition" + o.idBannerPosition,

            /*pagerAnchorBuilder: function (idx, el) {
                return '<li><a href="#">' + (idx + 1) + '</a></li>';
            }*/
        });
        $(this).show();
    };
})(jQuery);
