// Popup window script that is dynamic and will regain focus
// Modified link system to use this one script and pass parameters
// for lighter page weight and more flexibility.

function pop(u,n,f){
   var d = "default";
   var sf = "directories,location,menubar,resizable,scrollbars,status,toolbar";

   if (!n){n = d}
   if (!f){f = sf}
   pw = window.open(u,n,f);
   pw.focus();
}

function openLink(linkID){
   if(!window.opener.closed){
      window.opener.location.href = linkID;
   } else {
      newWin = window.open(linkID,'');
      newWin.focus();
   }
   self.close();
}

// This function changes the location of the Parent window and closes the corresponding pop-up
function changeParentWindow(url) {
   //alert("url="+url);
   var ah,aw,str;
   if (!opener.closed) {
      opener.location=url;
      self.close();
      opener.focus(); 
   } else { 
      // if opener was closed newWindow below will open window the same size as self which may be too small...
      str = "left=0,screenX=0,top=0,screenY=0";
			
      if (window.screen) {
         //  we want to open a fullscreen window max size is 800 x 600
	 ah = screen.availHeight > 600 ? 600 : screen.availHeight - 30;
	 aw = screen.availWidth > 800 ? 800 : screen.availWidth - 10;
	 str += ",height=" + ah;
	 str += ",innerHeight=" + ah;
	 str += ",width=" + aw;
	 str += ",innerWidth=" + aw;
      } else {
         // so the user can resize the window manually
         str += "directories,location,menubar,resizable,scrollbars,status,toolbar"; 
      } 
      url += ",default," + str;
      newWindow = window.open(url);
      self.close(); 
      newWindow.focus(); 
   } 
}


function changeParentFrameWindow(url) {
	opener.top.location.href=url;
	self.close();
	opener.focus();
}


function closeWindow() {
	self.close ()
}


// Timed window function, takes time parameter in seconds
var timerID = null;
function wait(time) {
	timerID = setTimeout("closeWindow()",time*1000)
}
