(function (jQuery) {
        jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function (i, attr) {
            jQuery.fx.step[attr] = function (fx) {
                if (fx.state == 0) {
                    fx.start = getColor(fx.elem, attr);
                    fx.end = getRGB(fx.end);
                }

                fx.elem.style[attr] = "rgb(" + [
        Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
        Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
        Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
      ].join(",") + ")";
            }
        });
        function getRGB(color) {
            var result;

            if (color && color.constructor == Array && color.length == 3)
                return color;

            if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
                return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];

            if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
                return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];

            if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
                return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];

            if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
                return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];

            return colors[jQuery.trim(color).toLowerCase()];
        }

        function getColor(elem, attr) {
            var color;

            do {
                color = jQuery.curCSS(elem, attr);

                if (color != '' && color != 'transparent' || jQuery.nodeName(elem, "body"))
                    break;

                attr = "backgroundColor";
            } while (elem = elem.parentNode);

            return getRGB(color);
        };

        var colors = {
            white: [255, 255, 255],
            yellow: [255, 255, 0]
        };
    })(jQuery);

    jQuery.extend(jQuery.easing, {
        easeOutBack: function (x, t, b, c, d, s) {
            if (s == undefined) s = 1.70158;
            return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
        },
        easeOutElastic: function (x, t, b, c, d) {
            var s = 1.70158; var p = 0; var a = c;
            if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
            if (a < Math.abs(c)) { a = c; var s = p / 4; }
            else var s = p / (2 * Math.PI) * Math.asin(c / a);
            return a * Math.pow(2, -8 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
        },
        easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
      }
    });
  
//delayFirstChange Первый таймаут перед началом автоматического переключения  
//timeChange таймаут между авто переключением 
//step скорость движения полосы  
//nextChangeAnim анимация переключения фотки влево-вправо
 
  var albumnow;
  var defaultAlbum = 82;
