/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jeroen Haan | http://www.haan.net */
/* -----------------------------------------------
   Link Enhancer - v.1.1
   (c) 2007 www.haan.net
   contact: jeroen@haan.net
   You may use this script but please leave the credits on top intact.
   Please inform us of any improvements made.
   When useful we will add your credits.
  ------------------------------------------------ */
  
// Give the outbound links a blank target and their own style
// and optional the inbound too or vise versa
// It will leave the mailto alone and skip anchor tags without the href attribute

function enhanceLinks() {
 	var links = document.getElementsByTagName("a");
	 var thisDomain = document.domain.split('www.');
 	var thisDomain = (thisDomain[1]) ? thisDomain[1] : document.domain ;
	 for (var i = 0; i < links.length; i++) {
  		if(links[i].href.indexOf(thisDomain) == -1 && links[i].href != '') {
			   links[i].target = '_blank';
   			links[i].className = 'link_ext';
 		 }
		// or else do this too if you like
		// else 
		// {
		//	links[i].target = '_self';
		//	links[i].className = 'link_int';
		// }		
	}
}

// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  enhanceLinks();
});

