﻿$(window).load(function(evt) {
    $("#homeSlideShow").catSlidShow({ slideShowSpeed: slideShowSpeed });
});

(function($) {
    $.fn.catSlidShow = function(o) {
        o = $.extend({
            slideShowSpeed: 5000
        }, o || {});
        var div = $(this);
        var wrapDiv = div;
        var ul = $("ul", div);
        var li = $("li", ul);
        var ControlA = $(".controls .makeMid .Mid a");
        li.hide();
        li.eq(0).show();
        ControlA.eq(0).attr("class", "curr");

        if (li.length > 1) {
            var MyMar = setInterval(showImg, o.slideShowSpeed);
            ControlA.click(function() {
                clearInterval(MyMar);
                var currSIndex = ControlA.index($(this)[0]);
                li.eq(currSIndex).fadeIn("slow").siblings("li").hide();
                ControlA.removeAttr("class");
                $(this).attr("class", "curr");
                MyMar = setInterval(showImg, o.slideShowSpeed);
            });

        };
        function showImg() {
            var currLI = ul.find("li:visible");
            var currIndex = li.index(currLI[0]) + 1;
            if (currIndex >= li.length)
                currIndex = 0;
            ControlA.removeAttr("class");
            ControlA.eq(currIndex).attr("class", "curr");
            li.eq(currIndex).fadeIn("slow").siblings("li").hide();
        };

    };

})(jQuery);
     
   
     


