// Popup Window Functions -- popup_windows.js
// Copyright (c) 2002 Mental Models, Inc. All rights reserved.

// Last Updated: Thursday, October 10th, 2002


// Library Usage:
// <SCRIPT TYPE="text/javascript" SRC="/javascript/popup_windows.js"></SCRIPT>


// popUpWindow() Text Link Usage:
// <A HREF="javascript:popUpWindow('/html/somepage.html','WindowName');">Link</A>


// popUpWindow() Button Usage (Two Options):   [see next note re: new variables]
// <INPUT TYPE="BUTTON" VALUE="Button Text" onClick="popUpWindow('/html/somepage.html','QADeQPopupWindow');">
// <BUTTON onClick="popUpWindow('/html/somepage.html','QADeQPopupWindow');">Button Text</BUTTON>


// The popUpWindow() function now accepts optional width and height parameters.
// If either or both are omitted, the default values will be used.
// The default values are specified in the first two lines of code.

// As an example of parameter usage, see the "Customize" button in the taskbar;
// it uses the following call to override pop-up window size defaults:
// onClick="popUpWindow('/html/customize.html','CustomizeTaskbarPopupWindow',500,675);"



var popUpWidth = 700;
var popUpHeight = 525;
var popUpX = (screen.availWidth - popUpWidth)/2;
var popUpY = (screen.availHeight - popUpHeight)/2;


function popUpHelpWindow(URL,windowName) {
  window.status = '';
  var popUpHelpWidth=300;
  var popUpHelpHeight = screen.availHeight - 40;
  
  popUp = window.open(URL, windowName, 'width=' + popUpHelpWidth + ',height=' + popUpHelpHeight + ',left=' + 0 + ',top=' + 0 + ',resizable=yes,scrollbars=yes,status=yes');
  popUp.focus();
  
  return;
}

function popUpWindow(URL, windowName, width, height) {

  window.status = '';


  if (width && height)
  {

    x = (screen.availWidth - width)/2;
    y = (screen.availHeight - height)/2;

    popUp = window.open(URL, windowName, 'width=' + width + ',height=' + height + ',left=' + x + ',top=' + y + ',resizable=yes,scrollbars=yes,status=no');

  }

  else
  {

    popUp = window.open(URL, windowName, 'width=' + popUpWidth + ',height=' + popUpHeight + ',left=' + popUpX + ',top=' + popUpY + ',resizable=yes,scrollbars=yes,status=no');

  }

  popUp.focus();

  return;

}


function popUpNormalWindow(URL, windowName, width, height) {


  window.status = '';


  if (width && height)
  {

    x = (screen.availWidth - width)/2;
    y = (screen.availHeight - height)/2 - 75;

    popUp = window.open(URL, windowName, 'width=' + width + ',height=' + height + ',left=' + x + ',top=' + y + ',location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes');

  }

  else
  {

    popUp = window.open(URL, windowName, 'width=' + popUpWidth + ',height=' + popUpHeight + ',left=' + popUpX + ',top=' + popUpY + ',location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes');

  }


  popUp.focus();


  return;

}


function focusAndClose() {

  //if (self.opener) { alert('"self.opener" exists.'); }
  //else { alert('"self.opener" does not exist.'); }

  if (self.opener)
  {

    if (self.opener.open) { self.opener.focus(); }

  }

  self.close();

  return;

}


function changePage(URL) {

  window.location.href = URL;

  return;

}


function checkAll() {

  var inputElements = document.getElementsByTagName('input');


  for (var i = 0; i < inputElements.length; i++)
  {

    if (inputElements[i].type == 'checkbox') {

      inputElements[i].checked = true;

    }

  }


  return;

}
