function popupCenterWindow(intWidth,intHeight)
{
   var strOutput = "";
   intWidth  = (screen.availWidth / 2) - (intWidth / 2) ;
   intHeight = ((screen.availHeight-20) / 2) - (intHeight / 2) ;
   
   strOutput += ",screenx=" + intWidth;
   strOutput += ",screeny=" + intHeight;

   strOutput += ",left=" 	+ intWidth ;
   strOutput += ",top=" 	+ intHeight;
 
   return strOutput;
}

function popupOpenHtmlWindow (strHtmlCode, strHtmlTitle, intWidth, intHeight, strSelect) 
{
	var strOutput   = "";
	var strFileName = "";
	
	switch  (strSelect)
	{
		case "flash":
			strOutput  =	'<table border="0" cellspacing="0" cellpadding="0">'+"\n";
			strOutput +=	'<tr>'+"\n";
			strOutput +=	'	<td><OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"  ';
			strOutput +=	'		WIDTH="'+ intWidth +'" ';
			strOutput +=	'		HEIGHT="'+ intHeight +'" VIEWASTEXT><PARAM ';
			strOutput +=	'		NAME="movie" VALUE="'+ strHtmlCode +'"><PARAM  ';
			strOutput +=	'		NAME="quality"  VALUE="high"><PARAM  ';
			strOutput +=	'		NAME="menu"  VALUE="true"><EMBED  ';
			strOutput +=	'		SRC="'+ strHtmlCode +'" ';
			strOutput +=	'		WIDTH="'+ intWidth +'" ';
			strOutput +=	'		HEIGHT="'+ intHeight +'" ';
			strOutput +=	'		MENU="false" ';
			strOutput +=	'		QUALITY="high" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></td>'+"\n";
			strOutput +=	'</tr>'+"\n";
			strOutput +=	'</table>'+"\n";
			break;
				
		case "image":
			strOutput  =	'<table border="0" cellspacing="0" cellpadding="0">'+"\n";
			strOutput +=	'<tr>'+"\n";
			strOutput +=	'	<td><img';
			strOutput +=	' src="' 	+ strHtmlCode + '" ';
			strOutput +=	' alt="'	+ strHtmlTitle + '" ';
			strOutput +=	' width="'	+ intWidth + '" ';
			strOutput +=	' height="' + intHeight + '" ';
			strOutput +=  	' border="0"></td>'+"\n";
			strOutput +=	'</tr>'+"\n";
			strOutput +=	'</table>'+"\n";
			intWidth = intWidth-4; 
			intHeight = intHeight-4; 
			break;
		
		case "file":
			strFileName  =	strHtmlCode;
			break;
			
	}

	strHtmlCode = strOutput;
	
	var win = window.open(strFileName,  strHtmlTitle,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+intWidth+",height=" + intHeight + popupCenterWindow(intWidth,intHeight));
	
	if (strSelect != "file"){
		// Format HTML
		strOutput ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'+"\n";
		strOutput +='<HTML>'+"\n";
		strOutput +='<HEAD>'+"\n";
	
		// Title
		strOutput +='	<TITLE>'+strHtmlTitle+'</TITLE>'+"\n";
		strOutput +='	<META http-equiv="content-type" content="text/html;charset=windows-1251">'+"\n";
		strOutput +='	</HEAD>'+"\n";
		strOutput +='<BODY bgcolor="#000000" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" style=" border: 0">'+"\n";
	
		// Html Code
		strOutput += strHtmlCode;
		strOutput +='</BODY></HTML>'+"\n";
	
		// Edit Window (Put HTML
		win.document.open("text/html");	
		win.document.write(strOutput);
		win.document.close();
		
	}
	win.focus();
}

function popupHandleWindow(strPath, intWidth, intHeight, strTitle, strMimeType){
	var strType = "";
	if(strMimeType == "jpg")
		strType = "image";
	if(strMimeType == "gif")
		strType = "image";
	if(strMimeType == "png")
		strType = "image";
	if(strMimeType == "swf")
		strType = "flash";
	if(strType == "")
		return;
	popupOpenHtmlWindow (strPath, "Popup", intWidth, intHeight, strType);
}