$(function () {
    var site = 'http://www.zart.ru';
    var miniWidth = 108;
    var liWidth = miniWidth + 3;
    var liCount;
    var countLoaded;
    var allLiWidth;
    var curMousePos = 0;
    var mCurr;
    var step = 8;
    var ul = $('.miniplace ul');
    var ulHeight = $('.miniplace ul').height();
    var place = $('.miniplace');
    var full = $('#full');
    var topmenuplace = $('#place');
    var fullImg = full.children('img')
    var placeWidth = parseInt($('.miniplace').width());
    var halfPlace = placeWidth / 2;
    var placeDeathSpace = 100;
    var cursorOnDeathSpace = false;
    $('#prevphoto, #nextphoto').animate({ top: (($('.Tmain').height() - 90) / 2) }, 1000);
    var prevBut = $('#prevphoto');
    var nextBut = $('#nextphoto');
    var idleTimer;
    var changeTimer;
    var cursorOnMini = false;
    var timeChange = 7000;
    var delayFirstChange = 15000;
    var multyLeft = 0.15;
    var multyRight = -0.15;
    var loadingMini = false;
    var processNextClick = false;
    var nextChangeAnim = 'easeOutCirc';
    var curFullImg = new Image();
    $('.Tmenu li:has(li)').each(function (e) {
      $(this).attr('id', 'item-' + e);
    });
    $('.Tmenu').append('<li id="item-' + $('.Tmenu li:has(li)').size() + '"></li>');
  
        function createMini(imgArray, albumN) {
            var imgCnt = imgArray.length;
            //current loaded =0 and hide ulpanel
            countLoaded = 0;
            fullImg.fadeOut(500);
            loadingMini = true;
            
      ul.empty();
      //if<7
      while (imgCnt < 10) {
        for (i = 0; i < imgCnt; i++) {
          imgArray.push(imgArray[i])
        };
        imgCnt = imgArray.length;
      }

      liCount = imgCnt;
      allLiWidth = liWidth * liCount;
      mCurr = allLiWidth;
      var li = '';
      for (j = 0; j < imgCnt * 3; j++) {
        li += '<li id="num-' + j + '"><img src="/-gallery/img/ajax-loader.gif" style="border:0; width:32px; height:32px; margin:0 0 15px 39px;" alt="" />' +
        '<img class="img" src="' +site+ (imgArray[j % imgCnt].split('||')[0]) + '" data-full="'+site+(imgArray[j % imgCnt].split('||')[1])+'" style="display:none; width:' + miniWidth + 'px; height:69px;" alt="" /></li>';
      }
      ul.empty().css({ 'width': (miniWidth * 3 + 21) * imgCnt + 'px', 'left': '-' + allLiWidth + 'px' }).append(li);
      
    if(albumN == defaultAlbum)
    ul.hide();
    else
    ul.show();
    ul.animate({ 'top': 0 });
      for (i = 0; i < imgCnt; i++) {
        var curImg = new Image();
        curImg.src = site+imgArray[i].split('||')[0];
        curImg.number = i;
        curImg.count = imgCnt;
        (function (img) {
          img.onload = function () {
            countLoaded++;
            //Найти все места этой минифотки
            var thisPlace = $('.miniplace ul li#num-' + img.number + ', .miniplace ul li#num-' + (img.number + img.count) + ', .miniplace ul li#num-' + (img.number + (img.count * 2)));
            $(thisPlace).find('img:not(.img)').fadeOut(1, function () { $(this).remove(); });
            $(thisPlace).find('.img').show();
            //Сheck active
            if ((img.count / 3).toFixed(0) == img.number) {
              clickOnMini($('.miniplace ul li#num-' + (img.number + img.count) + ' .img'));
              //Создание таймера
              nullableTimer();
            }
            //Если загружена первая
            //if (countLoaded == 1) {
              //ul.animate({ 'top': 0 });
            //}
            //Последняя
            if (countLoaded == imgCnt) {
              setTimeout(function () {
                loadingMini = false;
              }, 1200);

              //обновить обработчик килика
              $('.miniplace ul li .img').click(function () {
                clickOnMini(this);
                nullableTimer();
              });
            }
          };
        })(curImg);
      }
        }


        var curMiniSel;


        $.fn.startAnim = function () {
            var nextStep;
            var duration;
            if ((curMousePos - placeDeathSpace) > halfPlace) {
                nextStep = -(mCurr + step)
                duration = parseInt(Math.abs(curMousePos - placeWidth)) + 20
                this.not(':animated').animate({ left: nextStep }, {
                    duration: duration,
                    easing: 'linear',
                    queue: false,
                    //step: moveCall,
                    complete: stopCallLeft
                });
                cursorOnDeathSpace = false;
            }
            if ((curMousePos + placeDeathSpace) < halfPlace) {
                nextStep = -(mCurr - step)
                duration = parseInt(curMousePos + 20)
                this.not(':animated').animate({ left: nextStep }, {
                    duration: duration,
                    easing: 'linear',
                    queue: false,
                    //step: moveCall,
                    complete: stopCallRight
                });
                cursorOnDeathSpace = false;
            }

            if ((curMousePos > (halfPlace - placeDeathSpace)) && (curMousePos < (halfPlace + placeDeathSpace))) {
                cursorOnDeathSpace = true;
            }
            return this;
        }

        $.fn.animateToMin = function () {
            return this.stop().animate({ width: miniWidth + 'px', height: '69px', left: '0' }, { duration: 200, easing: 'easeOutBack' });
        }

        $.fn.animateToMax = function () {
            return this.animate({ width: '144px', height: '92px', left: '-15px' }, { duration: 300, easing: 'easeOutBack' });
        }

        $.fn.checkActive = function (currentUlLeft, nextAnim) {
            var std = ((Math.abs(currentUlLeft) + curMousePos) / (liWidth))
      var numActive = Math.ceil((std) + multyRight) - 1;
            var hideOpt;
            var visualOpt;
            if (numActive < curMiniSel) {
                numActive = Math.floor((std) + multyLeft);
            }
            if ((curMousePos - placeDeathSpace) > halfPlace) {
                hideOpt = ':not(#num-' + numActive + ', #num-' + (numActive - liCount) + ')';
                visualOpt = '#num-' + numActive + ' .img:not(.activepic), #num-' + (numActive - liCount) + ' .img:not(.activepic)';
            } else {
                hideOpt = ':not(#num-' + numActive + ', #num-' + (numActive + liCount) + ')';
                visualOpt = '#num-' + numActive + ' .img:not(.activepic), #num-' + (numActive + liCount) + ' .img:not(.activepic)';
            }

            if (!loadingMini) {
                $('.activepic').parent('li').filter(hideOpt).css("z-index", "1").children('.img').removeClass('activepic').stop(true).animateToMin();
                $(visualOpt).stop(true).animateToMax().addClass('activepic').parent().css("z-index", "99");
            }
            curMiniSel = numActive;
            if (nextAnim) $(this).startAnim();
            return this;
        }


        function stopCallLeft() {
    //Если курсор на полоске Подождать окончания анимации
    if (cursorOnMini)
      setTimeout(function () {
        var currentUlLeft = parseInt($(ul).css('left'))
        mCurr += step;
        if (currentUlLeft <= -((allLiWidth) * 2).toFixed(0)) {
          mCurr -= (allLiWidth);
          currentUlLeft = parseInt($(ul).css('left'))
          $(ul).css({ 'left': '-' + mCurr + 'px' }).checkActive(currentUlLeft, true);
        } else {
          $(ul).checkActive(currentUlLeft, true);
        }
      }, 1);
        }

        function stopCallRight() {
            //Если курсор на полоске Подождать окончания анимации
            if (cursorOnMini)
                setTimeout(function () {
                    var currentUlLeft = parseInt(ul.css('left'))
                    mCurr -= step;
                    if ((currentUlLeft >= 0)) {
                        mCurr += (allLiWidth);
                        currentUlLeft = parseInt(ul.css('left'))
                        $(ul).css({ 'left': '-' + mCurr + 'px' }).checkActive(currentUlLeft, true);
                    } else {
                        $(ul).checkActive(currentUlLeft, true)
                    }
                }, 1)
        }

        place.mouseenter(function (e) {
      if(loadingMini) return false;
            curMousePos = Math.floor((e.pageX - $('.miniplace').offset().left));
            var std = ((Math.abs(parseInt($(ul).css('left'))) + curMousePos) / (liWidth))
      var numActive = Math.ceil((std) + multyRight) - 1;
            var posEntry = 0; //по дефолту вход справа
            if (curMousePos < halfPlace) posEntry = 1; //Если вход слева
            curMiniSel = Math.ceil((std) - 0.90) - posEntry;
            $(ul).checkActive(parseInt(ul.css('left')), true);
            cursorOnMini = true;
            //убрать инфулл
                //Если курсор на мини 
        if(cursorOnMini){
          var infullthis = false;
          //проверяем не на инфулл ли
          $('.infull').parent().each(function(){
            if ($(this).attr('id').split('-')[1]==numActive) infullthis=true;
          });
          if(!infullthis){
            $('.infull').animateToMin();
          }
        }
        });

        place.mouseleave(function () {
    if(loadingMini) return false;
            var onSuccessCnt = 0;
      $('.activepic').parent().css("z-index", "2").find('.activepic').filter(':not(.infull)').stop(true).animate({ width: miniWidth + 'px', height: '69px', left: '0' }, { duration: 350, easing: 'easeOutBack', complete: function () {
                $(this).parent().css("z-index", "1");
        //Зумить только если курсор не на мини
        if(!cursorOnMini && onSuccessCnt==0){
          $('.infull').stop(true).animateToMax().parent().css("z-index", "44");
          //Выполнять 1 раз по complete
          onSuccessCnt++;  
        }
            }}).removeClass('activepic');
      cursorOnMini = false;
      //если небыло complete а была только infull
      if(onSuccessCnt==0){
        $('.infull').stop(true).animateToMax().parent().css("z-index", "44");
      }
            nullableTimer();
        });

        place.mousemove(function (e) {
            curMousePos = Math.floor((e.pageX - place.offset().left));
            var currentUlLeft = parseInt(ul.css('left'))
            $(ul).checkActive(currentUlLeft, cursorOnDeathSpace);
            //$('.infull').animateToMin();
        });


        //full
        function clickOnMini(_this) {
            $('#loader-ajax').fadeIn(200);
            $('.infull').parent('li').css("z-index", "1").find('.img').animateToMin().removeClass('infull');
            var numThis = $(_this).parent().attr('id').split('-')[1];
            $('#num-' + numThis + ', #num-' + (numThis - liCount) + ', #num-' + (parseInt(numThis) + liCount)).children('.img').animateToMax().addClass('infull').parent().css("z-index", "44");
            fullImg.fadeOut(300, function () {
                var fullSrc = $(_this).data('full');
                curFullImg.src = fullSrc;
                fullImg.attr('src', fullSrc);
                curFullImg.onload = function () {
                    $('#loader-ajax').fadeOut(200)
                    fullImg.fadeIn(800);
                    processNextClick = false;
                };
            });
        }

        function nextClick() {
            if (processNextClick) return false;
            processNextClick = true;
            var inall = $('.infull').eq(1).parent();
            var eqnum = 1;
            if (inall.attr('id').split('-')[1] >= (liCount * 2))
                eqnum = 0;
            ul.animate({ left: '-=' + liWidth }, {
                duration: 1000,
                easing: nextChangeAnim,
                queue: false,
                complete: function () {
                    mCurr += liWidth;
                    var currentUlLeft = parseInt($(ul).css('left'))
                    if (currentUlLeft <= -((allLiWidth) * 2).toFixed(0)) {
                        mCurr -= (allLiWidth);
                        $(ul).css({ 'left': '-' + mCurr + 'px' })
                    }
                }
            }).find('.infull').eq(eqnum).parent().next().children('.img').checkShe();
        }

        function prevClick() {
            if (processNextClick) return false;
            processNextClick = true;
            var inall = $('.infull').eq(1).parent();
            var eqnum = 1;
            if (inall.attr('id').split('-')[1] <= (liCount))
                eqnum = 2;
            ul.animate({ left: '+=' + liWidth }, {
                duration: 1000,
                easing: nextChangeAnim,
                queue: false,
                complete: function () {
                    var currentUlLeft = parseInt(ul.css('left'))
                    mCurr -= liWidth;
                    if (currentUlLeft >= 0) {
                        mCurr += (allLiWidth);
                        currentUlLeft = parseInt(ul.css('left'))
                        $(ul).css({ 'left': '-' + mCurr + 'px' })
                    }
                }
            }).find('.infull').eq(eqnum).parent().prev().children('.img').checkShe();
        }

        function nullableTimer() {
            clearTimeout(idleTimer);
            clearInterval(changeTimer);
            idleTimer = setTimeout(function () {
                changeTimer = setInterval(function () {
                    if (!cursorOnMini/* && tabIsActive*/) {
                        if (ul.filter(':animated').size() == 0) {
                            nextClick();
                        } else {
                            //Если анимируется пропустить анимацию, но узнать куда кликать
                            var inall = $('.infull').eq(1).parent();
                            var eqnum = 1;
                            if (inall.attr('id').split('-')[1] >= (liCount * 2))
                                eqnum = 0;
                            ul.find('.infull').parent().next().eq(eqnum).children('.img').checkShe();
                        }
                    }
                }, timeChange);
            }, delayFirstChange);
        }

        $.fn.checkShe = function () {
            clickOnMini(this)
        }

        nextBut.click(function () {
            if (ul.filter(':animated').size() == 0) {
                nextClick();
            }
            nullableTimer();
        });

        prevBut.click(function () {
            if (ul.filter(':animated').size() == 0) {
                prevClick();
            }
            nullableTimer();
        });

        //////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<MENU

        function visMenu() {    //Плавное появление
            $('.auto-item').each(function (e) {
                (function (i) {
                    setTimeout(function () {
                        $('.auto-item').eq(i).fadeIn(40).css({ 'left': '-28px' }).animate({ 'left': '0' }, { duration: 800, easing: 'easeOutElastic' });
                    }, 80 * i);
                })(e);
            });
        }

        function visaulMove($old, $oldPlace, $new, newOffsetTop, callback) {
            var newOffset = $oldPlace.offset();
            if (newOffsetTop != undefined) {
                newOffset.top += newOffsetTop;
            }
            //Get the old position relative to document
            var oldOffset = $old.offset();
            //we also clone old to the document for the animation
            var $temp = $old.clone().appendTo('body');
            //hide new and old and move $temp to position
            //also big z-index, make sure to edit this to something that works with the page
            $temp
    .css('position', 'absolute')
    .css('left', oldOffset.left - 8)
    .css('top', oldOffset.top)
    .css('zIndex', 1000)
      .css('visibility', 'visible');
            //animate the $temp to the position of the new img
            $temp.animate({ 'top': newOffset.top, 'left': newOffset.left - 8 }, 400, function () {
                //callback function, we remove $old and $temp and show $new
                $temp.remove();
                $oldPlace.css({ 'visibility': 'visible' });
                $new.css({ 'visibility': 'visible' });
                callback();
            });
        }

    function elasticThis(_this){
      $(_this).find('li').hide().each(function (e) {
        (function (i) {
          setTimeout(function () {
            $(_this).find('li').eq(i).fadeIn(30).css({ 'left': '-28px' }).animate({ 'left': '0' }, { duration: 600, easing: 'easeOutElastic' });
          }, 60 * i);
        })(e);
      });
    }
    
        $.fn.inBack = function (_newthis) {
            if ((_newthis.parent().attr('id') == "place")) {
                if (_newthis.parent().hasClass('pexpand')) {
                    topmenuplace.animate({ 'height': '18px' });
                    _newthis.find('ul').slideUp();
                    topmenuplace.toggleClass('pexpand pclose')
                } else {
                    topmenuplace.animate({ 'height': '200px' });
                    _newthis.find('ul').slideDown();
          elasticThis(_newthis.find('ul'));
                    topmenuplace.toggleClass('pclose pexpand')
                }
            } else {
                if (!topmenuplace.hasClass('pexpand')) {
                    topmenuplace.removeClass('pclose').addClass('pexpand')
                    topmenuplace.animate({ 'height': '200px' });
                }
                var topOffset = -18;
                var shift = 1;
                //old == in places
                //Олд это то что сверху.
                var $old = $(this).css({ 'visibility': 'hidden' });
                var topNum = parseInt($($old).attr('id').split('-')[1])
                if ((topNum + 1) == $(_newthis).attr('id').split('-')[1]) {
                    shift = +2;
                }
                //Олд плейс это то место где он был + сдвиг
                var $oldPlace = $('#item-' + (topNum + shift));
                //new == new selected
                var $new = $(_newthis).css({ 'visibility': 'hidden' });
                if (($new.index() != topNum) && ($new.index() != (parseInt(topNum) + 1)) && ($new.index() != (parseInt(topNum) + 1))) {
                    $new.slideUp(250);
                    $('#item-' + (parseInt(topNum) + 1)).before('<li id="tmpp" style="display:none;">&nbsp;</li>');
                    $('#tmpp').slideDown(250);
                    $oldPlace = $('#tmpp');
                    topOffset = 0;
                    if ($oldPlace.index() > $new.index())
                        topOffset = -18;
                }
                $old.find('ul').hide()
                $new.find('ul li').hide()

                //сверху вниз
                visaulMove($old, $oldPlace, $new, topOffset, function () {
                    $('#item-' + (parseInt($($old).attr('id').split('-')[1]) + 1)).before($($old));
                    $('#tmpp').remove();
                    //$oldPlace == куда едет
                    //new == where click
                    //$old == in top
                })

                visaulMove($new, $old, $oldPlace, undefined, function () {
                    $($new).show().appendTo('#place');
                    $($new).find('ul').show();
                    elasticThis($($new));
                    //new == where click
                    //$old == in top
                    //$oldPlace == куда едет
                })
            }
        };

        //////////////////<<<<<<<<<<<<SCROLL

        function setScrolls() {
            var DragHandler = {
                _oElem: null,

                attach: function (oElem) {
                    oElem.onmousedown = DragHandler._dragBegin;
                    oElem.dragBegin = new Function();
                    oElem.drag = new Function();
                    oElem.dragEnd = new Function();
                    return oElem;
                },

                _dragBegin: function (e) {
                    var oElem = DragHandler._oElem = this;
                    var x = parseInt(oElem.style.left);
                    var y = parseInt(oElem.style.top);
                    e = e ? e : window.event;
                    oElem.mouseX = e.clientX;
                    oElem.mouseY = e.clientY;
                    oElem.dragBegin(oElem, x, y);
                    document.onmousemove = DragHandler._drag;
                    document.onmouseup = DragHandler._dragEnd;
                    return false;
                },
                _drag: function (e) {
                    var oElem = DragHandler._oElem;
                    var x = parseInt(oElem.style.left);
                    var y = parseInt(oElem.style.top);
                    e = e ? e : window.event;
                    var setY = e.clientY - oElem.parentNode.getBoundingClientRect().top + 'px';
                    if (parseInt(setY) <= $(oElem).parent().height() - 20 && parseInt(setY) >= 1) {
                        oElem.style.top = setY
                        var HeightInner = $(oElem).parent().next().children().children().height() * $(oElem).parent().next().children().children().size();
                        var HeightOuter = $(oElem).parent().next().height();
                        var marg = HeightOuter - HeightInner;
                        var scrollBody = Math.abs(marg) / ($(oElem).parent().height() - 25);
                        var curTop = parseInt($(oElem).css('top')) * scrollBody;
                        $(oElem).parent().next().children().css('margin-top', '-' + curTop + 'px')
                    }
                    return false;
                },

                _dragEnd: function () {
                    var oElem = DragHandler._oElem;
                    document.onmousemove = null;
                    document.onmouseup = null;
                    DragHandler._oElem = null;
                }
            };
            $('.auto-item').each(function (e) {
                var scrollableHeight = $(this).find('.scrollable').children().height() * $(this).find('.scrollable').children().size();
                if ($(this).children('ul').height() < scrollableHeight) {
                    $(this).find('.scrollable').parent().before('<div class="scrollline"><div class="slider" id="sl' + e + '"></div></div>');
                    DragHandler.attach(document.getElementById('sl' + e));
                }
            });
        }
        /////////////////// >>>>>>>>>>>>>SCROLL
        ///////////////// >>>>>>>>>>MENU


        //Клик по эл-ту для раскрытия списка
        $('.Tmenu .parentli').click(function (e) {
            $('#place li:has(li)').inBack($(this).parent());
            return false;
        });

        //Наведение на меню
        $('.Tmenu .parentli').hover(function (e) {
            $(this).animate({ 'color': 'yellow' }, 100).prev().animate({ left: '7px' }, 170).css({ 'background-position': 'bottom' })
        }, function (e) {
            $(this).stop(true).animate({ 'color': 'white' }, 100).prev().stop(true).animate({ left: '0px' }, 170).css({ 'background-position': 'top' })
        });

        //Выбор тачки
        $('.Tmenu li ul li a, .Tmenu li p.parentli').click(function(e) {
      if($(this).parents('#place').size()!=0 && $(this).hasClass('parentli')) return false;
            selectCar(this)
            return false;
        });
    
     //Выбор тачки
        $('.Tmenu #place li p.parentli').one('click', function(e) {
      if($(this).parents('#place').size()==0) return false;
            selectCar(this)
            return false;
        });
    
    function selectCar(_this){
      if(supports_history_api())
        history.pushState(null, null, $(_this).attr('href'));
            init($(_this));
    }

    function supports_history_api() {
      return !!(window.history && history.pushState);
    }
    
    function preChangeHide(){
      $('#loader-ajax').fadeIn(500);
      fullImg.fadeOut(500);
      ul.animate({ 'top': ulHeight + 'px' },500);
    }
    
        function init(_this) {
      preChangeHide();
      setTimeout(function(){
        $.getJSON(site+'/ajax.html', { a: (_this==albumnow || _this==defaultAlbum) ? _this : $(_this).attr('name') }, function (result) {
          var arrayImg = new Array();
          if (result.imgs.length < 1) return false;
          for (el in result.imgs) {
            arrayImg.push(result.imgs[el].file);
          }
          createMini(arrayImg, _this);
        });
      },501);
        }

        
    visMenu();
    init(albumnow!=undefined ? albumnow : defaultAlbum);
    setScrolls();
        
        //$('.Tmenu .parentli:eq(0)').trigger('click');
    });
