var oWindow = '';
  
function openwin(WinUrl,winname,width,height,features) {
 
// Note: This has an adjustment of minus 15 pixels.  Remove if want to.
  var winleft = ((screen.width - width) / 2)-15;
  var wintop  = ((screen.height - height) / 2)-25;
  
	//*** if the window already exists close it first.  Work around for moveTo permission denied
	if(!oWindow.closed && oWindow)  {
		oWindow.close();
	}


	oWindow = window.open(WinUrl,winname,'width=' + width + ',height=' + height + ',top=' + wintop + ',left=' + winleft + ',' + features);

	if (!oWindow.opener) {oWindow.opener = self};
	
	if (window.focus) {oWindow.focus()}
}