
function popupWindow(href, width, height, scroll)
{
	var top=0, left=0;
	scroll = scroll || "no";
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open(href, "", "scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	return false;
}

function showImage(src, width, height, alt)
{
	var scroll = "no";
	var top=0, left=0;
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	wnd.document.write("<html><head>\n");
	wnd.document.write("<"+"script language='JavaScript'>\n");
	wnd.document.write("<!--\n");
	wnd.document.write("function KeyPress()\n");
	wnd.document.write("{\n");
	wnd.document.write("	if(window.event.keyCode == 27)\n");
	wnd.document.write("		window.close();\n");
	wnd.document.write("}\n");
	wnd.document.write("//-->\n");
	wnd.document.write("</"+"script>\n");
	wnd.document.write("<title>"+(alt == ""? "Картинка":alt)+"</title></head>\n");
	wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" style=\"cursor: pointer; cursor: hand;\" onClick=\"window.close();\" onKeyPress=\"KeyPress()\">\n");
	wnd.document.write("<img src=\""+src+"\" border=\"0\" alt=\""+alt+"\">");
	wnd.document.write("</body>");
	wnd.document.write("</html>");
	wnd.document.close();
}

var flashinstalled = 0;
function insertFlash(params, target) {
		var ms_styles = '';
		if (MSDetect == 'true') {
			ms_styles = 'visibility:hidden;';
		}
      target = document.getElementById(target);
      target.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" src="'+params['src']+'" style="position:absolute; ' + ms_styles + '">';
         target.innerHTML += '<param name="allowScriptAccess" value="sameDomain" />';
         target.innerHTML += '<param name="movie" value="'+params['src']+'" />';
         target.innerHTML += '<param name="menu" value="false" />';
         target.innerHTML += '<param name="quality" value="high" />';
         target.innerHTML += '<param name="wmode" value="transparent" />';
         target.innerHTML += '<param name="bgcolor" value="'+params['bgcolor']+'" />';
         target.innerHTML += '<embed src="'+params['src']+'" menu="false" quality="high" wmode="transparent" bgcolor="'+params['bgcolor']+'" width="'+params['width']+'" height="'+params['height']+'" name="'+params['id']+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
      target.innerHTML += "</object>";
		//target.innerHTML += "&nbsp;";
		target.style.width = params['width'];
		target.style.height = params['height'];
}

function insertFlashOrImg (params, target, png) {
	if (flashinstalled) {
		insertFlash (params, target);
	} else {
		target = document.getElementById(target);
		target.innerHTML = '<img src="' + png + '" id="' + params['id'] + ' alt="" />';
	}
}
