function vWin_CreateNewWindow (strTitle, strURL, iHeight, iWidth, bMin, bMax,
								bClose, bCenter, bMaximized, strIcon)
{
    var winWindow = new Object ();
	winWindow.strIcon = (strIcon || "");
	winWindow.strTitle = "";
	winWindow.strURL = "";
	winWindow.bCanMove = 0;
	winWindow.iHeight = 0;
	winWindow.iWidth = 0;
	winWindow.iXoffset = 0;
	winWindow.iYoffset = 0;
	winWindow.iPrevX = 0;
	winWindow.iPrevY = 0;
	winWindow.iMaximized = 0;
	winWindow.iMinimized = 0;
	winWindow.iMaxPrevHeight = 0;
	winWindow.iMaxPrevWidth = 0;
	winWindow.iMaxPrevX = 0;
	winWindow.iMaxPrevY = 0;
	winWindow.iWinNum = 0;
	winWindow.iClosed = 0;
	
	strWrite = ("<div id = \'winWindow" + iNumOfWindows + "\' style = \'display: None; position: absolute; background-color: #FFFFFF;\'");
		strWrite += ("onMouseOver = \"this.style.zIndex = '1';\" onMouseOut = \"this.style.zIndex = '0';\">");
		strWrite += ("<table border = \'1\' width = \'100%\' height = \'100%\' cellpadding = \'0\' cellspacing = \'0\'>");
			strWrite += ("<tr>");
				strWrite += ("<td>");
					strWrite += ("<div style = \'height: 25; width: 100%;\'>");
						strWrite += ("<table border = \'0\' id = '" + iNumOfWindows + "' height = \'100%\' width = \'100%\'");
							strWrite += ("cellpadding = \'0\' cellspacing = \'0\'");
							strWrite += ("onMouseDown = \'vWin_WindowMove (event, this.id);\' onMouseUp = \'vWin_MouseStop (this.id);\'");
							strWrite += ("onDblClick = \'vWin_Max (this.id);\' onSelectStart = \'return (false);\'>");
							strWrite += ("<tr>");
								strWrite += ("<td bgcolor = \'#163174\' width = \'70%\' valign = \'bottom\'>");
									strWrite += ("&nbsp;");
									
									if (winWindow.strIcon != "")
										strWrite += ("<img src = \'" + winWindow.strIcon + "\' height = \'14\'>");
									
									strWrite += ("<span onMouseDown = \'vWin_Deselect ()\' onSelectStart = \'return (false);\'>");
										strWrite += ("<font color = \'#FFFFFF\' face = 'System'>");
											strWrite += ("<b>");
												strWrite += ("&nbsp;<a id = \'winTitle" + iNumOfWindows + "\'></a>");
											strWrite += ("</b>");
										strWrite += ("</font>");
									strWrite += ("</span>");
								strWrite += ("</td>");
								strWrite += ("<td bgcolor = \'#A5C9EF\' width = \'30%\' align = \'right\' valign = \'bottom\'");
									strWrite += ("style = \'background-image: url(\"./images/titlefade.jpg\");");
											strWrite += ("background-repeat: no-repeat; background-color: #A5C9EF;\'>");

									if (bMin != false)
									{
										strWrite += ("<img src = \"./images/icons/min1.jpg\" id = \"imgMin" + iNumOfWindows + "\" onClick = \"vWin_Min (" + iNumOfWindows + ")\"");
											strWrite += ("onMouseDown = \"document.getElementById('imgMin" + iNumOfWindows + "').");
												strWrite += ("setAttribute ('src', './images/icons/min2.jpg');\"");
											strWrite += ("onMouseUp = \"document.getElementById('imgMin" + iNumOfWindows + "').");
												strWrite += ("setAttribute ('src', './images/icons/min1.jpg');\"");
											strWrite += ("onSelectStart = \"return (false);\"");
											strWrite += ("height = \"14\">");
									}

									if (bMax != false)
									{
										strWrite += ("<img src = \'./images/icons/max1.jpg\' id = \'imgMax" + iNumOfWindows + "\' onClick = \'vWin_Max (" + iNumOfWindows + ")\'");
											strWrite += ("onMouseDown = \"document.getElementById('imgMax" + iNumOfWindows + "').");
												strWrite += ("setAttribute('src', './images/icons/max2.jpg');\"");
											strWrite += ("onMouseUp = \"document.getElementById('imgMax" + iNumOfWindows + "').");
												strWrite += ("setAttribute ('src', './images/icons/max1.jpg');\"");
											strWrite += ("onSelectStart = \"return (false);\"");
											strWrite += ("height = \"14\">");
									}

									if (bClose != false)
									{
										strWrite += ("<img src = \"./images/icons/close1.jpg\" id = \"imgClose" + iNumOfWindows + "\"");
											strWrite += ("onClick = \"vWin_Close (" + iNumOfWindows + ")\"");
											strWrite += ("onMouseDown = \"document.getElementById('imgClose" + iNumOfWindows + "').");
												strWrite += ("setAttribute ('src', './images/icons/close2.jpg');\"");
											strWrite += ("onMouseUp = \"document.getElementById('imgClose" + iNumOfWindows + "').");
												strWrite += ("setAttribute ('src', './images/icons/close1.jpg');\"");
											strWrite += ("onSelectStart = \"return (false);\"");
											strWrite += ("height = \'14\'>");
									}

									strWrite += ("&nbsp;");
								strWrite += ("</td>");
							strWrite += ("</tr>");
						strWrite += ("</table>");
					strWrite += ("</div>");
					strWrite += ("<div style = \'height: 95%; width: 100%;\' onSelectStart = \'return (false);\'>");
						strWrite += ("<iframe id = \'winWindowContent" + iNumOfWindows + "\'  frameborder = \'0\' height = \'100%\' width = \'100%\'");
							strWrite += ("marginwidth = \'0\' marginheight = \'0\'>");
							strWrite += ("Your web browser cannot handle IFrames, please click <a href = \'\'>here</a> to view");
								strWrite += ("the page.");
						strWrite += ("</iframe>");
					strWrite += ("</div>");
				strWrite += ("</td>");
			strWrite += ("</tr>");
		strWrite += ("</table>");
	strWrite += ("</div>");
	
	document.getElementById ("idWindows").innerHTML = (document.getElementById ("idWindows").innerHTML + strWrite);
	
	winWindow.strTitle = strTitle;
	winWindow.strURL = strURL;
	winWindow.iHeight = iHeight;
	winWindow.iWidth = iWidth;
	winWindow.iWinNum = iNumOfWindows;

    aryWindows.push (winWindow);

	if (iBrowser != 0)
	{
		document.getElementById ("winWindow" + iNumOfWindows).style.height = (iHeight + "px");
		document.getElementById ("winWindow" + iNumOfWindows).style.width = (iWidth + "px");
		document.getElementById ("winWindow" + iNumOfWindows).style.left = "30px";
		document.getElementById ("winWindow" + iNumOfWindows).style.top = "70px";
		document.getElementById ("winWindow" + iNumOfWindows).style.display = "";

		document.getElementById ("winWindowContent" + iNumOfWindows).src = strURL;
		document.getElementById ("winTitle" + iNumOfWindows).innerHTML = strTitle;

		if (bCenter != false)
			vWin_Center (iNumOfWindows);

		if (bMaximized != false)
			vWin_Max (iNumOfWindows);

		vMin_Control (iNumOfWindows, 0);
	}
	else
		window.open (strURL, strTitle, "height = iHeight, width = iWidth, scrollbars = yes");

	iNumOfWindows++;
}

