function ImgBig(el,src)
{
    var src = src || el.src;
	var flag = 0;
	if(!document.getElementById('imgs')){
        $(document.body).append('<div id="imgs" onclick="this.style.display=\'none\';document.getElementById(\'i\').src=\'\';" style="box-shadow: 1px 1px 20px #FFFFFF;-webkit-box-shadow: 2px 5px 10px #FFFFFF;background-color:#130D31;border:1px solid #885300;color:#FFFFFF;cursor:pointer;display:none;font-size:11px;padding:2px;position:absolute;text-align:left;z-index:999;"><div style="float:right;padding:3px;">Закрыть</div><img id="i" src="" alt=""><div id="imgs-des" style="font-size:12px;padding:0px 20 0px 0px;padding:10px;color:#1E4DB3;font-weight:bold;"></div></div>');
    }
	var i = document.getElementById('i');
    var e = document.getElementById('imgs');
	var imgdes = document.getElementById('imgs-des');

	setTimeout(function(){
					if(flag == 0){
						//i.src = "/img/loading.gif";
                        i.style.display = "none";
						var coor = Block(300,50);
						e.style.top = coor[1] + 'px';
						e.style.left = coor[0] + 'px';
						e.style.width = "300px";
						e.style.height = "50px";

						if(imgdes.lastChild != null) imgdes.removeChild(imgdes.lastChild);
						imgdes.appendChild(document.createTextNode("загрузка фото ..."));
						e.style.display = 'block';
					}
	}, 1000);

	var pic = new Image();
		pic.onload = function()
		{
			flag = 1;
            var ttl = el.alt || el.title;
            var title = document.createTextNode(ttl);
			var coor = Block(pic.width,pic.height);
				e.style.top = coor[1]*1 - 40 + 'px';
				e.style.left = coor[0] + 'px';
				e.style.width = pic.width + "px";
				e.style.height = pic.height + 60 + "px";
				i.src = pic.src;
				i.style.display = "block";
				if(imgdes.lastChild != null) imgdes.removeChild(imgdes.lastChild);
				imgdes.appendChild(title);
				e.style.display = 'block';
		}
	pic.src = src;
}

function Block(width,height)
{
	var d = document.documentElement;
	var top = d.scrollTop || document.body.scrollTop;
	var y = Math.floor((d.clientHeight - height)/2) + top;
	var x = Math.floor((d.clientWidth - width)/2);
	return [x,y];
}
function MapBig(w,h,m,cD,cSh,bD,bSh,des){        //m - zoom, cD - center Dolgota, pSh - baloon Shirota
    if(document.getElementById('yam')) $('#yam').remove();
    $(document.body).append('<div id="yam"><div class="close" onclick="$(\'#yam\').remove()">закрыть [x]</div><div id="YMapsID" style="width:800px;height:500px;margin:5px;"></div></div>');
    var yam = document.getElementById('yam');
    var coor = Block(w,h);
        yam.style.top = coor[1] + 50 + 'px';
        yam.style.left = coor[0] + 'px';
        yam.style.width = w + 10 + "px";
        yam.style.height = h + 40 + "px";
        yam.style.position = 'absolute';
        yam.style.zIndex = '999';
        yam.style.display = 'block';
        yam.style.border = '1px solid #B5B5B5';
        yam.style.backgroundColor = '#000000';

    var map = new YMaps.Map(document.getElementById("YMapsID"));
        map.setCenter(new YMaps.GeoPoint(cD,cSh), m);
        map.openBalloon(new YMaps.GeoPoint(bD,bSh), des, {hasCloseButton:true});
    var zoom = new YMaps.Zoom({ customTips: [ { index: 1, value: "Мелко" },{ index: 9, value: "Средне" },{ index: 16, value: "Крупно" } ] });
        map.addControl(zoom);
        map.addControl(new YMaps.TypeControl());
}


