﻿$.MozatFeaturesCycle = {
    Start: function(picBox, pageBox, indexAttrName, fxMode) {
        $(pageBox).html("");
        $(picBox).children().each(function() {
            $('<a ' + indexAttrName + '="' + $(this).attr(indexAttrName) + '" href="#"><span></span></a>').appendTo($(pageBox));
        });
        var mode = 'fade';
        if (fxMode) mode = fxMode;
        var pics = $(picBox).cycle({
            fx: mode,
            timeout: 3000,
            next: picBox,
            pause: 1,
            before: function() {
                $(pageBox + " a").each(function() { $(this).removeClass("activeSlide"); });
                $(pageBox + " a[rel='" + $(this).attr(indexAttrName) + "']").addClass("activeSlide");
            }
        });

        $(pageBox + " a").each(function() {
            $(this).click(function() {
                var index = ($(this).attr(indexAttrName) / 1);
                $(pics).cycle(index);
                return false;
            });
        });
    }
}
