// JavaScript Document

//============================================================================================
// lib_externalLinks.js                                                                     ==
//============================================================================================
//                                                                                          ==
// This library contains a function to create valid markup for external links.				==
//                                                                                          ==
// DEPENDENCIES                                                                             ==
// there are no dependencies                                                                ==
//============================================================================================


//============================================================================================
// function manageEvent																		==
//============================================================================================
// DESCRIPTION																				==
// This function adds a function to an event without ruining the event for other functions	==
//																							==
// PARAMETERS																				==
// eventObj: the object having the event													==
// event: the event to listen for															==
// eventHandler: the function being attached to the event									==
//============================================================================================

function manageEvent(eventObj, event, eventHandler) {
	if (eventObj.addEventListener) {
		eventObj.addEventListener(event, eventHandler,false);
	} else if (eventObj.attachEvent) {
		event = "on" + event;
		eventObj.attachEvent(event, eventHandler);
	}
}
// manageEvent
//============================================================================================


//============================================================================================
// function convertExternalLinks															==
//============================================================================================
// DESCRIPTION																				==
// This function converts all links with a rel of "external" to a link that pops in a new	==
// window.																					==
//																							==
// PARAMETERS																				==
// there are no parameters																	==
//============================================================================================

function convertExternalLinks () {
	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.target = "_blank" ;
		}
	}
}
// convertExternalLinks
//============================================================================================

manageEvent ( window , "load" , convertExternalLinks ) ;