/**
 * Transforms alls link in the current page that DO NOT contain the given href
 * so that they pop up in a new window
 * Also now looks for class name of external, in which case _blank will be applied as well.
 *
 * @param string href
 */
function links_in_new_window() {
	
	var href = window.location.hostname;
	
	// get all the links in the document
	var links = document.getElementsByTagName('a');

	// make the regex
	re = new RegExp('\\b' + href + '\\b', "i");
	
	// iterate through the contents of the links array
	for (x = 0; x < links.length; x++) {
		var link = links[x];	
		
		// if the class_name matches, make the link open in a new window
		if (link.href.search(re) == -1) {
			link.target = "_blank";
		} else if (Element.hasClassName(link,'external') == true)	{
			link.target = "_blank";
		}
	}
}

Event.observe(window, 'load', links_in_new_window, false);