function globalOnLoad() {
    // Assign link events
    for (var i = 0; i < document.links.length; i++) {
        if (document.links[i].className.match('External')) {
            document.links[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (document.links[i].className.match('PDF')) {
            document.links[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (document.links[i].className.match('Enlargement')) {
            document.links[i].onclick = function() { enlargementPopup(this.href, this.title); return false; }
        }
		
		// added with the help of Mark Biek - force load new images on all hrefs with jpg
		if(document.links[i].href.match(/\.jpg$/i)) {
			//console.log(document.links[i].href);
			document.links[i].href += "?c=" + Math.round(new Date().getTime() / 1000);
			//console.log(document.links[i].href);
			
		}
    }
	

    // Run page onLoad function, if it exists
    if (typeof onLoad != 'undefined') {
        onLoad();
    }

}

winCounter = 0;
function offsitePopup(url) {
    var popUp = window.open(url, 'offsiteWindow'+winCounter, 'width=750,height=500,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes');
    if (typeof popUp == 'object') {
		winCounter = winCounter + 1;
        popUp.focus();
    }
}

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

addLoadEvent(globalOnLoad);

