var IE = '\v' == 'v';
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 #885300;-webkit-box-shadow: 2px 5px 10px #885300;background-color:#F0B837;border:1px solid #885300;color:#A06208;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);
            var height = pic.height + 60;
            if(document.documentElement.clientHeight<height){
                e.style.top = '0';
            } else {
                e.style.top = coor[1]*1 - 40 + 'px';
            }
				e.style.left = coor[0] + 'px';
				e.style.width = pic.width + "px";
				e.style.height = height + "px";
				i.src = pic.src;
				i.style.display = "block";
                i.className = "ie6pngfix";
				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 Recount() {
    var good = [];
    $('.amount').each(function(index){
        good.push($(this).attr('name')+':'+$(this).val());
    });
    var goodarr = good.join(";");
    document.getElementById('goodarr').value = goodarr;
    document.getElementById('form-recount').submit();
}


$(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":"g" };
    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, grey, color, zIndex1, zIndex2){
    if(pointer == 'color'){
        mist.item[grey] = "g";
        var counter = 10;
        setTimeout(function(){
            if(mist.item[grey] != "g"){
                return;
            }
            counter = counter - 1;
            if(IE){
                document.getElementById(grey).style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+mist.opacityIE[counter]+")";
            } else {
                document.getElementById(grey).style.opacity = mist.opacity[counter];
            }
            if(counter==9){
                document.getElementById(grey).style.zIndex = zIndex1;
                document.getElementById(color).style.zIndex = zIndex2;
                document.getElementById("d_"+grey).style.zIndex = zIndex1;
                document.getElementById(grey+"_a").style.zIndex = zIndex1;
                document.getElementById(grey+"_a").style.color = '#ffffff';
                document.getElementById("d_"+grey).style.webkitBoxShadow = '1px 3px 4px #ffffff';
                document.getElementById("d_"+grey).style.boxShadow = '1px 3px 4px #ffffff';
            }
            if(counter>0){
                setTimeout(arguments.callee, 70);
            }
        }, 0);
    } else {
        mist.item[grey] = "c";
        var counter = 1;
        setTimeout(function(){
            if(mist.item[grey] != "c"){
                return;
            }
            counter = counter + 1;
            if(IE){
                document.getElementById(grey).style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+mist.opacityIE[counter]+")";
            } else {
                document.getElementById(grey).style.opacity = mist.opacity[counter];
            }
            if(counter==2){
                document.getElementById(grey).style.zIndex = zIndex1;
                document.getElementById(color).style.zIndex = zIndex2;
                document.getElementById("d_"+grey).style.zIndex = zIndex1;
                document.getElementById(grey+"_a").style.zIndex = zIndex1;
                document.getElementById(grey+"_a").style.color = '#096be5';
                document.getElementById("d_"+grey).style.webkitBoxShadow = '3px 3px 6px #916d0e';
                document.getElementById("d_"+grey).style.boxShadow = '3px 3px 6px #916d0e';
            }
            if(counter<10){
                setTimeout(arguments.callee, 70);
            }
        }, 0);
    }
}
    $('#d_mist_menu_4').mouseenter(function(e){ mist.Anim('color','mist_menu_4','mist_menu_4_color',99,98); });
    $('#d_mist_menu_4').mouseleave(function(e){ mist.Anim('grey','mist_menu_4','mist_menu_4_color',2,1); });

    $('#d_mist_menu_5').mouseenter(function(e){ mist.Anim('color','mist_menu_5','mist_menu_5_color',99,98); });
    $('#d_mist_menu_5').mouseleave(function(e){ mist.Anim('grey','mist_menu_5','mist_menu_5_color',2,1); });

    $('#d_mist_menu_6').mouseenter(function(e){ mist.Anim('color','mist_menu_6','mist_menu_6_color',99,98); });
    $('#d_mist_menu_6').mouseleave(function(e){ mist.Anim('grey','mist_menu_6','mist_menu_6_color',2,1); });

    $('#d_mist_menu_7').mouseenter(function(e){ mist.Anim('color','mist_menu_7','mist_menu_7_color',99,98); });
    $('#d_mist_menu_7').mouseleave(function(e){ mist.Anim('grey','mist_menu_7','mist_menu_7_color',2,1); });

    $('#d_mist_menu_8').mouseenter(function(e){ mist.Anim('color','mist_menu_8','mist_menu_8_color',99,98); });
    $('#d_mist_menu_8').mouseleave(function(e){ mist.Anim('grey','mist_menu_8','mist_menu_8_color',2,1); });

});
