/// <reference path="~\Headers\Scripts\jquery-1.3.2-vsdoc.js" />
if (jQuery) (function($) {

    $.fn.Ads = function(options) {
        var settings = $.extend({}, $.fn.Ads.defaults, options);
        var owner = $(this);

        SwitchImage(-1);

        function SwitchImage(IgnoreIndex) {
            var intCount = $("img", owner).size();
            var intCurrent = -1;
            do {
                intCurrent = Math.floor(Math.random() * intCount);
            } while (intCurrent == IgnoreIndex);

            if ($("img.active", owner).size() > 0) {

                $("img.active", owner).fadeOut("slow", function() {
                    $(this).removeClass("active");
                    $("img:eq(" + intCurrent + ")", owner).fadeIn("slow", function() {
                        $(this).addClass("active");
                        setTimeout(function() { SwitchImage(intCurrent) }, settings.TickCount);
                    });
                });
            }
            else {
                $("img:eq(" + intCurrent + ")", owner).fadeIn("slow", function() {
                    $(this).addClass("active");
                    setTimeout(function() { SwitchImage(intCurrent) }, settings.TickCount);
                });
            }
        }
    };

    $.fn.Ads.defaults = {
        TickCount: 2500
    };

})(jQuery);