var gcWin     = null;

//******************************************************************************//
function Window(cPath,nX,nY,cOpt)
//******************************************************************************//
{
	OpenWindow(cPath,nX,nY,cOpt);   
   	LoadWin(cPath,gcWin);

   	if (gcWin.closed == true)
		gcWin = null;
}


//******************************************************************************//
function PicWindow(cPath,cTitle,nX,nY,cOpt)
//******************************************************************************//
{
	OpenWindow(cPath,nX,nY,cOpt);
   	LoadPicWin(cPath,gcWin,cTitle);

   	if (gcWin.closed == true)
      	gcWin = null;
}


//******************************************************************************//
function OpenWindow(cPath,nX,nY,cOpt)
//******************************************************************************//
{
   var x;
   var intervalID;
   var cParams = "width="+nX+",height="+nY;
   
   if (cOpt != null)
	   	cParams = cParams+","+cOpt;
   
   if (!gcWin || gcWin.closed)  
      gcWin = window.open("","window",cParams);
   else
      gcWin.focus();

   for (x=0;x<100000;x++) {}

   if (gcWin == null)
      alert('Window failed to open in time');
}

//******************************************************************************//
function CloseWindow()
//******************************************************************************//
{
	gcWin.close();
}

//******************************************************************************//
function w(cWin,text)
//******************************************************************************//
{
   cWin.document.write(text);
}

//******************************************************************************//
function LoadWin(cPath,cWin)
//******************************************************************************//
{
	cWin.location = cPath;
}


//******************************************************************************//
function LoadPicWin(cPath,cWin,cTitle)
//******************************************************************************//
{
	w(cWin,"<html><head><title>"+cTitle+"</title></head>");
	w(cWin,"<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">");
	w(cWin,"<img src="+cPath+">");
	w(cWin,"</body></html>");
	cWin.document.close();
}