/* POPUP WINDOW FUNCTION
Unobtrusive JS: uses class of anchor tag to apply pop-up window script
classes should be added to arrays in popupLiinkConfig to set the various 
settings within the popUp function

Place <body class=”” onload="initPopupLinks();"> on the page that calls this script
------------------------------------------------------------------------------------ */

var popupLinkConfig = new Array;

// Example: 
// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["pp08PromoWinners"] = new Array ( "pp08PromoWinners", "width=660,height=560,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=no,menubar=no,resizable=no,location=no");
popupLinkConfig["pp08rules"] = new Array ( "popup", "width=620,height=367,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=no,location=no");
popupLinkConfig["emailfriend"] = new Array ( "popup", "width=450,height=440,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=no,menubar=no,resizable=no,location=no");
popupLinkConfig["popup_privacy"] = new Array ( "popup_privacy", "width=480,height=350,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=no,location=no");
popupLinkConfig["popup_footer"] = new Array ( "popup", "width=480,height=360,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=no,menubar=no,resizable=no,location=no");
popupLinkConfig["popup_footer_scroll"] = new Array ( "popup", "width=480,height=350,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=no,location=no");
popupLinkConfig["popup"] = new Array ( "popup", "width=800,height=600,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=yes,resizable=yes,location=yes");

// Use these from now on please with the stc -John
popupLinkConfig["stc-popup_footer"] = new Array ( "stc-popup_footer", "width=480,height=350,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=no,menubar=no,resizable=no,location=no");
popupLinkConfig["stc-popup_footer_scroll"] = new Array ( "stc-popup_footer_scroll", "width=480,height=350,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=yes,location=no");
popupLinkConfig["stc-popup"] = new Array ( "stc-popup", "width=800,height=600,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=yes,resizable=yes,location=yes");
popupLinkConfig["stc-popup_scroll"] = new Array ( "stc-popup_scroll", "width=500,height=650,left="+ ((screen.availWidth - 800) /2) + ",top=" + (((screen.availHeight - 600) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=no,location=no");


// ==========================================================================

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;
}