var newWindow = null;

function closeWin() {
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, popWidth, popHeight) {
	
	var tools="";
	var winX = (screen.width - popWidth)/2;
	if (winX < 0) winX = 0;
	var winY = (screen.height - popHeight) / 2;
	if (winY < 0) winY = 0;

	closeWin();
	
	if (type == "fullScreen"){
		popWidth = screen.availWidth - 10;
		popHeight = screen.availHeight - 160;
	}
	
	if (type == "standard" || type == "fullScreen") {
		tools = "resizable=yes,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	} else if (type == "console") {
		tools = "resizable=yes,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	} else if (type == "ColorKey") {
		tools = "resizable=yes,toolbar=no,location=no,scrollbars=yes,menubar=no,width="+strWidth+",height="+strHeight+",top="+winX+",left="+winY;
	}
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

