var             wndCount = 0;
var             curXPos = 0;
var 			curYPos = 0;
var             wnd = null;
var             ht_loc = "";
var             curr_frames = new Array (5);
var             fs_file;
var				fs_applet;

function OpenWindow (file, width, height, x_pos, y_pos, wndname) {

	var             name, cc, temp = "";

	if (width == 0)
		width = 850;
	
	if (height == 0)
		height = 630;

	// adjust x and y to fit on screen
	if (SupportsDHTML ()) {
		if (x_pos < screen.width) {
			if (x_pos + width > (screen.width - 15))
				x_pos -= (x_pos + width) - (screen.width - 15)
			}
		else {  // assume 2nd monitor
			if (x_pos + width > ((screen.width * 2) - 15))
				x_pos -= (x_pos + width) - ((screen.width * 2) - 15)
			}

		if (y_pos + height > (screen.height - 60))
			y_pos -= (y_pos + height) - (screen.height - 60)
		}

	if (wndname == "") {
		name = file.substring (0, file.indexOf ("."));
		name += wndCount;
		wndCount++;
		}
	else
		name = wndname;
	
	// take all invalid chars out of name
	for (i = 0; i < name.length; i++) {
		cc = name.substring (i, i+1);
		if ((cc >= 'a' && cc <= 'z') || (cc >= 'A' && cc <= 'Z') && (cc >= '0' && cc <= '9'))
			temp += cc;
		else {
			val = parseInt (cc);
			if (val >= 0 || val <= 9)
				temp += cc;
			else
				temp += "_";
			}
		}

	name = temp;

	if (FullDHTML () == 1)
		wnd = open (file, name, 'width=' + width + ',height=' + height + ',left=' + x_pos + ',top=' + y_pos + ',resizable=1,scrollbars=1')              
	else if (PartialDHTML () == 1)
		wnd = open (file, name, 'width=' + width + ',height=' + height + ',screenX=' + x_pos + ',screenY=' + y_pos + ',resizable=1,scrollbars=1')               
	else
		wnd = open (file, name, 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=1')

	if (wndname != "") {
		if (GetBrowser () == 0) // netscape
			wnd.focus ();
		else {
			if (FullDHTML ()) {
				test = wnd.location;    // this seems to make the window available
				wnd.focus ();
//                              setTimeout ("wnd.focus ()", 1000);
				}
			}
		}
	}

function ShowPopup (file, width, height) {
	var		name;

	name = "fhpopupwnd" + wndCount;
	wndCount++;
	OpenWindow (file, width, height, curXPos, curYPos, name);
	}

function ClosePopup () {

	var		name = window.name;

	if (name.indexOf ("fhpopupwnd") != -1)
		window.close ();
	}

function hide(id) {
	obj = document.getElementById(id);
	if ((obj.style.display == "") ||
	(obj.style.display == "none"))  {
	obj.style.display = "block";
	} else {
	obj.style.display = "none";
	}
	}
