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


/**** REL = EXTERNAL ***/
addLoadEvent(function() {
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {
			anchor.target = "_blank"; 
			anchor.onclick = function() {
				newWindow(this.href, 'popup', 530, 500, 0, 0, 0, 0, 0, 0, 0); 
				return false;
			}
		}
	} 
})


function newWindow(url, name, width, height, scrollbars, resizable, menubar, toolbar, addressbar, statusbar, fullscreen) {
  var windowLeft = (screen.width - width) / 2;
  var windowTop = (screen.height - height) / 2;
  var windowProperties = 'height=' + height + ',width=' + width + ',top=' + windowTop + ',left=' + windowLeft + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',menubar=' + menubar + ',toolbar=' + toolbar + ',location=' + addressbar + ',statusbar=' + statusbar + ',fullscreen=' + fullscreen + '';
  var windowObj = window.open(url, name, windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      windowObj.window.focus();
    }
}