//------------------------------------------------------------------------------------
// Function to open a new window with various properties
//------------------------------------------------------------------------------------
function newWindow(URL, windowName, menuFlag, 
				pHeight, pWidth, centerWindow) {
					
	if (parseInt(navigator.appVersion) >= 4) {
		isDyn = true;
	}
	else {
		isDyn = false;
	}

	if (pHeight != null && pWidth != null) {
		wWidth = pWidth;
		wHeight = pHeight;
	}
	else {
		// set absolute defaults in case not a 4.0 or greater
		wWidth = 450;
		wHeight = 500;
	
		// ok...figure out the screen size
	
		if (isDyn) {
			wWidth = parseInt(screen.width * .75);
			wHeight = parseInt(screen.height * .75);
		}
	}
	
	if (windowName == null)
		windowName = "popupWindow";
	
	if (menuFlag) menuFlag = 'yes'; else menuFlag = 'no';
	
	var windowFeatures = "height=" + wHeight + ",width=" + wWidth;
	windowFeatures += ",resizable=yes,toolbar=no,scrollbars=yes,menubar=";
	windowFeatures += menuFlag;

	var windowHandle = window.open(URL, windowName, windowFeatures);
	
	if (centerWindow) {
		windowHandle.focus();
	
		if (isDyn) {
			var sWidth = screen.width;
			var sHeight = screen.height;
			
			windowHandle.moveTo(sWidth / 2 - wWidth / 2, 
								sHeight / 2 - wHeight / 2 - 35);
		}
	}
	
	/*if (centerWindow) {	
		if (isDyn) {
			var sWidth = screen.width;
			var sHeight = screen.height;
			windowFeatures += ",left=" + (sWidth / 2 - wWidth / 2) + ",top=" + (sHeight / 2 - wHeight / 2 - 35);
		}
	}
	var windowHandle = window.open(URL, windowName, windowFeatures);*/

	return windowHandle;
}

//------------------------------------------------------------------------------------
// Function to open a form submission in a new window
//------------------------------------------------------------------------------------
function runFormInWindow(form, windowName, menuFlag, 
						pHeight, pWidth, centerWindow) {
	// open a blank window, wait, then run the form
	if (!newWindow('/blank.html', windowName, 
					menuFlag, pHeight, pWidth, centerWindow)) {
		form.target = windowName;
		form.submit();
	}	
}
