
function popup_window(url,ww,wh) {
	w = ww || 500;
	h = wh || 400;
	var dwin = window.open(url,'dwin','width='+w+',height='+h+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
	dwin.focus();
}

var popup_image_window;
function bind_popup_image(imgClass) {
	var d = document.getElementsByTagName('img');
	for (var i = 0; i < d.length; i++) {
		var clName = d[i].className.toLowerCase();
		if (clName == imgClass || clName.match(new RegExp("(^|\\s)" + imgClass + "(\\s|$)"))) {
			var m = d[i];
			var j = 4;
			while(m != undefined && m != null && m.tagName.toLowerCase() != 'body' && m.tagName.toLowerCase() != 'a' && j-- > 0) m = m.parentNode;

			if (m != undefined && m != null && m.tagName.toLowerCase() == 'a') {
				if (document.all && document.all.item) {
					m.onclick = popup_image_handler;
				} else {
					m.setAttribute('onclick', 'popup_image(this.href, this.title); return false;');
				}

			}
		}
	}
}
function popup_image_handler() {
	popup_image(this.href, this.title);
	return false;
}
function popup_image(isrc,ititle) {
	if (!popup_image_window) {
		var popup_image_window;
	}
	ititle = ititle=="" ? '&laquo;ثوٌٍَ&raquo;' : ititle;
	popup_image_window=window.open('','popup_image_window','width=800,height=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no,scrolling=no');
	popup_image_window.document.open();
	popup_image_window.document.write(	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
							+'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">\n'
							+'<head>\n'
							+'<title>' + ititle + '</title>\n'
							+'<style type="text/css">html,body {padding: 0px; margin: 0px;"</style>\n'
							+'<script type=\"text/javascript\">\n'
							+'	var to = false;\n'
							+'	var iw = false;\n'
							+'	var ih = false;\n'
							+'	var kwh = false;\n'
							+'	var sizeMode = false;\n'
							+'	var resizeBlocker = false;\n'
							+'	var isDOM=document.getElementById?true:false;\n'
							+'	var isOpera=window.opera && isDOM;\n'
							+'	var isMSIE=document.all && document.all.item && !isOpera;\n'
							+'	function matchSize(obj) {\n'
							+'		if (iw === false) { iw = obj.width; document.getElementById("image").style.width = iw + "px"; }\n'
							+'		if (ih === false) { ih = obj.height; document.getElementById("image").style.height = ih + "px"; }\n'
							+'		if (kwh === false) kwh = iw / ih;\n'
							+'		var imgw = parseInt(obj.style.width);\n'
							+'		var imgh = parseInt(obj.style.height);\n'
							+'		if (!isMSIE) {\n'
							+'			var dw = self.outerWidth - self.innerWidth;\n'
							+'			var dh = self.outerHeight - self.innerHeight;\n'
							+'			self.resizeTo(imgw + dw, imgh + dh);\n'
							+'		} else {\n'
							+'			if (document.documentElement && document.documentElement.clientHeight) {\n'
							+'				var w = document.documentElement.clientWidth;\n'
							+'				var h = document.documentElement.clientHeight;\n'
							+'			} else if (document.body) {\n'
							+'				var w = document.body.clientWidth;\n'
							+'				var h = document.body.clientHeight;\n'
							+'			}\n'
							+'			var dw = imgw - w;\n'
							+'			var dh = imgh - h;\n'
							+'			window.resizeBy(dw, dh);\n'
							+'		}\n'
							+'		self.focus();\n'
							+'		window.setTimeout("window.onresize = bodyOnResize;", 300);\n'
							+'		return void(0);\n'
							+'	}'
							+'	function matchImage() {\n'
							+'		if (resizeBlocker) return void(0);\n'
							+'		var i = document.getElementById("image").style;\n'
							+'		var w,h;\n'
							+'		if (!isMSIE) {\n'
							+'			w = self.innerWidth;\n'
							+'			h = self.innerHeight;\n'
							+'		} else {\n'
							+'			if (document.documentElement && document.documentElement.clientHeight) {\n'
							+'				w = document.documentElement.clientWidth;\n'
							+'				h = document.documentElement.clientHeight;\n'
							+'			} else if (document.body) {\n'
							+'				w = document.body.clientWidth;\n'
							+'				h = document.body.clientHeight;\n'
							+'			}\n'
							+'		}\n'
							+'		var w1 = (kwh > 1 ? (w/h > kwh ? h*kwh : w) : (w/h > kwh ? h*kwh : w));\n'
							+'		i.width = w1 + "px";\n'
							+'		i.height= (w1 / kwh) + "px";\n'
							+'		sizeMode = true;\n'
							+'		matchSize(document.getElementById("image"));\n'
							+'	}\n'
							+'	function toggleSize() {\n'
							+'		window.clearTimeout(to);\n'
							+'		if (sizeMode) {\n'
							+'			var d = document.getElementById("image");\n'
							+'			d.style.width = iw + "px";\n'
							+'			d.style.height = ih + "px";\n'
							+'			matchSize(d);\n'
							+'			sizeMode = false;\n'
							+'			resizeBlocker = true;\n'
							+'			window.setTimeout("resizeBlocker=false;", 700);\n'
							+'		} else {\n'
							+'			matchImage();//to = window.setTimeout(matchImage, 100);\n'
							+'		}\n'
							+'	}\n'
							+'	function bodyOnResize() {\n'
							+'		window.clearTimeout(to);\n'
							+'		window.setTimeout(matchImage,200);\n'
							+'	}\n'
							+'</script>'
							+'</head>\n'
							+'<body style="overflow: hidden; margin: 0px; padding: 0px;">\n'
							+'<a href="javascript:void(0);" onclick="toggleSize();" title="' + ititle + '">'
							+'<img id="image" src="'+isrc+'" border="0" onload="matchSize(this);" alt="' + ititle + '" /></a>\n'
							+'</body>\n'
							+'</html>');
	popup_image_window.document.close();
	return void(0);
}
function onPageLoad() {
	bind_popup_image('js_popup_image');
}