function vWin_MouseMove (evtEvent)
{
	if (aryWindows[iCurrentWindow].bCanMove == 1)
	{
		if (iBrowser != 1)
		{
			document.getElementById ("winWindow" + iCurrentWindow).style.left = (aryWindows[iCurrentWindow].iPrevX +
				(evtEvent.clientX - aryWindows[iCurrentWindow].iXoffset) + "px");
			document.getElementById ("winWindow" + iCurrentWindow).style.top = (aryWindows[iCurrentWindow].iPrevY +
				(evtEvent.clientY - aryWindows[iCurrentWindow].iYoffset) + "px");
		}
		else
		{
			document.getElementById ("winWindow" + iCurrentWindow).style.left = (aryWindows[iCurrentWindow].iPrevX +
				(event.clientX - aryWindows[iCurrentWindow].iXoffset) + "px");
			document.getElementById ("winWindow" + iCurrentWindow).style.top = (aryWindows[iCurrentWindow].iPrevY +
				(event.clientY - aryWindows[iCurrentWindow].iYoffset) + "px");
		}
	}
}

function vWin_WindowMove (evtEvent, iWindow)
{
	iCurrentWindow = parseInt (iWindow);
	
	if (aryWindows[iCurrentWindow].iMaximized != 1)
	{
		if (iBrowser != 1)
		{
			aryWindows[iCurrentWindow].iXoffset = evtEvent.clientX;
			aryWindows[iCurrentWindow].iYoffset = evtEvent.clientY;
		}
		else
		{
			aryWindows[iCurrentWindow].iXoffset = event.clientX;
			aryWindows[iCurrentWindow].iYoffset = event.clientY;
		}
		
		document.getElementById("winWindowContent" + iCurrentWindow).style.display = "None";
		aryWindows[iCurrentWindow].iPrevX = parseInt (document.getElementById ("winWindow" + iCurrentWindow).style.left);
		aryWindows[iCurrentWindow].iPrevY = parseInt (document.getElementById ("winWindow" + iCurrentWindow).style.top);
		
		aryWindows[iCurrentWindow].bCanMove = 1;
		document.getElementById("winWindow" + iCurrentWindow).onmousemove = vWin_MouseMove;
	}
}

