function launch(newURL, newName, newFeatures, orgName, backURL) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.backURL = backURL;
  remote.opener.name = orgName;
  remote.focus();
  return remote;
}

function openWin(strLocation, windowName, w, h, backURL ) {
   myRemote = launch(strLocation, windowName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes,width=" + (w || "400") +",height=" + (h || "300") + ",left=100,top=50","parentWin", backURL);
}

function openWinPocket(strLocation, windowName, w, h, backURL ) {
  myRemote = launch(strLocation, windowName,"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes,width=" + (w || "800") +",height=" + (h || "600") + ",left=100,top=50","parentWin", backURL);
}

function openNwin(strLocation, windowName, w, h, backURL, toolbar, loc, dir, stat, menu, scroll, resize, raised) {
  
  w = w != null ? w : 800;
  h = h != null ? h : 400;

  if (screen != null) {
  	var awidth = screen.availWidth;
  	var aheight = screen.availHeight;
  	
	if (awidth < w) {
		w = awidth;
	}
	if (aheight < h) {
		h = aheight;
	}
  }
  
  var rem = open(strLocation, windowName, "toolbar="+toolbar+",location="+loc+",directories="+dir+",status="+stat+",menubar="+menu+",scrollbars="+scroll+",resizable="+resize+",alwaysRaised="+raised+",width="+w+",height="+h+",left=100,top=50","parentWin", backURL);

 self.blur();

}

// For Thrifty window
function openTWin(strLocation, windowName, w, h) { 
   if (!myThrifty || myThrifty.closed) {
   	myThrifty = launchExpTwin(strLocation, windowName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes,width=" + (w || "400") +",height=" + (h || "300") + ",left=10,top=50","parentWin");
   } else {
	myThrifty.opener.blur();
	myThrifty.focus();
   } 
}

// For thrifty window. Removes "focus" command so Thrifty window doesn't "flash-focus" during loading of page 
function launchExpTwin(newURL, newName, newFeatures, orgName) {  
  var remote = open(newURL, newName, newFeatures);  
  return remote;  
}
