function addEvent( obj, type, fn ) {
	if ( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else {
		obj.addEventListener( type, fn, false );
	}
}

function $(el) {
	return document.getElementById(el);
}

function $E(data) {
    var el;
    if ('string'==typeof data) {
        el=document.createTextNode(data);
    } else {
        //create the element
        el=document.createElement(data.tag);
        delete(data.tag);

        //append the children
        if ('undefined'!=typeof data.children) {
            if ('string'==typeof data.children ||
                'undefined'==typeof data.children.length
            ) {
                //strings and single elements
                el.appendChild($E(data.children));
            } else {
                //arrays of elements
                for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) {
                    el.appendChild($E(child));
                }
            }
            delete(data.children);
        }

        //any other data is attributes
        for (attr in data) {
            el[attr]=data[attr];
        }
    }

    return el;
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && (anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "nofollow") ) {
			anchor.target = "_blank";
		} else if( anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {
			anchor.onclick = function() { window.open(this.href,'_blank',"height=500,width=600,status=no,toolbar=no,menubar=yes,scrollbars=yes,resizable=yes"); return false; };
		}
	}
}
addEvent(window,'load',externalLinks);