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



 // prepare links for local popup windows
function prepareLinks() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
			if (links[i].className == "releasepopup") {
			links[i].onclick = function() {
				popup(this.getAttribute("href"));
				return false;
			}
		}
	}
}

// settings for the generic popup window
function popup(winURL) {
	/* window.open(winURL, "releasepopup", "width=620,height=810"); */
}

// make external links popup in a new window
function handleExternalLinks() {
	var anchors = document.getElementsByTagName("a");
	var i, href;
	for(i=0; i < anchors.length; i++){
		if(!anchors[i].href) continue;
		href = anchors[i].href;
		if(href.indexOf("erratikproductions.com") == -1){ // Href is not a file on my server
			if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
				if(!anchors[i].onclick){ // Href does not have an onclick event
					if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
						if(href.indexOf("http://") != -1){ // Href is not relative (for Safari)
							anchors[i].setAttribute("target","_blank");
						}
					}
				}
			}
		}
	}
}

// load your suckas!
addLoadEvent(handleExternalLinks);
addLoadEvent(prepareLinks);