isDOM=document.getElementById?true:false;
isOpera=isOpera5=window.opera && isDOM;
isOpera6=isOpera && window.print;
isOpera7=isOpera && document.readyState;
isMSIE=isIE=document.all && document.all.item && !isOpera;
isStrict=document.compatMode=='CSS1Compat';
isNN=isNC=navigator.appName=="Netscape";
isNN4=isNC4=isNN && !isDOM;
isMozilla=isNN6=isNN && isDOM;

function openDynamicImageWindow(file,w,h,typ,closeText) {
	if(typ == "dhtml") {
		if(document.all) {
			var windowWidth = self.document.body.clientWidth;
			var windowHeight = self.document.body.clientHeight;
		} else {
			var windowWidth = self.innerWidth;
			var windowHeight = self.innerHeight;
		}
		if(isMSIE || isOpera7) {
			if(isStrict) {
				var scrolltop = document.documentElement.scrollTop;
				var scrollleft = document.documentElement.scrollLeft;
			} else {
				var scrolltop = document.body.scrollTop;
				var scrollleft = document.body.scrollLeft;
			}
		}
		if(isNN || isOpera) {
			var scrolltop = window.pageYOffset;
			var scrollleft = window.pageXOffset;
		}

		// Уменьшение размеров изображение до размеров окна
		if (w != 0 && h != 0 && windowWidth != 0 && windowHeight != 0) {
			var my_epsilon = 20;
			var h_w_ratio = h / w;
			if (h > windowHeight - my_epsilon)
				h = windowHeight - my_epsilon;
			if (w > windowWidth - my_epsilon)
				w = windowWidth - my_epsilon;
			if (h / w > h_w_ratio) {
				h = w * h_w_ratio;
			} else if (h / w < h_w_ratio) {
				w = h / h_w_ratio;
			}
		}

		var postop =(windowHeight/2)-(h/ 2)+scrolltop+document.body.style.padding;
		var posleft =(windowWidth/2)-(w/ 2)+scrollleft+document.body.style.padding;
		if(document.all) {
			if(postop >= 20) { postop = postop-20; }
		} else {
			if(postop >= 30) { postop = postop-30; }
		}
		var bodyObj = document.getElementsByTagName('BODY')[0];
		if(!document.getElementById("dynamicImageContainer")) {
			divObjContainer = document.createElement("div");
			divObjContainer.setAttribute("id", "dynamicImageContainer");
			bodyObj.appendChild(divObjContainer);
			//bodyObj.insertBefore(divObjContainer, bodyObj.firstChild);
		} else {
			divObjContainer = document.getElementById("dynamicImageContainer");
		}
		divObjContainer.style.display = "block";
		divObjContainer.style.z_index = "1000";
		divObjContainer.innerHTML = "<div class=\"imageContainer\" style=\"top:"+postop+"px; left:"+posleft+"px; position: absolute; z-index: 1000; filter:progid:DXImageTransform.Microsoft.Shadow(color=#dddddd, Direction=135, Strength=4); display:block;\"><div class=\"imageBorder\" style=\"background-color: #fff; padding: 4px; border: solid 1px #ccc\"><img onclick=\"closeDynamicImageWindow();\" style=\"cursor:pointer;border: solid 1px #000\" src=\""+file+"\" alt=\""+closeText+"\" width=\""+w+"\" height=\""+h+"\"\/><\/div><\/div>";
	} else if(typ == "javascript") {
		// center popup
		var postop =(screen.height /2)-(h/ 2);
		var posleft =(screen.width /2)-(w/ 2);
		window.open(file+'&closeText='+encodeURI(closeText)+'', '', 'dependent=yes,width='+w+',height='+h+',left='+posleft+',top='+postop+',scrollbars=no,resizable=no,menubar=no,location=no,status=no');
	}
}
function closeDynamicImageWindow() {
	document.getElementById("dynamicImageContainer").style.display = "none";
}