function vWin_MouseStop (iWindow) 
{
	iWindow = parseInt (iWindow);
	
	aryWindows[iWindow].bCanMove = 0;
	document.getElementById("winWindow" + iWindow).onmousemove = null;
	document.getElementById("winWindowContent" + iWindow).style.display = "";
}

function vWin_Center (iWindow)
{
	iWindow = parseInt (iWindow);
	
	document.getElementById ("winWindow" + iWindow).style.left = ((document.body.clientWidth / 2) - (aryWindows[iWindow].iWidth / 2) + "px");
	document.getElementById ("winWindow" + iWindow).style.top = ((document.body.clientHeight / 2) - (aryWindows[iWindow].iHeight / 2) + "px");
}

function vWin_Max (iWindow)
{
	iWindow = parseInt (iWindow);
	
	if (aryWindows[iWindow].iMaximized != 0)
	{
		document.getElementById ("winWindow" + iWindow).style.left = aryWindows[iWindow].iMaxPrevX;
		document.getElementById ("winWindow" + iWindow).style.top = aryWindows[iWindow].iMaxPrevY;
		document.getElementById ("winWindow" + iWindow).style.width = aryWindows[iWindow].iMaxPrevWidth;
		document.getElementById ("winWindow" + iWindow).style.height = aryWindows[iWindow].iMaxPrevHeight;
		
		aryWindows[iWindow].iMaximized = 0;
	}
	else
	{
		aryWindows[iWindow].iMaxPrevHeight = document.getElementById ("winWindow" + iWindow).style.height;
		aryWindows[iWindow].iMaxPrevWidth = document.getElementById ("winWindow" + iWindow).style.width;
		aryWindows[iWindow].iMaxPrevX = document.getElementById ("winWindow" + iWindow).style.left;
		aryWindows[iWindow].iMaxPrevY = document.getElementById ("winWindow" + iWindow).style.top;
		
		document.getElementById ("winWindow" + iWindow).style.left = (0 + "px");
		document.getElementById ("winWindow" + iWindow).style.top = (0 + "px");
		document.getElementById ("winWindow" + iWindow).style.width = (document.body.clientWidth + "px");
		
		if (iBrowser != 1)
			document.getElementById ("winWindow" + iWindow).style.height = ((document.body.clientHeight - 42) + "px");
		else
			document.getElementById ("winWindow" + iWindow).style.height = ((document.body.clientHeight - 53) + "px");
		
		aryWindows[iWindow].iMaximized = 1;
	}
}

function vWin_Min (iWindow)
{
	iWindow = parseInt (iWindow);
	
	vMin_Control (iWindow, 1);
}

function vWin_Close (iWindow)
{
	document.getElementById("winWindow" + iWindow).style.display = "None";
	aryWindows[iWindow].iClosed = 1;
	
	vMin_Control (iWindow, 0);
}

function vWin_Deselect ()
{
	if (iBrowser != 1)
		window.getSelection ().removeAllRanges ();
	else
		document.selection.empty ();
}
