<!--
//======================================================================== 
//
//      mywindow.js
//
//----- Mods: 12-10-03, 12-19-03 ka1fsb/kbn
//----- 01-28-04
//----- 03-30-04
//----- 07-19-05, 07-30-05
//----- 08-07-05
//----- 11-29-05
//
//----- Open a window on some trigger...
//----- A simple "square" window on demand, with optional text/caption 
//----- All major dimensions can be passed in as arguments...
//----- myFile can be either a jpg or an html file
//----- myFile can also be "this" meaning this "myText" here in the page
//----- Does scroll bars too if needed, for an html page...
//
//=========================================================================

function createMyWindow(myTitle, 	// Window bar unique title/name
			myFile, 	// Name of image, url, or html
			winSquare, 	// A side of the square window
			picWd, 		// Width of image
			picHt, 		// Height of image
			myText)		// Optional text, caption
{
//----- Inits...
	var myURL     = "";
	var myHeight  = "";
	var myWidth   = "";
	var myTest    = "";

	var top       = 90;		// Pixels from screen top
	var left      = 100;		// Pixels from screen left
	var pos       = 0;

//----- If winSquare comes in with a separated list: width.height
//----- Convert to a string... then back to a number, for 000 use 001 etc
	myTest = String(winSquare);

	if ( myTest.match(/\./) )
	{
		var dimens = new Array();
		dimens     = myTest.split('.');
		myWidth    = Number(dimens[0]);
		myHeight   = Number(dimens[1]);
	}
	else
	{
		myWidth  = Number(winSquare);
		myHeight = Number(winSquare);
	}

	if ( myFile.match(/\.html$/) )
	{
		myURL  = myFile;
		myFile = "";
		top    = 25;		// Start farther up
		left   = 25;		// Start more to left
	}


	if ( myTitle.length > 0 )
	{
//----- Change spaces to underbars...
//----- NOTE: No strange characters in myTitle! no -'s dashes
		if ( myTitle.match(/ /g) )
		{
			do
			{
				pos = myTitle.indexOf(' ');
				if ( pos < 0 ) break;
				myTitle = myTitle.substr(0,pos) + '_' + myTitle.substr(pos+1);
			} while (1);
		}
	}
	else
	{
//----- Default value...
		myTitle = "myWindow";
	}

//----- Data inits...
	var msg = "Detail View Window "+myWidth+"x"+myHeight;
	var statMsg = "status='" + msg + "'; return true;";

//----- Create a new smaller window
//----- ***No*** spaces between the quotes for a window.open arg list...
//----- No spaces in variables either!
	var w = window.open(myURL,myTitle, 
		"status,resizable,scrollbars,top="+top+",left="+left+",width="+myWidth+",height="+myHeight);

//----- Do you want to adjust these vars? was w.moveBy
//-----	w.moveTo(100,90);

//----- Bail out here if showing an html document
	if ( ! myFile ) return true;

//----- We are only passing text data here... if it is "this"
	if ( myFile.match(/this$/) )
	{
		myFile = "";
	}

//----- Implicitly open this document for writing...
	var d = w.document;

	d.write("<html><head><title>" + myTitle + "</title></head>");
	d.write('<body onload="' + statMsg + '">');

//----- If we have an image file then write...
	if ( myFile )
	{
//----- Position image...
	     d.write('<p><br><center>');

//----- If we supplied dimensions, then use them... was src='+myFile+'
		if ( picWd )
		{
			d.write('<img src='+myFile+' width="'+picWd+'" height="'+picHt+'">');
		}
		else
		{
//----- Else assume the picture will be fully displayed, and is right size.
			d.write("<img src="+myFile+">");
		}

	     d.write("</center><br>");
	}

//----- If we have text then write...
//----- Double quotes are noted as &#34; in the passed-in text itself
//----- This may be a caption for an image, or actual text body
	if ( myText )
	{
		d.write(myText);
	}

//----- This is also for an image file for spacing
//----- If this is not an image file, the passed in lines should handle this...
	if ( myFile )
	{
		d.write("</p><br>");
	}

//----- Close tags at the bottom of the page...
	d.write("</body></html>");


//----- Close the document to further writing, but keep the window up.
//----- NOTE: w.close will close the window before it can be seen.
	d.close();

//----- May not need this return true below...
// return true;
}

//----- End of mywindow.js
//-->
