function targetLinks() {
	var strDomain = ((location.href).split('/'))[2];

// this bit does links
	for(var x=0; x < document.links.length; x++) {
		if ((document.links[x].href.indexOf(strDomain) == -1) && (document.links[x].href.toLowerCase().indexOf('javascript:') == -1) && (document.links[x].href.toLowerCase().indexOf('mailto:') == -1) && (document.links[x].innerHTML.toLowerCase().indexOf('<img') == -1)) {
			document.links[x].target = '_blank';
		}
	}

// this bit does forms, bit rough and ready because
// we only check if the target begins with "http://"
	for(var x=0; x < document.forms.length; x++) {
		if ((document.forms[x].action.indexOf("http://") != -1)) {
			document.forms[x].target = '_blank';
		}
	}
}

window.onload = targetLinks;
