function getScreenWidth() {
  if (screen.width < 800)
  	return screen.width;

  return 800;
}

function getScreenHeight(){
  if (screen.height < 600)
  	return screen.height;

  return 600;
}

function openWindow(theURL){

var nwidth = getScreenWidth() - 10;
var nheight = getScreenHeight() - 10;

var winparms ="resizable=yes,status=yes,width=" + nwidth + ",height=" + nheight + ",scrollbars=yes,top=5,left=100,toolbar=yes,location=yes,directories=yes,menubar=yes,alwaysRaised=yes,z-lock=no";

var win = window.open(theURL,"external",winparms);

if(win.opener == null)
	win.opener = window;

win.opener.name = "main";

if(window.focus)
	win.focus();

}