/* Opens a Pop Up window and transfers focus to it. If window is already open, closes it
 so we can open it with a different size, then reopens it. */
var newWindow;
/* Add a  margin to the available width, height so we fit the screen comfortably.*/
var availWidth = screen.availWidth - 100;
var availHeight = screen.availHeight - 120;

function popUp ( url, name, width, height, scrollBar ) {
    /* Set the window size. */
    if (availWidth < width ) { width = availWidth }
    if (availHeight < height) { height = availHeight }
	if (newWindow) {
		if (newWindow.closed == false) {
            newWindow.close();
		}
	}
	newWindow = window.open(url,name,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars='+scrollBar+',resizable=1,width='+width+',height='+height);
    newWindow.focus();
}

