/*
   Copyright M. Vesey April 2006
   Information here should be duplicated in stoppress.htm
*/


var characterDelay = 50;
var storyDelay = 4000; 
var msg = "";

var nextStory  = -1; 
var currentLength = 0; 

var storyIndex = 0;
var storyCount = 1;
var maxStories = 1;

var storyDate = new Array(storyCount); 
var storyTitle = new Array(storyCount); 
var storyLink = new Array(storyCount); 

storyDate[storyIndex] = "24th May 2010";
storyTitle[storyIndex] = "Closure of the Low Carbon Buildings Programme";
storyLink[storyIndex++] = "http://www.lowcarbonbuildings.org.uk/Grants-for-your-home/Closure-of-the-Low-Carbon-Buildings-Programme";

storyDate[storyIndex] = "";
storyTitle[storyIndex] = "Open to the public from Wednesday - Saturday, 11am-3pm";
storyLink[storyIndex++] = "";

storyDate[storyIndex] = "";
storyTitle[storyIndex] = "... or contact us for group visits, guided tours and consultancy.";
storyLink[storyIndex++] = "http://www.syec.co.uk/contact.php";

function showTicker()
{
    var whichTimeout;

    if(currentLength == 0) {
      nextStory++;
      msg = "";
      if(nextStory >= maxStories) {
        nextStory = 0;
      }
      if(storyDate[nextStory] != "") {
        msg += storyDate[nextStory]+ ' : ';
      }
      if(storyLink[nextStory] != "") {
        msg += '<a href=\"' + storyLink[nextStory] + '\">';
      }

      msg += '<span id=\"stopPressStory\">&nbsp;<\/span>';

      if(storyLink[nextStory] != "") {
        msg += '<\/a>';
      }
	if(document.getElementById&&document.getElementById("stopPressText")) {
        document.getElementById("stopPressText").innerHTML = msg;
	}
    }
    if(storyTitle[nextStory] != "") {
      showMsg('stopPressStory',storyTitle[nextStory].substring(0,currentLength+1));
    }
    if(currentLength <= storyTitle[nextStory].length) {
        currentLength++; 
        whichTimeout = characterDelay;
    }
    else {
        currentLength = 0; 
        whichTimeout = storyDelay;
    }
    setTimeout("showTicker()", whichTimeout);
}
function writeStopPressDiv() {
  if(document.getElementById) {
    document.write('<div id=\"stopPress\"><div id=\"stopPressHeader\">Stop Press<\/div><div id=\"stopPressText\"><\/div><\/div>');
  }
  else {
    document.write('<a href="stoppress.php">Stop Press<\/a>');
  }
}

function initialise(){
  if(document.getElementById) {
    showTicker();
  }
  initForm();
}
window.onload=initialise;
