﻿(function($) {
    //
    $.fn.adidoGlint = function(options) {
        var opts = $.extend({}, $.fn.adidoGlint.defaults, options);
        return this.each(function() {
            $this = $(this);
            var w = $this.width();
            var css = {
                'position': 'relative'
            };
            $this.css(css);

            $gmask = $('<span class="glint-mask"></span>');
            $geffect = $('<span class="glint-effect"></span>');

            $gmask.append($geffect);
            $this.append($gmask);

            var gew = $geffect.width();
            var css = {
                'top': opts.topOffset,
                'left': -gew
            };
            $geffect.css(css);

            var glintTimer = setInterval(function() {
                $geffect.animate({
                    left: w
                }, opts.animSpeed, function() { $geffect.css({ 'left': -gew }) });
            }, opts.speed);

        });
    };

    $.fn.adidoGlint.defaults = {
        animSpeed: 200,
        speed: 5000,
        topOffset: 0
    };
})(jQuery);
