// ---------------------------------------------------------------------------
// SCRIPT NAME: grafweb.js
// DESCRIPTION: Site-specific JavaScript Library.
// PROGRAMMER:  George Silberstern, ...by Graf!
// REQUIRES:    javalib.js
// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Functions included:
//      * Photo()
//
// Custom Subroutines:
//      * CreateWindow()


// ===========================================================================
// Photo - Generate Window for Photographs
//      Parameters: ImageName, ImageWidth, ImageHeight
//      Syntax:     Photo(<Str>,<expN>,[<expN>])
//      Returns:    Nothing
//      Requires:   GetDimension(), GetPosition()
//
function Photo(ImageName, ImageWidth, ImageHeight) {
	// Set Padding based on Browser platform
	if(navigator.appName == "Netscape") {
		var HPadding = 50;		// Netscape requires less padding than IE
		var VPadding = 85;		// Netscape requires less padding than IE
	} else {
		var HPadding = 60;
		var VPadding = 95;
	}

	// Set Window Attributes
	var WindowHandle = "Photograph";
	var WindowAttrib = "toolbar=no,location=no,directories=no,status=no,menubar=no";
	var WindowScroll = "scrollbars=yes";
	var WindowResize = "resizable=yes";

	// Configure structure and layout parameters
	WindowWidth = GetDimension(screen.width, ImageWidth, HPadding);
	WindowHeight = GetDimension(screen.height, ImageHeight, VPadding);

	HPosition = GetPosition(screen.width, WindowWidth);
	VPosition = GetPosition(screen.height, WindowHeight);

	WindowAttrib = "width="+WindowWidth+",height="+WindowHeight+","+WindowAttrib+","+WindowScroll+","+WindowResize;
	ObjectTag = '<img src="'+ImageName+'" height="'+ImageHeight+'" width="'+ImageWidth+'" border="2" alt="'+WindowHandle+'">';

	// Generate the Window
	PhotoFrame = window.open("", WindowHandle, WindowAttrib);
	CreateWindow(PhotoFrame, WindowHandle);
}
// ===========================================================================

// ------------------------------------------------------------- //
// Document - Generate a static size, modeless Browser window
//       Parameters: <document>
//       Returns: nothing
//
function Document(url, PanelWidth, PanelHeight) { 
	if (! PanelWidth ) {
		PanelWidth = 520;
	}
	if (! PanelHeight ) {
		PanelHeight = 400;
	}
	
	Pane = window.open(url,'remote','width='+PanelWidth+',height='+PanelHeight+',scrollbars'); 
	Pane.focus();
}
// ===========================================================================



// ***************************************************************************
// Subroutines
// ***************************************************************************
//
// ===========================================================================
// CreateWindow()
//      Description: Generate a new window object
//      Parameters:  WindowObjectName
//      Syntax:      CreateWindow(<Str>,[<Str>])
//      Returns:     Nothing
//      Requires:    Center(), HTMLHeader(), HTMLFooter()
//
function CreateWindow(WindowObjectName, WindowTitle) {
	var WindowObjectName;
	var WindowTitle;
	var BodyAttrib = 'bgcolor="#C0C0C0" link="#3300CC" vlink="#FF3399" alink="#99FF66" text="#000000"'
	var CloseLink='<input type="button" value="    Close    " style="margin: 5px 0 0 0;;" onClick="window.close()">'
	
	Center(WindowObjectName);
	WindowObjectName.document.open();
	HTMLHeader(WindowObjectName, WindowTitle, BodyAttrib);
	
	with (WindowObjectName.document) {
		write('<form method="post">\n');
		write('<table border="0" width="100%" align="center" cellpadding="0" cellspacing="0">\n');
		write('<tr>\n\t<td align="center" width="100%">'+ObjectTag+'<br></td>\n</tr>\n');
		write('<tr>\n\t<td align="center" valign="middle" width="100%">'+CloseLink+'</td>\n</tr>\n');
		write('</table>\n</form>\n');
	}

	HTMLFooter(WindowObjectName);
	WindowObjectName.document.close();
}
// ===========================================================================
