/*
 * xStatusBar.js, 1.4, 2005-05-16
 *
 * Copyright (c) 2002-2005 Roumen Petrov.
 *
 * Roumen Petrov grants you a royalty free license to use, modify or
 * distribute this software provided that this copyright notice appears
 * on all copies.  This software is provided "AS IS," without a
 * warranty of any kind.
 *
 * Notes:
 * - Do not put script in HTML head section - NS4 and frames problem
 * - Works on:
 *   - Netscape 4.7x
 *   - Gecko 0.9.x/1.x (Mozilla, Firefox, Netscape 6x/7x, Galeon)
 *   - IE 5.x/6.x
 *   - Opera 5.x/6.x/7.x/8.x
 *   - Konqueror 2.2.x/3.x
 */

var xstatusbar = null;
xStatusBar.prototype.index = 0;
xStatusBar.prototype.tmout = null;
xStatusBar.prototype.sleeptime = 2000;
xStatusBar.prototype.updatetime = 140;


function xStatusBar(_msg) {
  this.msg    = _msg;
  this.length = _msg.length;
  if (xstatusbar != null) {
    xstatusbar.stop();
  }
  xstatusbar = this;
  this.start();
}

xStatusBar.prototype.next = function () {
  if (this.index > 0) {
    window.defaultStatus = this.msg.substring(0, this.index);
  } else {
    window.defaultStatus = " ";
  }

  if (this.index >= this.length) {
    this.index = 0;
    this.tmout = window.setTimeout('xstatusbar.next();', this.sleeptime);
  } else {
    this.index++;
    this.tmout = window.setTimeout('xstatusbar.next();', this.updatetime);
  }
}


var myalert = 0;
xStatusBar.prototype.stop = function () {
  if (this.tmout != null) {
    window.clearTimeout(this.tmout);
    this.tmout = null;
  }
  if (myalert == 1) alert('xStatusBar.stop() :' + this.msg);
  if (myalert > 0) myalert--;
}


xStatusBar.prototype.start = function () {
  this.index = 0;
  this.next();
}

