// JavaScript Document

// <![CDATA[
	/************************************************
		New window link
		by Marko Dugonjic, http://www.maratz.com/
	*************************************************/

	// Set paramethers:
	var path_to_icon 		= 'images/generic/ext_link.gif';
	var link_alt_text 		= 'open link in new window';
	var link_title_text 	= 'Open this link in new window!';

	function new_window_link() {
		if (!document.getElementById || !document.createTextNode || !document.domain);
		var l = document.getElementsByTagName('a');
		for (var i = 0; i < l.length; i++) {

			// just for off-site links
			if (l[i].getAttribute('href').indexOf("mailto") != -1)
			{
					// does not add to the link if it is a mailto
					// could be extended for javascript: if needed
			}
			else if ((l[i].href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')
				&& !l[i].getAttribute('target')
				&& !l[i].parentNode.id.match(/^copy/))) {


				// create new elements
				var nwl = document.createElement('a');
				var nwl_image = document.createElement('img');
				var space = document.createTextNode(' ');

				// setup image attributes
				nwl_image.setAttribute('src', path_to_icon);
				nwl_image.setAttribute('alt', link_alt_text);
				nwl_image.setAttribute('title', link_title_text);

				// set link attributes
				nwl.setAttribute('href', l[i].getAttribute('href'));
				nwl.setAttribute('target', '_blank');
				nwl.setAttribute('title', link_title_text);
				nwl.className = 'new_window_link';

				// append new elements
				nwl.appendChild(nwl_image);
				l[i].parentNode.insertBefore(space, l[i].nextSibling);
				l[i].parentNode.insertBefore(nwl, l[i].nextSibling.nextSibling);
			}
			
		}
	}
	onload = new_window_link;
// ]]>