var lastSRC = '';

function swapImg(obj, type) {
  if ( type == 2 ) {
    obj.src = lastSRC;
  }
  else
  {
    lastSRC = obj.src;
    obj.src = obj.src.replace( "off", "on" );
  }
}

function bookmark() {
  try {
    window.external.AddFavorite(document.location,document.title);
  } catch (err) {
    try {
      window.sidebar.addPanel(document.title, document.location,"");
    } catch(err) {
      alert("Press Ctrl-D to bookmark this page");
    }
  }
}

function textAreasInit() {
   var fields = document.getElementsByTagName("textarea");
   for(var i=0; i<fields.length; i++) {
       if(fields[i].getAttribute('maxlength') != undefined) {
           fields[i].onkeyup = function() {
               val = this.value.replace(/(\r\n|\n\r|\n|\r)/gi,"\r\n");
               var maxLength = parseInt(this.getAttribute('maxlength'));
               x = val.length;
               if(x > maxLength) {
                   this.value = val.substring(0, maxLength).replace(/\r*$/g,"");
               }
           }
       }
   }
}