// ================================================ //
// Typing Banner v2.0 by Elton Kong (2000/06/10).   //
// (c)1998-2000 Elton Kong. All Rights Reserved.    //
// You can freely use or modify the script, as long //
// as this message is kept intact in the source.    //
//                                                  //
// Contact me by:                                   //
// elton@graffiti.net                               //
// http://home.netvigator.com/~freya/               //
// ================================================ //

// banner messages
// banner URLs
// interval between messages
// interval between characters
var TB_msg, TB_url, TB_msg_delay, TB_chr_delay

// index of message pointer
// index of character pointer
var TB_msg_index=-1, TB_chr_index;

// banner area size
var TB_banner_width, TB_banner_height;

// popup window location & dimension
var TB_popup_left, TB_popup_top, TB_popup_width, TB_popup_height

// random banner mode?
var TB_random_mode;

function TB_runBanner() {
  document.TB_f.t.value+=TB_msg[TB_msg_index].charAt(TB_chr_index);

  if (TB_chr_index<(TB_msg[TB_msg_index].length-1)) {
    TB_chr_index++;
    setTimeout("TB_runBanner()", TB_chr_delay);
  } else {
    setTimeout("TB_startBanner()", TB_msg_delay);
  }
}

function TB_startBanner() {
  document.TB_f.t.value="";
  if (TB_random_mode) {
    TB_msg_index=Math.floor(Math.random()*TB_msg.length);
  } else {
    TB_msg_index=(TB_msg_index+1)%TB_msg.length;
  }
  TB_chr_index=0;
  TB_runBanner();
}

function TB_popupURL() {
  var param;

  if (TB_url[TB_msg_index]!="") {
    param="screenX="+TB_popup_left+","+
          "screenY="+TB_popup_top+","+
          "innerWidth="+TB_popup_width+","+
          "innerHeight="+TB_popup_height+","+
          "menubar,toolbar,location,status,scrollbars=no,resizable";

    window.open(TB_url[TB_msg_index], "_top", param);
  }
}

function TB_writeBannerArea() {
  var str="<form name=\"TB_f\" onSubmit=\"return(false);\">"+
          "<textarea class=banner name=\"t\" "+
          "rows="+TB_banner_height+" "+
          "cols="+TB_banner_width+" "+
          "wrap onFocus=\"this.blur();TB_popupURL();\"></textarea>"+
          "</form>";

  document.write(str);
}

function TB_initBanner() {
  // =================== //
  // begin configuration //
  // =================== //

  // banner messages & URLs

  
  TB_msg   =new Array();
  TB_msg[0]="Click here for new Health and Safety course information...";
  TB_msg[1]="Click here to register for training sessions online...";
  

  TB_url   =new Array();
  TB_url[0]="http://www.jhryder.com/eng/health_safety/index.shtml";
  TB_url[1]="http://www.jhryder.com/eng/training/index.shtml";

 
  // interval between messages & characters
  TB_msg_delay=3000; // milli-seconds
  TB_chr_delay=100;  // milli-seconds

  // banner area size
  TB_banner_width =60; // characters
  TB_banner_height=1;  // rows

  // popup window location & dimension
  TB_popup_left  =50;  // pixels
  TB_popup_top   =50;  // pixels
  TB_popup_width =480; // pixels
  TB_popup_height=320; // pixels

  // random banner mode?
  TB_random_mode=false;

  // ================= //
  // end configuration //
  // ================= //

  TB_writeBannerArea();
  TB_startBanner();
}
