function ShowBig(){
	   	var s = document.getElementById('big').style;
    	var scrollT = document.documentElement.scrollTop || '0'
    		scrollT = parseInt(scrollT) + 50;
    	
    	document.getElementById('big').style.top = scrollT + 'px';
    	   	
    	if(s.display == 'none'){
    		s.display = 'block';
        	var clientW = document.documentElement.clientWidth
        	var imgW = document.getElementById('img-big').width;
        	var left = Math.floor((clientW - imgW)/2)
    		document.getElementById('big').style.left = left + 'px';
    	}
    	else{
    		s.display = 'none';
    	}
}
function ShowBigID(id,flag){
	var nodes = document.getElementById('imgs').childNodes
	var len = nodes.length
		for(var i=0; i<len; i++){
			if('block' == nodes[i].style.display) nodes[i].style.display = 'none'
		}
	if(1 != flag){
		var e = document.getElementById('img-'+id)
	   	//var scrollT = document.documentElement.scrollTop || '0'
		//	scrollT = parseInt(scrollT) + 250
		
		//document.getElementById('img-'+id).style.top = scrollT + 'px'
		var small = document.getElementById('small-'+id)
		var top = Position(small) || '0'
		var left = Position(small,'left') || '0'
		top =  parseInt(top) - 250
		left = parseInt(left) - 120
		
		e.style.top = top + 'px'
		e.style.left = left + 'px'
		if(e.style.display == 'none'){
			e.style.display = 'block'
		}
	}
}
function Position(element,xy) {
  	var coord = 0;
  	if(element.offsetParent!=null){
  		coord += parseInt(Position(element.offsetParent,xy));
  	}
  	if(xy=='left'){
    	coord += element.offsetLeft;
  	}
  	else{
  		coord += element.offsetTop;
  	}
  return coord;
}

function AddGood(good){
	if(good){
		document.getElementById('good').value = good;
	}
	document.getElementById('add_good').submit();
return false;
}

function DelGood(bid){
	document.getElementById('bid').value = bid;
	document.getElementById('del_good').submit();
return false;
}

function Order(){
	var fio = document.getElementById('fio').value;
	var tel = document.getElementById('tel').value;
	var mail = document.getElementById('mail').value;
	
if('' == fio){
  alert('Укажите пожалуйста Имя(Ф.И.О.)!');
return false;
}

if(('' == tel)&&('' == mail)){
  alert('Укажите пожалуйста Ваш телефонный номер или e-mail!');
return false;
}
document.getElementById('order').submit();
return false;
}

function ImgBig(el,src)
{
	var src = src || el.src;
	var flag = 0;
	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";
						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 title = document.createTextNode(el.title);
			var coor = Block(pic.width,pic.height);
				e.style.top = coor[1] + '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 H()
{
	var h = document.getElementById('des').offsetHeight;
	if(h<700){ document.getElementById('des').style.height = 600 + "px"; }
}
var popup;

function Demand()
{
	var ref = document.referrer;
    var c = document.cookie;
	if(c.match(/ref=[^;]*/) == null){
		document.cookie = "ref=" + ref;
	}
}

