// Prepare function for opening links in new windows.
function mw_newWindow()
{
	var newWin = window.open(this.getAttribute("href"), "_blank");
	if (newWin)
	{
		if (newWin.focus) { newWin.focus(); }
		return false;
	}
	return true;
}

// Create function to find external links and bind onclick handler.
function mw_externalLinks()
{
	if (document.getElementById && document.createElement && document.appendChild)
	{
		var anchors = document.getElementsByTagName("a");
		for (var i = 0; i < anchors.length; i++)
		{
			if (/\bexternal\b/.exec(anchors[i].getAttribute("rel")) && !anchors[i].onclick)
			{
				anchors[i].onclick = mw_newWindow;
			}
		}
	}
}

// Bind function to body onload handler.
mw_addOnload(mw_externalLinks);
