// $Id$ //
// redirect upon success or error

function redirection(url, msg)
{
   var TARG_ID = "redirect";
   var DEF_MSG = "Redirecting...";

   if( ! msg )
   {
      msg = DEF_MSG;
   }

   if( ! url )
   {
      throw new Error('You didn\'t include the "url" parameter');
   }


   var e = document.getElementById(TARG_ID);

   if( ! e )
   {
      throw new Error('"redirect" element id not found');
   }

   var cTicks = parseInt(e.innerHTML);

   var timer = setInterval(function()
   {
      if( cTicks )
      {
         e.innerHTML = --cTicks;
      }
      else
      {
         clearInterval(timer);
         document.body.innerHTML = msg;
         location = url;	  
      }

   }, 1000);
}

// nonintrusive popup new window

function doPopups() {
  if (!document.getElementsByTagName) return true;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("external")) {
      links[i].onclick=function() {
      // Next two lines should be on one line
        window.open(this.href, "","");
        return false;
      }
    }
  }
}
window.onload=doPopups;