// GENERAL-PURPOSE FUNCTION TO LOAD MULTIPLE FUNCTIONS
function addLoadEvent(func) { 
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// CREATE TITLE TAGS ON THE FLY - WRITTEN BY RJB 8/3/06
function createTitleTags() { 
	if (!document.getElementsByTagName) return false;
	var images = document.getElementsByTagName("IMG");
	for (var i=0; i < images.length; i++) {
		var image = images[i]
		if (!image.getAttribute("TITLE")) { // Check to see whether title tag already exists.
			if (image.getAttribute("ALT")) { // Check to see whether alt tag exists and it's not empty.
				var alttext = image.getAttribute("ALT");
				if (alttext !== " ") image.setAttribute("title",alttext);
			}
		}
	}
}

// OPEN LINKS IN A NEW WINDOW (TO CONFORM TO XHTML 1.0 STRICT, WHERE WE CANNOT USE "_BLANK" IN THE LINK - 12/3/10
// FROM SITEPOINT.COM
// TO MAKE IT WORK, INCLUDE REL="EXTERNAL" IN THE LINK.
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.target = "_blank";   
 }   
}   


// LOAD THE FUNCTIONS
addLoadEvent(createTitleTags);
addLoadEvent(externalLinks);
