function initGallery() {
    jQuery.noConflict();
    jQuery('.gallery-flow').each(function() {
        var _this = this;
        _this.moove = jQuery(_this).find('ul');
        _this.list = jQuery(_this).find('ul > li');
        _this.curent = 3;
        _this.k = 0.8;
        _this.offset = 4;
        _this.duration = 500;
        _this.center = {};
        _this.center.x = (jQuery(_this).width() - _this.list.innerWidth()) / 2;
        _this.center.y = (jQuery(_this).height() - _this.list.innerHeight()) / 2;
        _this.btnPrev = jQuery('.btn-prev', _this);
        _this.btnNext = jQuery('.btn-next', _this);
        _this.onChangeFunc = function() {
            var _gal = this;
            var _text = jQuery('.panel .description', _gal);
            var _curText = _gal.list.eq(_gal.curent - 1).find('.hidden-decription').html();
            _text.animate({
                opacity: 0
            }, (jQuery.browser.msie ? 0 : _gal.duration / 2), function() {
                _text.html(_curText).animate({
                    opacity: 1
                }, (jQuery.browser.msie ? 0 : _gal.duration / 2), function() {
                    jQuery(this).css('opacity', 'auto');
                });
            })
        };
        //def settings
        _this.moove.css({
            position: 'relative',
            width: jQuery(_this).width(),
            height: jQuery(_this).height()
        });
        jQuery(_this).css({
            position: 'relative',
            width: jQuery(_this).width(),
            height: jQuery(_this).height()
        });
        _this.list.css({
            position: 'absolute',
            left: _this.center.x
        });
        _this.list.each(function() {
            this.data = {
                width: jQuery(this).innerWidth(),
                height: jQuery(this).innerHeight(),
                top: jQuery(this).position().top,
                left: jQuery(this).position().left
            }
        });
        _this.def = {
            width: _this.list.eq(_this.curent - 1).get(0).data.width,
            height: _this.list.eq(_this.curent - 1).get(0).data.height,
            top: _this.list.eq(_this.curent - 1).get(0).data.top,
            left: _this.list.eq(_this.curent - 1).get(0).data.left
        }

        //get element position
        function getPositions() {
            jQuery.noConflict();
            var _prevEls = _this.list.eq(_this.curent - 1).prevAll();
            var _nextEls = _this.list.eq(_this.curent - 1).nextAll();

            _this.list.eq(_this.curent - 1).get(0).data = {
                width: _this.def.width,
                height: _this.def.height,
                top: _this.def.top,
                left: _this.def.left
            }

            if (_prevEls.length) {
                _prevEls.each(function() {
                    this.data = {
                        width: jQuery(this).next().get(0).data.width * _this.k,
                        height: jQuery(this).next().get(0).data.height * _this.k,
                        top: (jQuery(_this).height() - jQuery(this).next().get(0).data.height * _this.k) / 2,
                        left: jQuery(this).next().get(0).data.left - jQuery(this).next().get(0).data.width * _this.k - _this.offset
                    }
                })
            }
            if (_nextEls.length) {
                _nextEls.each(function() {
                    this.data = {
                        width: jQuery(this).prev().get(0).data.width * _this.k,
                        height: jQuery(this).prev().get(0).data.height * _this.k,
                        top: (jQuery(_this).height() - jQuery(this).prev().get(0).data.height * _this.k) / 2,
                        left: jQuery(this).prev().get(0).data.left + jQuery(this).prev().get(0).data.width + _this.offset
                    }
                })
            };
        }
        //get position at start 
        getPositions();

        function moveToDefault() {
            jQuery.noConflict();
            if (jQuery.isFunction(_this.onChangeFunc)) {
                _this.onChangeFunc.apply(_this);
            }
            _this.list.each(function() {
                jQuery(this).animate({
                    width: this.data.width,
                    height: this.data.height,
                    top: this.data.top,
                    left: this.data.left
                }, _this.duration);
            });
        }
        //moove elements on page load to start position
        moveToDefault();

        // element clicked
        _this.list.click(function() {
            var _ind = _this.list.index(this) + 1;
            if (_ind != _this.curent) {
               
                _this.curent = _ind;
                getPositions();
                moveToDefault();
                return false;
            }
             
            
            
        });
        //next && prev buttons
        if (_this.btnPrev && _this.btnPrev.length) {
            _this.btnPrev.click(function() {
                if (_this.curent > 1) _this.curent -= 1;
                else _this.curent = _this.list.length;
                getPositions();
                moveToDefault();
                return false;
            });
        }
        if (_this.btnNext && _this.btnNext.length) {
            _this.btnNext.click(function() {
                if (_this.curent < _this.list.length) _this.curent += 1;
                else _this.curent = 1;
                getPositions();
                moveToDefault();
                return false;
            });
        };
    });
};
jQuery.noConflict(); 
jQuery(window).bind('load',function(){
	initGallery();
});
