function getElementsByClassName(oEl, sTag, sClass)
{	var aEl = (sTag == "*" && oEl.all) ? oEl.all : oEl.getElementsByTagName(sTag);
  var aRet = new Array();
  sClass = sClass.replace(/\-/g, "\\-");
  var re = new RegExp("(^|\\s)" + sClass + "(\\s|$)");
  var oTemp;
  for(var i=0; i < aEl.length; i++)
  { oTemp = aEl[i];      
    if(re.test(oTemp.className)) { aRet.push(oTemp); }
  }
  return (aRet);
}

function convertExts()
{ var array = getElementsByClassName(document, 'a' ,'external');
  for (var ii = 0, link; link = array[ii]; ++ii)
  { link.onclick = function() { return ext(this.href); }
  }
}

function convertLinks()
{ var array = document.getElementsByTagName('a');
  for (var ii = 0, link; link = array[ii]; ++ii)
  { if (!link.getAttribute('rel')) continue;
    var sRel = link.getAttribute('rel');
    if      (sRel.indexOf('ext') != -1) link.onclick = function() { return ext(this.href); }
    else if (sRel.indexOf('pop') != -1) link.onclick = function() { return pop(this.href); }
  }
}

var oe = null;
function ext(url)
{ if (typeof oe == 'object' && oe == '[object inaccessible]') //opera
  { oe = window.open(url,'ext','location=1,toolbar=1');
    return false; //opera focuses
  }
  if (oe && !oe.closed && oe.location) oe.location.href = url;
  else oe = window.open(url,'ext');
  if (!oe.opener) oe.opener = self;  
  if (oe.focus) oe.focus();
  return false;
}

var op = null;
function pop(url)
{ if (op && !op.closed && op.location) op.location.href = url;
  else op = window.open(url,'pop','height=300,width=500,scrollbars=1,resizable=1');
  if (op.focus) op.focus();
  return false;
}

function pushOnload(fn)
{ var oldfn = window.onload;
  if (typeof window.onload != 'function') { window.onload = fn; }
  else                                    { window.onload = function() { oldfn(); fn(); } }
}
