/**
 * loops through all links in the current page, and sets their target
 * attribute as follows:
 * 
 * if the "rel" attribute is set to "external", the target is set to "_blank"
 *
 * if the "rel" attribute begins with "external:", the target is set to the
 * remainder of the "rel" attribute following the colon.
 *
 * For example, to target the "myframe" frame, a link should be
 * formatted as:
 *
 * <a href="someurl" rel="external:myframe">my link</a>
 *
 * this is based upon a simpler version at
 * http://www.sitepoint.com/article/1041/3
 */
 
 /**
 * Modificacion: hace externos los links "nofollow"
 * Para hacer links externos sin "nofollow" usar rel="external:_blank"
 */
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")) {
			var rel = anchor.getAttribute("rel");
			if (rel == "nofollow") {
				anchor.target = "_blank";			
			} else if (rel.substring(0,9) == "external:") {
				anchor.target = rel.substring(9, rel.length);
			} 
		}
	}
}
