function elPopupOn(){elDoPopups('_blank');}
function elPopupOff(){elDoPopups('_self');}

function elDoPopups(target) {
  
  // Set up your domains here
  // Must be escaped for insertion into regex
  var domains = new Array(
    "scottishrefugeecouncil\\.org\\.uk",
    "test\\.scottishrefugeecouncil\\.org\\.uk",
    "www\\.scottishrefugeecouncil\\.org\\.uk",
    "src\\.bycog\\.co\\.uk"
  );
  
  var regex = "^(https?|ftp):\/\/(?!(";
  for (var x = 0; x < domains.length; x++) {
    if (x > 0) regex += "|";
    regex += domains[x];
  }
  regex += "))";
  var r = new RegExp(regex,"i");
  e=new Array();
  e.push(document.body);
  while(e.length>0) {
    t=e.shift();
    if(t.nodeName.toLowerCase()=='a'&&(t.href.match(r)!=null))t.setAttribute('target',target);
    if(t.hasChildNodes())for(x=0,l=t.childNodes.length;x<l;x++)e.push(t.childNodes[x]);
}}
