﻿
/* This script gets all elements in the document, then stores the id's of elements with a class name of "popup" 
** in an array called popups. In order to make things work properly (in IE), the onload function clears the popups 
** array then rebuilds the array with id's of elements with class name of "popup". The function close_popups simply 
** calls the onload function to rebuild the popups array, and gives the popups array scope within the close_popups 
** function. Then the close_popups function iterates through the popups array and sets display:none for each id stored. 
** The main function is popup, which takes the id of the desired element to be affected, then checks
** to see if the element has display:block, which simply calls close_popups. Otherwise, if not display:block, 
** then close_popups is called, AND the element matching the id is then set display:block.
*/
var tags = document.getElementsByTagName('*');
var popups = new Array();
function popup_list() {
  popups.length = 0;
  for (var i=0;i < tags.length;i++) {
    if (tags[i].className == "popup") {
      popups.push(tags[i].id);
      tags[i].style.display = "";
    }
  }
}
function close_popups() {
   popup_list();/*call to rebuild the popups array, makes things work in IE*/
   for (var i=0;i < popups.length;i++) {
        document.getElementById(popups[i]).style.display = "";
    }
}
function popup(id) {
  if (document.getElementById(id).style.display == "block") {
    close_popups();
  } else {
    close_popups();
    document.getElementById(id).style.display = "block";
  }
}
