//
// This JavaScript fixes the omission of the 'target' attribute
// in the anchor-tag in XHTML 1.0 Strict.
//
// Further reading: http://www.sitepoint.com/article/standards-compliant-world
//
// Copyright (c) 16 Mar 2006 by Peter Bittner

//
// Tells the browser to open any 'a href's, which are specifying a
// 'rel="external"' attribute, in a new browser window.
//
// NOTE: You need to specify a rel-attribute with value "external" in
//       any anchor tag you want to have opened in a new window!
//
// e.g. <a href="http://peter.bittner.it/" rel="external">...</a>
//

function initExternalLinks()
{
	if (!document.getElementsByTagName)
		return;

	var anchors = document.getElementsByTagName("a");

	for (var i = 0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

// Credits to Simon Willison for this function.
// taken from: http://www.webreference.com/programming/javascript/onloads/
function addLoadEvent(func)
{
	var oldonload = window.onload; 
	if (typeof window.onload != 'function')
		window.onload = func;
	else
	{
		window.onload = function()
		{ 
			if (oldonload)
				oldonload();
			func();
		}
	}
} 

// run the function above when finished loading the document
addLoadEvent(initExternalLinks);

