function addLoadEvent(func) {
   var oldonload = window.onload;
   if (typeof func != 'function') {
      //alert('Invalid: ' + func + ' [' + typeof func + ']');
   } else if (typeof window.onload != 'function') {
      window.onload = func;
   } else {
      window.onload = function() {
         if (typeof oldonload == 'function') {
            oldonload();
         }
         func();
      }
   }
} // addLoadEvent

addLoadEvent(function() {
   if (document.getElementsByTagName) {
      var anchors = document.getElementsByTagName('a');
      for (var i = 0; i < anchors.length; i++) {
         var anchor = anchors[i];
         if (anchor.getAttribute('href') &&
             anchor.getAttribute('rel') == 'external') {
            anchor.target = '_blank';
         }
      }

      // for setting "spellcheck" attribute on form inputs
      // (recognized by FF to spell-check text input)
      var inputs = document.getElementsByTagName('input');
      for (var i = 0; i < inputs.length; i++) {
         var classname = inputs[i].getAttribute('class');
         if (classname != null && classname.indexOf('spellcheck') >= 0) {
            inputs[i].spellcheck = 'true';
         }
      }
   }
});
