// to change dynamically the title-Tag and target for a link, which should open in a new window
// confirms with XHTML 1.0 Strict and the WCAG/BITV
// coded by Joern Hofer: jhATgrassi.de (2004-04-04)
// as it seems, this doesn't work on IE5 on mac
// here we go:

//	different languages in an array
//	[x][0] is the identifier for an external link
//	[x][1] is the additional text to announce a new window
//	var languages = new Array(x), x defines the among of languages
var languages = new Array(3);
//	and now we make each array-element to an array with 2 dimensions
for(i = 0; i < languages.length; i++) {
	languages[i] = new Array(2);
}
// german 1
languages[0][0] = "Externer Link";
languages[0][1] = "in einem neuem Fenster";
// german 2
languages[1][0] = "externer Link";
languages[1][1] = "in einem neuem Fenster";
// english
languages[2][0] = "External Link";
languages[2][1] = "in a new window";



// define more if you want

function changeTitleAndTarget() {
//	check, if the browser understands the new DOM, if not, stop here
//	(we can't change the title, so we can't open it in a new window, if we still want to get WCAG or BITV accessibility)
	if(!document.getElementsByTagName) return;
//	fill up an array with all links in the page
	var links = document.getElementsByTagName("a");
//	for-loop to address each single Link
	for(i = 0; i < links.length; i++) {
//	declare tempVariable for single Link
		var singleLink = links[i];
//	get the title of the single Link
		titleOld = singleLink.getAttribute("title");
// if the title is available
		if(titleOld) {
// and now we get through our different languages
			for(j = 0; j < languages.length; j++) {
//	let us check, if our defined identifier of that language for external links is present
				if(titleOld.indexOf(languages[j][0]) != -1) {
//	split up the given title-Tag to get the text behind our identifier
					titleAddition = titleOld.substring((titleOld.indexOf(languages[j][0])) + languages[j][0].length, titleOld.length);
//	write the new title-Tag
					singleLink.setAttribute("title", languages[j][0] + " " + languages[j][1] + titleAddition);
//	and now we declare, that the external link should open in a new window (you can also use another name, 
//	to open all external links in one window, but than you will need an extra .focus() for that window
					singleLink.target = "_blank";
//	and if we got this, we do not need the for-loop of the languages anymore
					break;
				}
			}
		}
	}
}
//	if the document is loaded, we start our title/target-changing
window.onload = changeTitleAndTarget;

//	that's it
//	insert this JS-file to change your external Links. If JS is enabled it will change all, 
//	if not, the external links will work as normal links in the same window
