
function LinkIcons()
{
    this.load = LinkIcons_Load;
	this.start = LinkIcons_Start;
    this.addImage = LinkIcons_AddImage;

	this.load();
}

function LinkIcons_Load()
{
    // Attach the processing function to the window's onLoad event.
	// Save existing events and execute those first, so we don't mess up existing scripts.
    var x = this;
    var previousHandler = window.onload ? window.onload : new Function();
    window.onload = function() { previousHandler(); x.start(); };
}

function LinkIcons_Start()
{
    elements = document.body.getElementsByTagName('a');
    for (var i = 0; i < elements.length; i++) {

        classDef = elements[i].className;
		classes = classDef.split(' ');
		newClasses = [];
		var k = 0;
		for (var j = 0; j < classes.length; j++) {
		    if (classes[j] == 'document' || classes[j] == 'external') {
			    if (classes[j] == 'external') {
				    title = 'externe link';
				} else {
				    title = classes[j];
				}
			    this.addImage(elements[i], classes[j], title);
			} else {
			    newClasses[k++] = classes[j];
			}
        }
		elements[i].className = newClasses.join(' ');
	}
}

function LinkIcons_AddImage(el, name, title)
{
    el.innerHTML = '<span class="underlined">' + el.innerHTML + '</span><img alt="(' + title + ')" title="' + title + '" class="linkicon" src="/images/general/link-' + name + '.gif"/ >';
    el.style.textDecoration = "none";
}

LI = new LinkIcons();