<!--
// Ticker startup
function startTicker() {

	if (itemCount == 0) 
		return false;

	// Define run time values
	currentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {
		theAnchorObject = document.getElementById("tickerAnchor");
		if (theAnchorObject) {
			runTheTicker();
		}
	} else {
		document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
		return true;
	}
}

// Ticker main run loop
function runTheTicker() {

	var myTimeout;
	// Go for the next story data block

	if(theCurrentLength == 0) {
		currentStory++;
		currentStory      = currentStory % itemCount;
		theStorySummary      = summaries[currentStory].replace(/&quot;/g,'"');
		theTargetLink        = links[currentStory];
		theAnchorObject.href = theTargetLink;
		thePrefix 	     = "<span class=\"ticker\">" + leadString + "</span>";
	}

	// Stuff the current ticker text into the anchor
	theAnchorObject.innerHTML = thePrefix +
	theStorySummary.substring(0,theCurrentLength) + whatWidget();

	// Modify the length for the substring and define the timer
	if (theCurrentLength != theStorySummary.length) {
		theCurrentLength++;
		myTimeout = characterTimeout;
	} else {
		theCurrentLength = 0;
		myTimeout = storyTimeout;
	}

	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}

// Widget generator
function whatWidget() {
	if (theCurrentLength == theStorySummary.length) {
		return widgetNone;
	}
	if ((theCurrentLength % 2) == 1) {
		return widgetOne;
	} else {
		return widgetTwo;
	}
}

var characterTimeout = 50;
var storyTimeout     = 5000;
var widgetOne        = "_";
var widgetTwo        = "-";
var widgetNone       = "";
var leadString       = ""; /* LATEST:&nbsp; */
var summaries = new Array();
var links = new Array();

//summaries[0] = 'LATEST NEWS: New Development - Narev Court. A selection of one bedroom flats with balcony';
//links[0] = 'http://castles.dev/#';
//summaries[1] = 'test ticker text';
//links[1] = 'http://castles.dev/#';
//var itemCount = 2;

//startTicker();

//-->
