var curItem = -1;
var itemCount = 4;
var title = ['Folk at The Pump House'
,'Top stand up comedy comes to the Pump House'
,'Keep traditional dance & music alive'
,'Folk at The Pump House'
];
var link = ['http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=pump_house_folk'
,'http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=giggle_inn_comedy'
,'http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=clog_morris'
,'http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=pump_house_folk'
];
var description = ['The NEW Spring SEASON !! Worth seeing on 24th February is Just \'Sposing. Then we have one of our popular Singarounds on' + 
' 3rd March followed by the Fabulous KIlcawley Family on 9th March 2012'
,'The Giggle Inn Comedy Club brings top comedy to the Pump House every month. Don\'t miss the next show on 4th March featu' + 
'ring Carey Marx, Michael Legge, and Dave Johns.'
,'For 30 years now Pump House Clog Morris has travelled far & wide to keep the traditions of Morris Dancing alive. Our pra' + 
'ctise sessions on a Monday evening resume on January 2nd in the Upper rehearsal room at the Pump House. We will teach yo' + 
'u the dances and you’ll soon be able to show off your new skills and keep fit at the same time. '
,'Hosted by the talented singers, Warp & Weft, alongside folk aficionado Pete Nutkins the Club has continued to attract so' + 
'me great musicians and singers. For more details check out www.folkatthepumphouse.webs.com or www.youtube.com/watfordfol' + 
'k '
];
var expiryDates = [''
,''
,''
,''
];

function changeContent() {
	var moveToNextValidItem = 1;
	var now = new Date();
	var counter = 0;
	while (moveToNextValidItem) {
		curItem = curItem + 1;
		counter = counter + 1;
		if (curItem == itemCount) {
			curItem = 0;
		}
		if (expiryDates[curItem] == '' || counter > itemCount) {
			moveToNextValidItem = 0;
		}
		else {
			if (Date.parse(expiryDates[curItem]) > now.getTime()) {
				moveToNextValidItem = 0;
			}
		}
	}

	var showTitle = "<p class=\"PHTickerHead\">" 
			+ title[curItem] + "</p><p class=\"PHTickerDesc\">" + description[curItem] + " .&nbsp;.&nbsp;.&nbsp;<b><i>more</i></b></p>";

	if (link[curItem] != '') {
		showTitle = "<a href=\"" + link[curItem] + "\">" + showTitle + "</a>";
	}
	document.getElementById("PHTicker").innerHTML = showTitle;
	var timeToWait = 9000 / 160 * description[curItem].length;
	if (timeToWait < 6000) {timeToWait = 6000;}
	if (timeToWait > 12000) {timeToWait = 12000;}
	window.setTimeout('changeContent()', timeToWait);
}	

