document.onclick = function(e){
  var target;
  target = e ? e.target : window.event.srcElement;
  while (target && !/^(a|body)$/i.test(target.nodeName)){
    target = target.parentNode;
  }
  if (target && target.getAttribute('rel')){
    switch(target.rel){
      case 'external':
      var external = window.open(target.href);
      break;
    case 'pop':
      var external = makePopup(target.href, 400, 500, 'scroll');     
      break;
    case 'amazon':
      var external = makePopup(target.href, 500, 500, 'scroll');     
      break;
    case 'mywire':
      var external = makePopup(target.href, 220, 400, 'scroll');     
      break;

    }
    return external.closed;
  }
  else return true;
}

function makePopup(url, width, height, overflow){
/*
  if (width > 640) { width = 640; }
  if (height > 480) { height = 480; }
*/
  if (overflow == '' || !/^(scroll|resize|both)$/.test(overflow)){
    overflow = 'both';
  }
  var win = window.open(url, '',
      'width=' + width + ',height=' + height
      + ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ? 'yes' : 'no')
      + ',resizable=' + (/^(resize|both)$/.test(overflow) ? 'yes' : 'no')
      + ',status=no,toolbar=no,menubar=no,location=no'
  );
  return win;
}


function confirmSubmit(msg){
    var confirmed = confirm(msg);
    if (!confirmed && window.event)
        window.event.returnValue = false;
    return confirmed;
}


