var photoImage=null;
var loadFlag;


// --------------------------------------------------------


function loadImage(imgSrc)
{
	if (!photoImage || photoImage.src.search(imgSrc)==-1)
	{
		clearTimeout(loadFlag);

		photoImage=new Image();
		photoImage.src=imgSrc;

		document.getElementById('photo-td').style.backgroundImage='url(http://narodnayamarka.ru/files/91_loading.gif)';
	}

	if (photoImage.complete)
	{
		document.getElementById('photo-td').style.backgroundImage='url('+imgSrc+')';
		photoImage=null;

		return;
	}
	
	loadFlag=setTimeout("loadImage('"+imgSrc+"');",10);
}


// --------------------------------------------------------


function closePhoto()
{
	document.getElementById('photo-div').style['visibility']='hidden';

	document.getElementById('photo-div').style['left']=-2000;
	document.getElementById('photo-div').style['top']=-2000;

	document.getElementById('photo-td').style.backgroundImage='url(http://narodnayamarka.ru/files/91_loading.gif)';
}


// --------------------------------------------------------


function showPhoto(imgSrc, w, h)
{
	w=w+30;
	h=h+30;

	document.getElementById('photo-div').style.width=w;
	document.getElementById('photo-div').style.height=h;

	// дополнение
	if (document.body.clientWidth>1280) mWidth=1280;
	else mWidth=document.body.clientWidth;
	// дополнение

	document.getElementById('photo-div').style['left']=Math.round((mWidth-w)/2)+30;
	document.getElementById('photo-div').style['top']=Math.round((document.body.clientHeight-h)/2)+document.body.scrollTop;

	document.getElementById('photo-div').style['visibility']='visible';

	loadImage(imgSrc);
}


// --------------------------------------------------------


// дополнение
function reCalculate()
{

	if (parseInt(document.getElementById('photo-div').style['left'])>0)
	{
		if (document.body.clientWidth>1280) mWidth=1280;
		else mWidth=parseInt(document.body.clientWidth);

		w=parseInt(document.getElementById('photo-div').style.width);

		document.getElementById('photo-div').style['left']=Math.round((mWidth-w)/2)+30;
	}

		
	if (document.all && !window.opera)
	{
		if (document.body.clientWidth>1280) w='1280px';
		else w='100%';

		document.getElementById('main-div').style.width=w;
	}

}
// дополнение

