/**
 * DECAF Addon
 * @author su[at]decaf[dot]de Stefan Ullrich
 * @author <a href="http://www.decaf.de">www.decaf.de</a>
 * @package redaxo3_3
 * @version $Id: decaf_externalwindow.js,v 1.2 2007/06/29 22:39:44 su Exp $
 */

if (typeof addLoadEvent != 'function') {
   function addLoadEvent(func) {
     var oldonload = window.onload;
     if (typeof window.onload != 'function') {
       window.onload = func;
     } else {
       window.onload = function() {
         if (oldonload) {
           oldonload();
         }
         func();
       }
     }
   }
}

function d_ew() {
	if (document.getElementsByTagName) {
   	var a = document.getElementsByTagName("a");
   
   	for (var i=0; i<a.length; i++){
         try {
      		if (a[i].getAttribute("href")
      		&&  a[i].getAttribute("rel") 
      		&& (a[i].getAttribute("rel").match(/^external$/)
      		 || a[i].getAttribute("rel").match(/^external (.)*$/)
      		 || a[i].getAttribute("rel").match(/^(.)* external$/)
      		 || a[i].getAttribute("rel").match(/^(.)* external (.)*$/))){
      			a[i].onclick = function () {window.open(this.getAttribute("href"), "_blank"); return false;}
      		}
         }
         catch (e) { }
   	}
   }
}

addLoadEvent(d_ew);