function changeEmbeddedImage(activeNode, newSrc) {
  if (! activeNode || ! activeNode.childNodes) {
    return;
  }
  
  var childNodes = activeNode.childNodes;
 
  childNodes[1].src = newSrc;
}

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";
    } 
	
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {
		anchor.href="javascript:popup('" + anchor.href + "');"; 
	}
  }
}

function popup(location) {
	window.open(location, 'Window', 'dependent=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=480');	
}

var Try = {
  these: function() {
    var returnValue;

    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }

    return returnValue;
  }
}

// window.onload = externalLinks;
var rules = {
	'body' : function(el) {
		Try.these(
			externalLinks()
		);
  	}
};

Behaviour.register(rules);
