/*******************************************************************************
**
**	target.js
**	Copyright 2004 Clough, Harbour & Associates LLP.  All rights reserved.
**  
**	PURPOSE:
**		Scans the document for links, and changes any links to external sites by
**		setting their target attribute to "_blank".  Useful because XHTML 1.0 
**		Strict does not include the "target" attribute on the "a" element, so 
**		setting the target attribute in the HTML document prevents the document 
**		from validating.
**	
**	HISTORY:
**		2004-02-20 (PKC) - Initial Version.
**		Tested with Internet Explorer 6.0, Mozilla Firefox 0.8.
**	
*******************************************************************************/

// You must pass in the "siteUrl" variable.
if(!window.siteUrl)
{
	throw("Site URL not defined!");
}
if(document.getElementsByTagName)
{
	var links = document.getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		var l = links[i];
		if(
			l.attributes.href &&
			(
				(l.attributes.href.nodeValue.match(/\.pdf$/)) ||
				(
					(l.attributes.href.nodeValue.indexOf("http") == 0) &&
					(l.attributes.href.nodeValue.indexOf(siteUrl) != 0)
				)
			)
		)
		{
			l.setAttribute("target","_blank");
		}
	}
}
