// from http://snippets.dzone.com/tag/onload
// better than loading all of jquery or prototype just to do this
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

/* this site is XHTML Strict, which doesn't support the 'target' attribute.
   however, since HTML5 will likely allow it, we use that to accomplish the new window functionality */
function externalLinks() {
	if (!document.getElementsByTagName)
		return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		var rel = anchor.getAttribute("rel");

		if (rel && rel.match("new-window") && anchor.getAttribute("href"))
			{
				anchor.target = "_blank";
			}
	}
}

addLoadEvent(externalLinks);
