var curItem = -1;
var itemCount = 3;
var title = ['Jazz Club Thursday 7th January Cancelled'
,'Watford Filmhouse introduces film to the Pump House'
,'Folk at the Pump House'
];
var link = ['http://ph.acutest.com/cgi-bin/pumphouse/site.pl?type=rss&fn=feed_news&x=news'
,'http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=watford_filmhouse'
,'http://ph.acutest.com/cgi-bin/pumphouse/site.pl?fn=pump_house_folk&x=news'
];
var description = ['Jazz Club Thursday 7th January has been cancelled due to weather conditions'
,'Born out of a desire to see films that are not available locally, WATFORD FILMHOUSE aims to show a diverse range of film' + 
's on a monthly basis. The first film is Looking For Eric (15) on 5th February 2010.'
,'Folk is back at the Pump House every Friday with some of the leading acts in the country. Check out more on the site.'
];
var expiryDates = ['Fri, 08 Jan 2010 00:00:00 +0000'
,'Tue, 13 Jul 2010 00:00:00 +0000'
,'Tue, 13 Jul 2010 00:00:00 +0000'
];

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);
}	
