PhotoRoot = '';

window.onscroll=hidephoto;

function getClientWidth() {
	return document.documentElement?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight() {
	return document.documentElement?document.documentElement.clientHeight:document.body.clientHeight;
}
function getBodyScrollTop() {
	return document.documentElement?document.documentElement.scrollTop:document.body.scrollTop;
}
function getBodyScrollLeft() {
	return document.documentElement?document.documentElement.scrollLeft:document.body.scrollLeft;
}
function viewphoto(filename) {
	var o1 = document.getElementById('photoback');
	var o2 = document.getElementById('photoview');
	var o3 = document.getElementById('photoimg');
	o1.style.width = getClientWidth() + 'px';
	o1.style.height = getClientHeight() + 'px';
	o1.style.left = getBodyScrollLeft() + 'px';
	o1.style.top = getBodyScrollTop() + 'px';
	o1.style.display = 'block';
	o2.style.width = getClientWidth() + 'px';
	o2.style.height = getClientHeight() + 'px';
	o2.style.left = getBodyScrollLeft() + 'px';
	o2.style.top = getBodyScrollTop() + 'px';
	o2.style.display = 'block';
	o3.innerHTML = '<img id="photo" src="' + PhotoRoot + filename + '" style="border: 20px solid #FFF;">';
}

function hidephoto() {
	var o1 = document.getElementById('photoback');
	var o2 = document.getElementById('photoview');
	var o3 = document.getElementById('photoimg');
	o1.style.display = 'none';
	o2.style.display = 'none';
	o3.innerHTML = '<H1><font color=white>Загрузка изображения ...</font></H1>';
}

function initphoto(p1) {
	PhotoRoot = p1;
	document.write('<div id="photoback" style="position: absolute; display: none; cursor: pointer; width: 40px; height: 40px; top: 0; left: 0; background-color: #000; opacity: 0.75; filter:alpha(opacity=75);"></div><div id="photoview" style="position: absolute; display: none; cursor: pointer; width: 40px; height: 40px; top: 0; left: 0;" onclick="hidephoto()" oncontextmenu="hidephoto(); return false;"><table width="100%" height="100%" class="photoimg"><tr><td id="photoimg" style="text-align:center; vertical-align:middle;">Изображение недоступно</td></tr></table></div>');
}
