//add Events to window and anchors
function makeEventHandler(o,e,fn)
  {
  if(o.addEventListener)
    o.addEventListener(e, fn, true);
  else if(o.attachEvent)
    o.attachEvent('on'+e, fn);
  }


//initialise
function initAnchors()
  {
  
  if(!document.getElementsByTagName)return;   //let it be, won't work anyway

  aArr = document.getElementsByTagName('a');

  for(i=0;i<aArr.length;i++)
    if(aArr[i].getAttribute('href')&& aArr[i].getAttribute('rel') == 'extern')
      {
      //target_blank
      aArr[i].target = '_blank';
      //count makeEventHandler(aArr[i],'click',countClick)
      }
  }

//now it counts
/*
function countClick(evt)
  {
  evt = (evt) ? evt : ((window.event) ? window.event : '');
  elem = (evt.target) ? evt.target : evt.srcElement;
  ctImg = new Image();
  now = new Date();
  nowStr=now.getFullYear()+'-'+now.getMonth()+'-'+now.getDate();
  src = "link_ext.php?link="+encodeURIComponent(elem.href)+"&page="+encodeURIComponent(document.location)+"&date="+nowStr;
  ctImg.src=src;
  //document.location.href=src;
  return true;
  }
*/

makeEventHandler(window,'load',initAnchors);
