function openBigImage(url,width,height,title) {
	var min_bottom_shift=60;
	var win_width=width+20;
	var win_height=height;
	var not_full=false;
	if (win_width>(screen.width-10)) {
		win_width=screen.width-10;
		not_full=true;
	}
	if (win_height>(screen.height-min_bottom_shift)) {
		win_height=screen.height-min_bottom_shift;
		not_full=true;
	}
	if (not_full) {
		full_width=width;
		full_height=height;
		var k=width/height;
		if (k<((win_width-20)/(win_height-22))) {
			height=win_height-22;
			width=height*k;
		} else {
			width=win_width-20;
			height=width/k;
		}
	}
	var left=Math.round((screen.width-win_width)/2)-5;
	var top=Math.round((screen.height-win_height)/2)-30;
	ow=window.open("","_blank","dependent=1,width="+win_width+",height="+win_height+",status=no,resizable=yes,scrollbars=yes,toolbar=no,top="+top+",left="+left);
	ow.document.open();
	ow.document.write("<html><title>"+title+"</title><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" width=\""+width+"\" height=\""+height+"\"");
	if (not_full) {
		ow.document.write(" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\'if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\'><sc"+"ript>var full=false;</scr"+"ipt>");
	} else {
		ow.document.write(" alt=\""+title+"\">");
	}
	ow.document.write("</center></body></html>");
	ow.document.close();
}

function openImageWindow(url,title) {
	ow=window.open("","_blank","dependent=1,status=no,resizable=yes,scrollbars=yes,toolbar=no");
	ow.document.open();
//	ow.document.write("<html><title>"+title+"</title><scr"+"ipt language=\"javasc"+"ript\" src=\"/js/optimage.js\"></scr"+"ipt><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" alt=\""+title+"\" name=\"img1\" id=\"img1\" on1load=\'OptimizeImageWindow(document.getElementById(\"img1\"));\'>");
	ow.document.write("<html><title>Увеличенное изображение</title><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" alt=\""+title+"\">");
	ow.document.write("</center></body></html>");
	ow.document.close();
}

function openBigImage2(url,title) {

//	var inscript = 'alert(1); var full=false; var img=document.getElementById("img1"); img.onload=function() { var width=img.width; var height=img.height; var min_bottom_shift=60; var win_width=width+20; var win_height=height; var not_full=false; if (win_width>(screen.width-10)) { win_width=screen.width-10; not_full=true; } if (win_height>(screen.height-min_bottom_shift)) { win_height=screen.height-min_bottom_shift; not_full=true; } if (not_full) { full_width=width; full_height=height; var k=width/height; if (k<((win_width-20)/(win_height-22))) { height=win_height-22; width=height*k; } else { width=win_width-20; height=width/k; } } var left=Math.round((screen.width-win_width)/2)-5; var top=Math.round((screen.height-win_height)/2)-30; if (not_full) { src=img.src; img.innerHTML = "<img border=\"0\" src=\""+src+"\" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\"if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\">"); } window.resizeTo(win_width,win_height); window.moveTo(left,top); }';
	/*
	var full=false;
	var img=document.getElementById("img1");
	img.onload=function() {
		var width=img.width;
		var height=img.height;
		var min_bottom_shift=60;
		var win_width=width+20;
		var win_height=height;
		var not_full=false;
		if (win_width>(screen.width-10)) {
			win_width=screen.width-10;
			not_full=true;
		}
		if (win_height>(screen.height-min_bottom_shift)) {
			win_height=screen.height-min_bottom_shift;
			not_full=true;
		}
		if (not_full) {
			full_width=width;
			full_height=height;
			var k=width/height;
			if (k<((win_width-20)/(win_height-22))) {
				height=win_height-22;
				width=height*k;
			} else {
				width=win_width-20;
				height=width/k;
			}
		}
		var left=Math.round((screen.width-win_width)/2)-5;
		var top=Math.round((screen.height-win_height)/2)-30;
		if (not_full) {
			src=img.src; 
			img.innerHTML = "<img border=\"0\" src=\""+src+"\" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\'if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\'>");
		}
		window.resizeTo(win_width,win_height);
		window.moveTo(left,top);
	}
	*/

	ow=window.open("","_blank","dependent=1,status=no,resizable=yes,scrollbars=yes,toolbar=no");
	ow.document.open();
	ow.document.write("<html><title>"+title+"</title><body style=\"margin: 0px;\"><sc"+"ript>"+inscript+"</scr"+"ipt><center><img border=\"0\" name=\"img1\" id=\"img1\" src=\""+url+"\" alt=\""+title+"\">");
	ow.document.write("</center></body></html>");
	ow.document.close();
}
