//Simple TypeTicker Script (for DOM compliant browsers - ie not Netscape)
//(c) 2004 RJ Bigg, all rights reserved
//version 1.0.1 July 2004
//check for old browsers
var ie = document.layers ? false : true;
//set up basic variables
var dtext="";  //partial text to display
var ttext="";  //current item's full text
var curline=-1;  //current position in items array
var num=-5;  //current text position within current item, negative value for initial delay
var items=new Array();
var iimgs=new Array();
//customise messages and associated images here
items[0]="Welcome to St George's";
iimgs[0]="";
items[1]="Please join us at any of our Sunday or Weekday Services";
iimgs[1]="images/xbull.gif";
items[2]="Parish Vision Day 10th Nov - please give us your feedback";
iimgs[2]="images/date.gif";
items[3]="Don't miss the October Revolution! - 26/27 Oct 2007";
iimgs[3]="images/play.gif";
items[4]="Test Line 5";
iimgs[4]="";
items[5]="Test Line 6";
iimgs[5]="";
//set number of these messages to display, normally the number of elements in the array
var displaylines=2;
if (displaylines > items.length) displaylines=items.length;
//display functions
function typeLine(n) {
  //this 'types' the line of text with an optional starting image
  tlen=ttext.length;
  if (tlen>0) {
    dtext="<b>" + ttext.substring(0,n); + "</b>"
    if (iimgs[curline]!="") dtext="<img src='"+iimgs[curline]+"' alt=''>"+dtext;
    if (n<tlen) {
      if (n%2==0) {
      dtext=dtext + "&#x25AA;";
      } else {
      dtext=dtext + "&#x25AB;";
      }
    }
  } else {
    dtext="";
  }
}
function changeLine() {
  //this cycles through the items array to show the different messages in turn
  if (curline>=displaylines-1) curline=-1;
  if (displaylines<1) {
    ttext="";
  } else {
    ttext=items[++curline];
  }
}
function scrollItems(num) {
  //this is the main control & dynamic HTML display function called by the timer
  clearInterval(newsTick);
  if(ie) {
    if (document.all) {
      //IE browsers with support for non standard syntax
      enews.innerHTML=dtext;
    } else {
      //non-IE browsers
      document.getElementById("enews").innerHTML=dtext;
    }
  if (num>ttext.length+25) {
   //number added to ttext.length is a delay whilst the whole message stays visible
   //set num to a negative value to create a delay before starting to type next item
   num=-5;
   changeLine();
  }
  num++;
  //setInterval numeric argument controls speed of typing (delay interval in ms)
  newsTick=setInterval('scrollItems('+num+')',140);
  typeLine(num);
  }
}
// main page content code (use static text for old Netscape browsers)
changeLine();
if(ie) {
  typeLine(num);
  if (displaylines>0) var newsTick = setInterval('scrollItems('+num+')',180);
  document.write('<span id="enews" class="ticker"> </span>');
} else {
  typeLine(999);
  document.write('<span id="enews" class="ticker">'+dtext+'</span>');
}

