﻿// Ticker startup
function startTicker()
{
	// Define run time values
	huidigeBoodschap = -1;
	huidigeLengte = 0;
	// Locate base elements
	if (document.getElementById) {	
		    element = document.getElementById("nieuws");
			tikHetNieuws();   	
		 }
	
}
// Ticker main run teller
function tikHetNieuws()
{
	var myTimeout;  
	// Go for the next story data block
	if(huidigeLengte == 0)
	{
		huidigeBoodschap++;
		huidigeBoodschap = huidigeBoodschap % theItemCount;
		Boodschap = boodschappen[huidigeBoodschap].replace(/&quot;/g,'"');		

	}
	// Stuff the current ticker text into the anchor
	element.innerHTML = Boodschap.substring(0,huidigeLengte) + bepaalTeken();
	// Modify the length for the substring and define the timer
	if(huidigeLengte != Boodschap.length)
	{
		huidigeLengte++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		huidigeLengte = 0;
		myTimeout = theStoryTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("tikHetNieuws()", myTimeout);
}
// Widget generator
function bepaalTeken()
{
	if(huidigeLengte == Boodschap.length)
	{
		return geenTeken;
	}

	if((huidigeLengte % 2) == 1)
	{
		return teken1;
	}
	else
	{
		return teken2;
	}
}

var theCharacterTimeout = 50;
	var theStoryTimeout     = 5000;
	var teken1        = "_";
	var teken2        = "-";
	var geenTeken       = "";
	

	var boodschappen = new Array();

	var theItemCount = 4;

	
		boodschappen[0] = "Zaterdag 17 april infoavond KBKC";
		
	
		boodschappen[1] = "Gewestelijke clubshirts aangekomen";
	
	
		boodschappen[2] = "Vrijdag 16 april restart veldcompetitie";
	
	

	

	
	window.onload= startTicker();