/**
 * Unobtrusive popup window handler from:
 * http://mar.anomy.net/entry/2004/02/09/12.17.47/
 */

var popupLinkConfig = new Array;
// Delete/copy/modify the following lines to configure your popup windows.
popupLinkConfig["popup"] = new Array ( "", "width=660,height=600,scrollbars=no,menubar=no");
popupLinkConfig["popupscroll"] = new Array ( "", "width=680,height=500,scrollbars=yes,menubar=no");

//window.onload = initPage;  
// Make sure that no other javscripts assign a fuction to window.onload
// There can be only one window.onload at a time

//function initPage() {
//  alert("init");
//  initPopupLinks();
//  // place here any other code you wish to run when the page loads.
//}

function initPopupLinks() {
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp() {
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}

function popUpManual(windowname, url, query, width, height) {
  if(!window.focus)
    return true;
  
  var left = (screen.width - width) / 2;
  var top = (screen.height - height) / 2;
  if(left < 0) left = 0;
  if(top < 0) top = 0;
  
  return window.open(url + '?' + query, windowname, 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',scrollbars=no');
}