function externalLinks() {
	if (!document.getElementsByTagName) return;
 	
	var allAnchors = document.getElementsByTagName("a");
 	var allAnchorsLength = allAnchors.length;
	
	for (var i=0; i<allAnchorsLength; i++) {
   		var anchorItem = allAnchors[i];
  		
		if (anchorItem.getAttribute("rel") == "external"){
     		anchorItem.setAttribute("target","_blank");
 		}
		else if(anchorItem.getAttribute("rel") == "popup"){
			anchoredTo = anchorItem.getAttribute("href");
			
			anchorItem.setAttribute("popUpLink",anchoredTo);
			
			anchorItem.onclick = function(){
				openPopup(this.getAttribute("href"));
				return false;
			}
//			anchorItem.onclick = "openPopup('" + linkedPage + "');";
		}
	}
}

function openPopup(linkedPage){
	var popUpWidth = 620;
	var popupHeight = 400;
	var features ="scrollbars,height=" + popupHeight + ",width=" + popUpWidth + ",left=40,top=60";
  	winName = new Date();
    winName = 'win' + winName.getTime().toString();
   	window.open(linkedPage, winName, features);
}

addLoadEvent(externalLinks);
