$(document).ready(function(){
	
$(document).keydown(function(e) {
  if(e.keyCode == 27) HidePhoto();
});
	
});

function ShowPhoto(path,width,height) {
	/*
	int = document.getElementById('interlaced');
	int.style.height = document.documentElement.scrollHeight + 'px';
	int.style.visibility = 'visible';
	view = document.getElementById('ViewPhoto');
	vd = document.getElementById('Vdiv');
	foto = document.getElementById('Fotka');
	foto.innerHTML = '<img src="'+path+'" onclick="HidePhoto();">';
	view.style.width = width + 'px';
	vd.style.width = width + 'px';
	view.style.height = height + 30 + 'px';
	view.style.marginLeft = -Math.round(width/2) + 'px';
	view.style.marginTop = -Math.round(height/2) - 35 + document.documentElement.scrollTop + 'px';
	view.style.display = 'block';*/
	
	$('div.PopupPhoto').fadeTo('fast', 0, function(){
		$(this).remove();
	});
	var new_div = $('<div>').html('<img src="' + path + '" onclick="HidePhoto();"><div class="label">Для закрытия нажмите на изображения или клавижу Esc</div>').addClass('PopupPhoto').appendTo('body');
	var cur_hpos = defScroll().y;
	cur_hpos = cur_hpos + 20;
	if (cur_hpos < 250) cur_hpos = 250;
	var cur_wpos = ($(document).width() / 2) - (width / 2);
	$(new_div).css("top", cur_hpos).css("left", cur_wpos);
	$(new_div).fadeTo('fast', 1);
}

function defScroll() {
      var x = y = 0;
      x = (window.scrollX) ? window.scrollX : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;
      y = y = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
      return {x:x, y:y};
}

function HidePhoto() {
	$('div.PopupPhoto').fadeTo('fast', 0, function(){
		$(this).remove();
	});
}