// Allows multiple functions to load

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


// Opens PDF links in new windows

function doPopups()
{
 if (!document.getElementsByTagName) return false;
 var links = document.getElementsByTagName("a");
 for (var i=0; i < links.length; i++) {
  if (links[i].href.indexOf('.pdf') !== -1) {
   links[i].onclick =
    function() {
     window.open(this.href,'popper','resizable,top=10,left=10,scrollbars,menubar');
     return false;
    }
    links[i].title += "\(document opens in a new window)";
    //var img = document.createElement("img");
    //img.setAttribute("src", "i/new-win-icon.gif");
    //img.setAttribute("alt", "(opens in a new window)");
    //links[i].appendChild(img);
  }
else if (links[i].href.indexOf('.doc') !== -1) {
   links[i].onclick =
    function() {
     window.open(this.href,'popper','resizable,top=10,left=10,scrollbars, menubar');
     return false;
    }
    links[i].title += "\(document opens in a new window)";
    //var img = document.createElement("img");
    //img.setAttribute("src", "i/new-win-icon.gif");
    //img.setAttribute("alt", "(opens in a new window)");
    //links[i].appendChild(img);
  }
else if (links[i].href.indexOf('.jpg') !== -1) {
   links[i].onclick =
    function() {
     window.open(this.href,'popper','width=800,height=404,top=10,left=10,scrollbars');
     return false;
    }
    links[i].title += "\(document opens in a new window)";
    //var img = document.createElement("img");
    //img.setAttribute("src", "i/new-win-icon.gif");
    //img.setAttribute("alt", "(opens in a new window)");
    //links[i].appendChild(img);
  }
else if (links[i].href.indexOf('.jpe') !== -1) {
   links[i].onclick =
    function() {
     window.open(this.href,'popper','width=500,height=734,top=10,left=10,scrollbars');
     return false;
    }
    links[i].title += "\(document opens in a new window)";
    //var img = document.createElement("img");
    //img.setAttribute("src", "i/new-win-icon.gif");
    //img.setAttribute("alt", "(opens in a new window)");
    //links[i].appendChild(img);
  }
 }
}


addLoadEvent(doPopups);


