// 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(2);
// 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
languages[0][0] = "extern";
languages[0][1] = "Externer Link in einem neuem Fenster";
if(this.location.href.indexOf("/f/") != -1) {
	languages[0][1] = "Lien externe vers une nouvelle fenêtre";
}
if(this.location.href.indexOf("/e/") != -1) {
	languages[0][1] = "Link will open in a new window";
}
// define more if you want
var j = 0;

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];
		// if language is french
		
		// get the title of the single Link
		titleOld = singleLink.getAttribute("title");
		// get the href of the single Link
		linkHref = singleLink.getAttribute("href");
		// if the title is available
		if(titleOld) {
			if(titleOld.indexOf(languages[j][0]) != -1) {
				// write the new title-Tag
				singleLink.setAttribute("title", languages[j][1]);
				// 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
			}
		}
		if(linkHref) {
			if(linkHref.indexOf(".pdf") != -1) {
				// write the new title-Tag
				singleLink.setAttribute("title", languages[j][1]);
				// 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
			}
		}
	}
}

// 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
