function wizPopup(mylink, windowname, width, height) {

        var x = (800 - width)/2;
        var y = (600 - height)/2;
        if (screen) {
                y = (screen.availHeight - height)/2;
                x = (screen.availWidth - width)/2;
        }
	window.top.frames["dataFrame"].wizWindow = window.open(mylink, windowname, 'scrollbars=no,resizable=no,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y);
        return;
}

function setWizardPage(enableFlag)	{ popupWindow.wizardPage = enableFlag; }
function getWindowHandle()			{ return popupWindow.windowHandle; }
function setWindowHandle(handle) {
	if (handle) {
		new popupWindow();
		popupWindow.windowHandle = handle;
		popupWindow.windowHandle.focus();
	}
}
function closeActivePopup() {
	if (popupWindow.wizardPage) {	
		return;
	}
	if (popupWindow.windowHandle && !popupWindow.windowHandle.closed) {
		popupWindow.windowHandle.close();
		popupWindow.windowHandle = 0;
	}
}
function popupWindow() {}
popupWindow.closeWindow		= false;
popupWindow.wizardPage		= false;
popupWindow.windowHandle	= 0;

// popup from a propertysheet, itself a popup
function closeActivePopup2() {						
	if (popupFromPopupWindow.windowHandle && !popupFromPopupWindow.windowHandle.closed) {
		popupFromPopupWindow.windowHandle.close();
		popupFromPopupWindow.windowHandle = 0;
	}
}

function popupFromPopupWindow() {}
popupFromPopupWindow.closeWindow	= false;
popupFromPopupWindow.windowHandle	= 0;

function getWindowHandle2() { return popupFromPopupWindow.windowHandle; }

function setWindowHandle2(handle) {
	if (handle) {
		new popupFromPopupWindow();
		popupFromPopupWindow.windowHandle = handle;
		popupFromPopupWindow.windowHandle.focus();
	}
}	

//////////////////////////////////////////////////////

function popup(mylink, windowname, width, height) {
	if (!window.focus) {
		return true;
	}
	closeActivePopup();
	var href;
	if (typeof(mylink) == 'string') {
		href = mylink;
	} else {
		href = mylink.href;
	}
	var x = (800 - width)/2;
	var y = (600 - height)/2;
	if (screen) {
		y = (screen.availHeight - height)/2;
		x = (screen.availWidth - width)/2;
	}	
	if (windowname == 'helpWindow') {		
		setWindowHandle(window.open(href, windowname, 'scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	else if (windowname == 'dialogScroll') {
		setWindowHandle(window.open(href, windowname, 'scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	else if (windowname == 'dialogResizable') {
		setWindowHandle(window.open(href, windowname, 'scrollbars=no,resizable=yes,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	else {
		setWindowHandle(window.open(href, windowname, 'scrollbars=no,resizable=no,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	return false;
}

var helpWindow;
function showHelp(helpContext)
{
	var path;
	
	path = 'help_' + helpContext + '.html';
	helpWindow = window.open(path, 'helpWindow', 'scrollbars=yes,resizable=yes,width=600,height=500');
	helpWindow.focus();
}

var newHelpWindow;
function showHelp2(helpContext)
{
        path = 'help_' + helpContext + '.html';
        newHelpWindow = window.open(path, 'newHelpWindow');
	newHelpWindow.focus();
}

function popupFromPopup(mylink, windowname, width, height) {
	closeActivePopup2();
	var href;
	if (typeof(mylink) == 'string') {
		href = mylink;
	} else {
		href = mylink.href;
	}
	var x = (800 - width)/2;
	var y = (600 - height)/2;
	if (screen) {
		y = (screen.availHeight - height)/2;
		x = (screen.availWidth - width)/2;
	}
	if (windowname == 'helpWindow') {		
		setWindowHandle2(window.open(href, windowname, 'scrollbars=no,resizable=yes,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	else if (windowname == 'dialogScroll') {
		setWindowHandle2(window.open(href, windowname, 'scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	else {
		setWindowHandle2(window.open(href, windowname, 'scrollbars=no,resizable=no,width=' + width + ',height=' + height + ',top=' + y + ',left=' + x + ',screenX=' + x + ',screenY=' + y));
	}
	return false;
}

function targetopener(mylink, closeme, closeonly, form) {
	if (!(window.focus && top.opener)) {
		return true;
	}
	top.opener.focus();
	if (!closeonly) {
		top.opener.location.href = mylink.href;
	}
	if (closeme) {
		window.close();
	}
	if (form) {
		form.submit();
		return true;
	}
	return false;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//						Check for errors
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var waitForError = 0;
function checkForError() {
 	if (waitForError == 0) {
		waitForError = setInterval("checkForUpdateError()", 250);
	}
}
function checkForUpdateError() {
	if (!top.opener || top.opener.closed
	 || !top.opener.top.frames["statusFrame_0006B11A1228"]
	 || !top.opener.top.frames["statusFrame_0006B11A1228"].document) {
		clearInterval(waitForError);
		waitForError = 0;
		if (canClose) {			
			top.close();
		}			  
		return;
	}
	if (top.opener.top.frames["statusFrame_0006B11A1228"].document.statusBarForm) {
		clearInterval(waitForError);
		waitForError = 0;
		if (top.opener.top.frames["statusFrame_0006B11A1228"].errorExists == 1) {
			setErrorMessage(top.opener.top.frames["statusFrame_0006B11A1228"].strErrorMessage);
		} else {
			if (popupFromPopupWindow.windowHandle) {
				popupFromPopupWindow.windowHandle.close();
				popupFromPopupWindow.windowHandle = 0;
			}
			checkRefreshNeeded();
			if (canClose) {			
				top.close();
			}			  
			setErrorMessage("Ready"); 
		}
	}
}
function setErrorMessage(strError) {
	if (document.getElementById('errorStatus')) {
		if (strError == "Ready") {
			document.getElementById('errorStatus').style.color = "black";															  	
		} else {
			document.getElementById('errorStatus').style.color = "red";
		}
		document.getElementById('errorStatus').innerHTML = " " + strError;
	}
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//					Check for StatusBar to load 'Please Wait...' form
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var waitForLoad=0;
function doSubmit(str) {
	doSubmit2(str, document.thisForm);
}
function doSubmit2(str, form) {	
	if (form.cgiaction) {
		form.cgiaction.value = str;						
	}
	top.opener.top.frames["statusFrame_0006B11A1228"].location.href="/wait2.html";					  
	setErrorMessage("Please Wait...");   
	if (waitForLoad == 0) {
		waitForLoad = setInterval("checkForWaitLoad()", 1000);
	}
}
function checkForWaitLoad() {
	if (top.opener.top.frames["statusFrame_0006B11A1228"].location.pathname == "/wait2.html") {
		if (top.opener.top.frames["statusFrame_0006B11A1228"].document.statusWaitForm) {
			clearInterval(waitForLoad);
			waitForLoad = 0;
			submitForm();
		}
	}
}	

/* If popup itself contains frames */ 
var waitForLoadFrames=0;
function doSubmitFrames(str) {	
	document.thisForm.cgiaction.value = str;						
	top.opener.top.frames["statusFrame_0006B11A1228"].location.href="/wait2.html";					  
	setErrorMessage("Please Wait..."); 
	if (waitForLoadFrames == 0) {
		waitForLoadFrames = setInterval("checkForWaitLoadFrames()", 1000);
	}
}	
function checkForWaitLoadFrames() {
	if (top.opener.top.frames["statusFrame_0006B11A1228"].location.pathname == "/wait2.html") {
		if (top.opener.top.frames["statusFrame_0006B11A1228"].document.statusWaitForm) {
			clearInterval(waitForLoadFrames);
			waitForLoadFrames = 0;
			submitFormFrames();
		}
	}
}	  

