var apptformwin = null;

function openNewWindow(pathname,wintitle,winw,winh) {

if (window.screen) {
			var aw = screen.availWidth;
			var ah = screen.availHeight;
var winLeft = 0;
var winTop = 0;
			}
		
if (aw < 700) {
var winWidth = winw;
var winHeight = winh;
}
else if (aw > 700) {
var winHeight = winw;
var winWidth = winh;
var winLeft = (aw-winWidth)/2;
var winTop = (ah-winHeight)/2;
}
else {
var winWidth = winw;
var winHeight = winh;
winLeft = 0;
winTop = 0;
}

var options = 'width=' + winWidth + ',height=' + winHeight +
              ',left=' + winLeft + ',top=' + winTop + ',scrollbars=no,resizable=no,menubar=no, status=no,toolbar=no,location=no,directories=no';

var options2 = 'width=' + winWidth + ',height=' + winHeight +
              ',left=' + winLeft + ',top=' + winTop + ',scrollbars=no,resizable=no,menubar=no, status=no,toolbar=yes,location=no,directories=no';

	if (navigator.appVersion.substring(0,1) < 4) {
		apptwinObj = window.open(pathname, wintitle, options2);
	} else {
		apptwinObj = window.open(pathname, wintitle, options);
		}
	return apptwinObj;
}

function openNewForm(pathname,wintitle,winw,winh) {
	if (apptformwin == null || apptformwin.closed) {
		apptformwin = openNewWindow(pathname,wintitle);
	} else {
		apptformwin.focus();
	}
}

