$.extend({
    initCarousel:function(_div, _count, _thumbWidth) {

        var _holder = $(_div).find('div.mask').find('div.holder');
        var _thumbs = _holder.children('a.thumb');
        var _nav = $(_div).find('div.nav').find('a');
        var _currentPage = 0;
        var _currentLink = 0;
        var _thumbCount = _count;

        if (!_thumbWidth)
		    _thumbWidth = 102;

        _thumbWidth += 10;

        _thumbs.each(function(i) {
            $(this).css('left',(_thumbWidth*i));
        });

        if (_thumbs.length > _thumbCount) {

            _nav.bind('click', function(e) {
                e.preventDefault();

                if ($(this).hasClass('nav-next')) {
                    _currentPage++;
                    if (_currentPage > _thumbs.length-_thumbCount)
                        _currentPage = 0;

                } else {

                    _currentPage--;
                    if (_currentPage < 0)
                        _currentPage = _thumbs.length-_thumbCount;

                }

                _holder.stop().animate({'left':-(_currentPage*_thumbWidth)}, 200, 'easeInOutExpo');

                return false;
            });
        } else
            _nav.hide();

        return;

    }
});