$(function(){
var IE = '\v' == 'v';
var IE7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
var IE8 = (navigator.appVersion.indexOf("MSIE 8.")==-1) ? false : true;

var mist = {};
    mist.item = { "igrey":"c" };
    mist.opacity = { "0":"0", "1":"0.1", "2":"0.2", "3":"0.3", "4":"0.4", "5":"0.5", "6":"0.6", "7":"0.7", "8":"0.8", "9":"0.9", "10":"1" }
    mist.opacityIE = { "0":"0", "1":"10", "2":"20", "3":"30", "4":"40", "5":"50", "6":"60", "7":"70", "8":"80", "9":"90", "10":"100" }
    mist.move = 0;

    mist.Anim = function (pointer, e, id){
    if(pointer == 'color'){ // fading
         mist.item[id] = "g";
        var counter = 1;
        setTimeout(function(){
            if(mist.item[id] != "g"){
                return;
            }
            counter = counter + 1;
            if(IE){
                document.getElementById(id+"-img").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+mist.opacityIE[counter]+")";
            } else {
                document.getElementById(id+"-img").style.opacity = mist.opacity[counter];
                e.style.textShadow = "black -2px 2px 2px";
            }
            if(counter<10){
                setTimeout(arguments.callee, 70);
            }
        }, 0);
    } else {
        mist.item[id] = "c";
        var counter = 10;
        setTimeout(function(){
            if(mist.item[id] != "c"){
                return;
            }
            counter = counter - 1;
            if(IE){
                document.getElementById(id+"-img").style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+mist.opacityIE[counter]+")";
            } else {
                document.getElementById(id+"-img").style.opacity = mist.opacity[counter];
                e.style.textShadow = "none";
            }
            if(counter>0){
                setTimeout(arguments.callee, 70);
            }
        }, 0);
    }
}

var jet = {};

jet.init = function (){
    if(IE7){
        $('#wings').remove();
    }
    var stl = '';
    var htm = '';
    $('.b-top').height(357);
    var len = jet.arr.length;
    for(var i = 0; i < len; i += 1){
        if(i>2){
            stl = 'display:none';
        }
        htm += '<li id="'+jet.arr[i].id+'li" style="width:280px;'+stl+'">' +
                '<div class="mist-item" id="carousel'+jet.arr[i].id+'">' +
                '<a href="'+jet.arr[i].href+'">' +
                        '<div class="mist-ani-radius" style="background:url('+jet.arr[i].src+') top center no-repeat;" id="'+jet.arr[i].id+'"></div>'+
                        '<div class="mist-shadow-block"><div class="mist-shadow-radius" id="'+jet.arr[i].id+'shadow"></div>'+
                    '</div>'+
                '</a>' +
                '</div></li>';
    }
    htm += '';
    $('#banner').append('<ul class="carousel" id="ulcarousel">'+htm+'</ul>');
}

jet.arr = arrCarousel; //jet.arr = [ { src:"/img/carousel/ani1.jpg", id:"ani0", href:"/", price:"", title: "" } ];

if(jet.arr.length>2){
    jet.init();
}

mist.AniCar = function () {
    var item = {firstId: '', lastId: '', lastSrc: ''};
    var ul =  document.getElementById('ulcarousel').childNodes;
    var len = ul.length;
    var lid;
    for (var i=0; i<len; i +=1) {
        if (ul[i].style.display == "") {
            item.firstId = ul[i].id.split("li")[0];

            if (document.getElementById(ul[i+3].id)) {
                item.lastId = ul[i+3].id.split("li")[0];
                for (var j in jet.arr) {
                    if (jet.arr[j].id == item.lastId) {
                        item.lastSrc = jet.arr[j].src;
                    }
                }
            } else {
                return;
            }
            break;
        };
    }

    var o = {
            shag : [2, 4, 8, 17, 35, 70, 140, 285],
            shagTop : [30, 100, 140, 170, 120, 70, 10, 0],
            heightLeft : 280,
            paddingTopLeft : 0,
            heightLeftPx : '',
            carL : document.getElementById('carousel'+item.firstId).style,
            aniL : document.getElementById(item.firstId).style,
            aniLLi : document.getElementById(item.firstId+'li').style,
            aniLrg : document.getElementById(item.firstId+'rg').style,
            carR : document.getElementById('carousel'+item.lastId).style,
            aniRLi : document.getElementById(item.lastId+'li').style,
            heightRight : 0,
            paddingTopRight : 280,
            heightRightPx : '',
            aniR : document.getElementById(item.lastId).style
        }
    if(IE){
        document.getElementById(item.firstId+'rg').width = "";
        document.getElementById(item.firstId+'rg').height = "";
        document.getElementById(item.firstId+'ie').width = "";
        document.getElementById(item.firstId+'ie').height = "";
    }
    if(document.getElementById(item.firstId+'canvas')){
        o.aniLcanvas = document.getElementById(item.firstId+'canvas').style;
    }
        var shagTempLeft = [].concat(o.shag);
        var shagTempRight = [].concat(o.shag);
        var shagTempTop = [].concat(o.shagTop);
    setTimeout(function(){

        o.heightLeft = shagTempLeft.pop(); //goto Min
        o.heightRight = shagTempRight.shift(); // goto Max
        o.paddingTopLeft = shagTempTop.shift(); //vector left moving


        o.carL.width = o.heightLeft + "px";
        o.carL.paddingTop = o.paddingTopLeft + "px";
        o.aniL.height = o.heightLeft + "px";
        o.aniL.width = o.heightLeft + "px";
        o.aniLLi.width = o.heightLeft + "px";
        o.aniLrg.height = o.heightLeft + "px";
        o.aniLrg.width = o.heightLeft + "px";

        if(document.getElementById(item.firstId+'canvas')) {
            o.aniLcanvas.height = o.heightLeft + "px";
            o.aniLcanvas.width = o.heightLeft + "px";
        }

        if(o.aniRLi.display == 'none'){
            o.aniR.height = '10px';
            o.aniR.width = '10px';
            o.carR.height = '0px';
            o.carR.width = '0px';
            o.aniRLi.display = '';
        }

        o.paddingTopRight = o.heightLeft;
        o.aniR.height = o.heightRight + "px";
        o.aniR.width = o.heightRight + "px";
        o.carR.height = o.heightRight + "px";
        o.carR.width = o.heightRight + "px";
        o.carR.paddingTop = o.paddingTopRight + "px";

        if(document.getElementById(item.firstId).offsetHeight>2){
            setTimeout(arguments.callee, 100);
        } else {
            o.aniLLi.width = '0px';
            o.aniLLi.display = 'none';
            if(!IE8){
                mist.Reflection(item.lastSrc, item.lastId, false, false, 290);
            }
            setTimeout(function () {
                mist.AniCar();
            }, 3000);
        }
    }, 0);
}

setTimeout(function () {
    if (IE7) {
        return;
    } else {
        if(document.getElementById('ulcarousel')) {
            var len = jet.arr.length;
            var per = Math.floor(100/len);
            var total = 0;
            var arrImg = [];
            var wings = document.getElementById('wings');

            for (var j in jet.arr) {
                arrImg[j] = {};
                arrImg[j].i = new Image();
                arrImg[j].i.onload = function () {
                    len -= 1;
                    if(len == 1){    //replace 0 to 1 for start animation
                        $('#wings').remove();
                        mist.AniCar();
                    } else {
                        total = total + per;
                        wings.innerHTML = total + '%';
                    }
                };
                arrImg[j].i.src = jet.arr[j].src;
            }
        }
    }
}, 1000);

var razdel = document.location.href.match(/[a-z]+$/)+"";


if(document.getElementById(razdel)){
    mist.Anim('color',document.getElementById(razdel),razdel);
    document.getElementById(razdel).className = "";
} else{
    if(document.getElementById('urlRazdel')){
        var urlRazdel = document.getElementById('urlRazdel').value;
        if(urlRazdel != ''){
            urlRazdel = urlRazdel.match(/[a-z]+$/)+"";
            mist.Anim('color',document.getElementById(urlRazdel),urlRazdel);
        } //document.getElementById(urlRazdel).className = "";
    }
}

$('.logo').click(function(){
    document.location.href = '/';
});

$('.menu-td').mouseenter(function(e){
        mist.Anim('color',document.getElementById($(this).attr('id')),$(this).attr('id'));
});
$('.menu-td').mouseleave(function(e){
        mist.Anim('grey',document.getElementById($(this).attr('id')),$(this).attr('id'));
});
$('.menu-td').click(function(e){
    document.location.href = $("#"+$(this).attr('id')+" a").attr("href");
});

var i = new Image();
    i.onload = function(){
        $('.listalka').css({ "margin-top": "-"+($('.long-radius').height()/2 + 20)+"px" });
    }
    i.src = $('.long-radius img').attr('src');

mist.Reflection = function(src,id,heightGradient,pngCorner,reflectionWidth){
    var heightGradient = heightGradient || 90;
    var pngCorner = pngCorner || '/img/rg.png';
    if(IE){
        var i = new Image();
            i.id = id+'ie';
            i.style.zIndex = -1;
            i.style.position = 'absolute';
            document.getElementById(id+'shadow').appendChild(i);
            i.onload = function(){
                i.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity=50, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=20)';
                if(document.getElementById('banner')){
                    if(IE8){
                        i.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity=0, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=20)';
                    }
                }
            }
            i.src = src;
    } else {
        var canvas = document.createElement('canvas');
        document.getElementById(id+'shadow').appendChild(canvas);
        if (canvas.getContext) {
            var i = new Image();
            i.onload = function(){
                var reflectionWidth = reflectionWidth || document.getElementById(id).offsetWidth;
                var reflectionHeight = document.getElementById(id).offsetHeight;
                var imageHeight = reflectionHeight;
                var context = canvas.getContext("2d");

                canvas.className = 'mist-radius';
                canvas.id = id+'canvas';
                canvas.style.zIndex = -1;
                canvas.style.position = 'absolute';
                canvas.style.height = reflectionHeight+'px';
                canvas.style.width = reflectionWidth+'px';
                canvas.height = reflectionHeight;
                canvas.width = reflectionWidth;

                context.save();
                context.translate(0,imageHeight-1);
                context.scale(1,-1);
                context.drawImage(i, 0, 0, reflectionWidth, reflectionHeight);
                context.restore();
                context.globalCompositeOperation = "destination-out";

                var gradient = context.createLinearGradient(0, 0, 0, heightGradient);
                    gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
                    gradient.addColorStop(0.5, "rgba(255, 255, 255, 0.8)");

                context.fillStyle = gradient;
                context.rect(0, 0, reflectionWidth, reflectionHeight*2);
                context.fill();
            }
            i.src = src;
        }
    }
    var rg = new Image();
        rg.src = pngCorner;
        rg.id = id+'rg';
        rg.style.zIndex = 2;
        rg.style.position = 'absolute';
        document.getElementById(id+'shadow').appendChild(rg);
}
if(document.getElementById('banner')){
    mist.Reflection(jet.arr[0].src,jet.arr[0].id);
    mist.Reflection(jet.arr[1].src,jet.arr[1].id);
    mist.Reflection(jet.arr[2].src,jet.arr[2].id);
} else{
    $('.shapka-radius').each(function(index){
        var img = ($(this).attr('style').match(/\("*([^"]+)"*\)/i))[1];//.match(/\(([^"]+)?\)/i)[1];
        var id = (img.match(/\/(\d+)\//i))[1];
        mist.Reflection(img,'shapka'+id, 50, '/img/rg1.png', 180);
    });
}

    mist.imageZoom = function (e) {
        if(document.getElementById('zoomId')){
            return false;
        }
        var img = new Image(),
        e = e,
        param = {
            title: '',
            id: e.attr('id'),
            zoomId:  e.attr('rel').match(/\/([^/]+)\.\w{3}$/)[1],
            radius: '15px',
            widthImg: 0,
            heightImg: 0,
            heightViewport: 0,
            widthViewport: 0,
            top: document.documentElement.scrollTop || document.body.scrollTop,
            k: 5,                //k koaficient zapasa width and height ramki
            imgSrc: '',
            arrRel: [],
            arrTitle: [],
            arrId: [],
            itemp: {},
            listalka: {left: { opacity: 1 }, right: { opacity: 1 }},
            loading: function () {},
            hash: function (hash) { window.location.hash = hash; }
        };

        param.hash(param.id.split("hashimg")[0]);

        param.title = e.attr('title');
        param.des = $('#'+param.id+' > .des-hidden').html();
        $('.zoom').each(function(index){
            param.arrRel[index] = $(this).attr('rel');
            param.arrTitle[index] = $(this).attr('title');
            //param.arrId[index] = $(this).attr('id').split("hashimg")[0];
        });

        param.loading = function (flag) {
            var flag = flag || 0;
            if(flag==0){
                $('#zoombg').html('<div id="loading" style="opacity:0;width:650px;height:450px;display:block;position:absolute;background-color:#130D31;"><img src="/img/cherry28.png" style="margin-top:225px;"><br><img src="/img/loading.gif" style="padding-top:5px"></div>');
                $('#loading').animate({ opacity: 1 }, 800, function() {});
                //$('#zoombg div').css({opacity:0})
            } else {
                $('#zoombg').innerHTML = '';
                $('#loading').css({ opacity: 1 });
            }
        }


        img.onload = function(){
            param.imgSrc = img.src.match(/(\/images.+)/)[1];
            param.widthImg = img.width;
            param.heightImg = img.height;
            param.heightViewport = $(window).height();
            param.widthViewport = $(window).width();

            param.offsetTop = Math.floor((param.heightViewport - 500 - param.k)/2);
            param.offsetLeft = Math.floor((param.widthViewport - 780 - param.k)/2);
            //param.offsetTop = Math.floor((param.heightViewport - param.heightImg - param.k)/2);
            //param.offsetLeft = Math.floor((param.widthViewport - param.widthImg - param.k)/2);

            img.style.visibility = 'hidden';

        $(document.body).append('<div id="'+param.zoomId+'" style="left:'+param.offsetLeft+'px;opacity:0;display:none;" class="radiusimg20">' +
                '<ul class="long-img"><li><img class="listalka listalkaL" src="/img/knLeft.png"></li>' +
                '<li style="width:650px;height:450px;">' +
                '<center style="display:block;height:450px;vertical-align:middle"><div id="zoombg" style="display:block;width:'+param.widthImg+'px;height:'+param.heightImg+'px;background-image:url('+img.src+');background-position:center center" class="radius10"></div></center>' +
                '<div id="loading" style="z-index:111;margin-top:-450px;width:650px;height:450px;display:block;position:absolute;background-color:#130D31;"><img src="/img/cherry28.png" style="margin-top:225px;"><br><img src="/img/loading.gif" style="padding-top:5px"></div>' +
                '</li>' +
                '<li><img class="listalka listalkaR" src="/img/knRight.png"></li>' +
                '<li style="vertical-align:top"><div id="zoomClose" class="zoomClose">x</div></li></ul>' +
                '<div id="zoomtitle" style="color:#ffffff;padding:20px;margin:3px 0 0 10px;position:absolute;">'+param.title+'</div>'+
                '<div><div class="zoomdetail" style="width:'+(img.width-40)+'px;">'+param.des+'</div><div id="zoomdes">подробнее ...</div>'+
                '</div>');

        $('#zoomdes').click(function (e) {
            if(IE8){
                $('.zoomdetail').css({ 'background-color': '#FFFFFF' });
            }
            $('.zoomdetail').css({ 'left':($('#zoombg').position().left+10)+'px', 'margin-top': '-150px', 'height': '120px'}); //'+($('#'+(param.imgSrc.match(/.+?\/(\d+)?\/.+?/)[1])+'hashimg > .des-hidden').height()+30)+'
            $('.zoomdetail').slideToggle();
        });


        $('.listalkaR').click(function () {
            $('.zoomdetail').slideUp();
            for(var i = 0; i < param.arrRel.length; i += 1){
                if (param.arrRel[i] == param.imgSrc) {
                    if((i+1) < param.arrRel.length){
                        $('#loading').animate({ opacity: 1 }, 800, function() {
                            param.itemp = new Image();
                            param.itemp.onload = function () {
                                $('.zoomdetail').html($('#'+(param.arrRel[i+1].match(/.+?\/(\d+)?\/.+?/)[1])+'hashimg .des-hidden').html());  //refresh description of model
                                $('.zoomdetail').css({'width':(param.itemp.width - 40)+'px'});  //refresh description of model
                                param.imgSrc = param.arrRel[i+1];
                                var s = document.getElementById('zoombg').style;
                                    s.width = param.itemp.width+'px';
                                    s.height = param.itemp.height+'px';
                                    s.backgroundImage = 'url('+param.arrRel[i+1]+')';
                                    document.getElementById('zoomtitle').innerHTML = param.arrTitle[i+1];
                                $('#loading').animate({ opacity: 0 }, 800, function() {
                                    if(IE){
                                        $(this).css('filter','progid:DXImageTransform.Microsoft.Alpha(opacity=0)');
                                    }
                                });
                            }
                            param.itemp.src = param.arrRel[i+1];
                            param.imgSrc = param.arrRel[i+1];
                            //param.hash(param.arrId[i+1]);
                        });
                    }
                    break;
                }
            }
            if(i==param.arrRel.length -2){
                $('.listalkaR').animate({opacity: 0}, 800, function() {});
                param.listalka.right.opacity = 0;
            }
            if(param.listalka.left.opacity == 0){
                $('.listalkaL').animate({opacity: 1}, 800, function() {});
                param.listalka.left.opacity = 1;
            }
        });
        $('.listalkaL').click(function () {
            $('.zoomdetail').slideUp();
            for(var i = param.arrRel.length; i > 0; i -= 1){
                if (param.arrRel[i] == param.imgSrc) {
                    $('#loading').animate({ opacity: 1 }, 800, function() {
                        param.itemp = new Image();
                        param.itemp.onload = function () {
                            $('.zoomdetail').html($('#'+(param.arrRel[i-1].match(/.+?\/(\d+)?\/.+?/)[1])+'hashimg .des-hidden').html());  //refresh description of model                            param.imgSrc = param.arrRel[i-1];
                            $('.zoomdetail').css({'width':(param.itemp.width - 40)+'px'});  //refresh description of model
                            var s = document.getElementById('zoombg').style;
                                s.width = param.itemp.width+'px';
                                s.height = param.itemp.height+'px';
                                s.backgroundImage = 'url('+param.arrRel[i-1]+')';
                                document.getElementById('zoomtitle').innerHTML = param.arrTitle[i-1];
                            $('#loading').animate({ opacity: 0 }, 800, function() {
                                if(IE){
                                    $(this).css('filter','progid:DXImageTransform.Microsoft.Alpha(opacity=0)');
                                }
                            });
                        }
                        param.itemp.src = param.arrRel[i-1];
                        param.imgSrc = param.arrRel[i-1];
                        //param.hash(param.arrId[i-1]);
                    });
                break;
                }
            }
            if(i==1){
                $('.listalkaL').animate({opacity: 0}, 800, function() {});
                param.listalka.left.opacity = 0;
            }
            if(param.listalka.right.opacity == 0){
                $('.listalkaR').animate({opacity: 1}, 800, function() {});
                param.listalka.right.opacity = 1;
            }
        });

        var div = document.getElementById(param.zoomId);
            if(IE){
                $('#zoomClose').addClass('radius10').css({'background-color':'#505050'});
            }
            param.top = document.documentElement.scrollTop || document.body.scrollTop;
            div.style.top = (param.offsetTop + param.top) + 'px';
            var zIds = document.getElementById(param.zoomId).style;
            zIds.zIndex = '99';
            zIds.opacity = '0.5';
            zIds.display = 'block';
            document.getElementById('zoomClose').style.zIndex = '100';
            $('#'+param.zoomId).animate({ opacity:1.0 }, 1200, function () {});
            $('#wrap').animate({ opacity:0.2 }, 700, function () {});

            $('#zoomClose').click(function (){
                $('#'+param.zoomId).animate({ opacity:0 }, 1200, function () {
                    document.getElementById(param.zoomId).style.zIndex = '-1';
                    document.getElementById('zoomClose').style.zIndex = '-1';
                    $('#wrap').animate({ opacity:1 }, 700, function () {});
                    $('#'+param.zoomId).remove();
                });
            });
            for(var i = 0; i < param.arrRel.length; i += 1){
                if (param.arrRel[i] == param.imgSrc) {
                    if(i==0){
                        $('.listalkaL').animate({opacity: 0}, 800, function() {});
                        param.listalka.left.opacity = 0;
                    }
                    if(i==param.arrRel.length -1){
                        $('.listalkaR').animate({opacity: 0}, 800, function() {});
                        param.listalka.right.opacity = 0;
                    }
                    break;
                }
            }
        }
        img.src = e.attr('rel');
    };

    mist.imageZoomIE7 = function (e) {
        var img = new Image(),
        param = {
            title: '',
            radius: '15px',
            widthImg: 0,
            heightImg: 0,
            heightViewport: 0,
            widthViewport: 0,
            top: document.documentElement.scrollTop || document.body.scrollTop,
            k: 5                //k koaficient zapasa width and height ramki
        };
        param.title = e.attr('alt');
        img.onload = function(){

            param.widthImg = img.width;
            param.heightImg = img.height;
            param.heightViewport = $(window).height();
            param.widthViewport = $(window).width();

            param.offsetTop = Math.floor((param.heightViewport - param.heightImg - param.k)/2);
            param.offsetLeft = Math.floor((param.widthViewport - param.widthImg - param.k)/2);

            img.style.visibility = 'hidden';

            $(document.body).append('<div id="zoomId" style="background-image:url('+img.src+');width:'+param.widthImg+'px;height:'+param.heightImg+'px;left:'+param.offsetLeft+'px;z-index:-1;position:absolute;display:none;cursor:pointer;border:1px solid #fff">' +
                    '<img src="'+img.src+'">' +
                    '<div id="zoomClose" style="margin:3px 0 0 -30px;display:block;position:absolute;width:25px;height:25px;float:right;z-index:100;line-height:23px;font-family:Arial;background-color:#BBBBBB;border:1px solid #fff;font-size:19px;text-align:center;">x</div>' +
                    '</div>');
            $('#zoomId').css({'opacity':0});

            param.top = document.documentElement.scrollTop || document.body.scrollTop;
            var zId = document.getElementById('zoomId').style;
            zId.top = (param.offsetTop + param.top) + 'px';
            zId.zIndex = '99';
            zId.display = 'block';
            document.getElementById('zoomClose').style.zIndex = '100';
            $('#zoomId').animate({ opacity:1.0 }, 1200, function () {});

            $('#zoomId').click(function (){
                $(this).animate({ opacity:0 }, 1200, function () {
                    document.getElementById('zoomId').style.zIndex = '-1';
                    document.getElementById('zoomClose').style.zIndex = '-1';
                    $('#zoomId').remove();
                });
            });

        }
        img.src = e.attr('rel');
    }

    $('.zoom').click(function() {
        if(IE7){
            mist.imageZoomIE7($(this));
        } else {
            mist.imageZoom($(this));
        }
    });
    if(IE7){
        if(document.location.href.match(/[^/]+?$/) == null){
            $('.div-menu-horizontal').css({ 'margin-top': '1px' })
        } else {
            $('.div-menu-horizontal').css({ 'margin-top': '120px' })
        }

    } else {
        var hashImg = document.location.href.split("#")[1];
        if(document.getElementById(hashImg+'hashimg')){
            mist.imageZoom($('#'+hashImg+'hashimg'));
        }
    }
});
