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

function acpopup(strURL,strType,strHeight,strWidth,strTop,strLeft) {
	var strOptions="";
	if (strType == "textwin") {
		strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth+",top="+strTop+",left="+strLeft;
		popupWin = window.open(strURL, 'Textwindow', strOptions);
		popupWin.focus();
		
		} else if (strType == "imgwin") {
		strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth+",top="+strTop+",left="+strLeft;
		popupWin = window.open(strURL, 'Imagewindow', strOptions);
		popupWin.focus();
	}
}

function windowLinks() {							
	if(!document.getElementsByTagName) {			
		return;										
	}
	
	var anchors = document.getElementsByTagName("a");	
	for (var i = 0; i < anchors.length; i++) {			
		var anchor = anchors[i];						
		var relIndex = anchor.rel;						
		if (relIndex){									
			var relSplit = relIndex.split("|");
	
			if (relSplit[0] == "external") {		
				anchor.target = "_blank";			
				anchor.className = "external";		 
				anchor.title = "Åbner i nyt vindue";  				
	
				} else if (relSplit[0] == "popup") {		
				anchor.className = "popup";					
				anchor.title = "Åbner i popup vindue";		
				anchor.popupWidth = relSplit[1];			
				anchor.popupHeight = relSplit[2];			
				anchor.popupTop = relSplit[3];				
				anchor.popupLeft = relSplit[4];				
				anchor.onclick = function() {acpopup(this.href,'textwin',this.popupWidth,this.popupHeight,this.popupTop,this.popupLeft);return false;};
	
				} else if (relSplit[0] == "popupx") {		
				anchor.className = "popupx";					
				anchor.popupWidth = relSplit[1];			
				anchor.popupHeight = relSplit[2];			
				anchor.popupTop = relSplit[3];				
				anchor.popupLeft = relSplit[4];				
				anchor.onclick = function() {acpopup(this.href,'imgwin',this.popupWidth,this.popupHeight,this.popupTop,this.popupLeft);return false;};
			}
		}
	}
}

addLoadEvent(function() {
	windowLinks();
});
