var popWin = null;

function openPopWin(winURL, winName, winWidth, winHeight, winCenter, winScrollbars) {
	var dateNow = new Date();
	var timestamp = dateNow.getTime();

	if(winCenter == true) {
		var winLeft = (screen.availWidth / 2) - (winWidth / 2); // Center Window in Screen
		var winTop = (screen.availHeight / 2) - (winHeight / 2); // Center Window in Screen
	} else {
		var winLeft = 0
		var winTop = 0
	}

	var winFeatures = "toolbar=no,location=no,status=no,menubar=no,scrollbars=" + winScrollbars + ",resizable=no";
	winFeatures += getScreenLocation(winWidth, winHeight, winLeft, winTop);

	closePopWin(); // close any previously opened pop-up window

	popWin = window.open(winURL, winName + "_" + timestamp, winFeatures);
}

function closePopWin() { // close pop-up window if it is open
	if(navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4) { //do not close if early IE
		if(popWin != null) {
			if(!popWin.closed) {
				popWin.close();
			}
		}
	}
}

function getScreenLocation(winWidth, winHeight, winLeft, winTop){
	if(winLeft == 0 || winTop == 0) {
		return ",width=" + winWidth + ",height=" + winHeight;
	} else {
		return ",width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop;
	}
}

function refreshOpener() {
	opener.location.reload();
}
