newsstring=new Array("Saturday 31st July 2010 at 9.00pm|| <The Good Intent> ||John St, Rochester,Kent","Sunday 1st August 2010 at 1.00pm|| <The Robin Hood> ||Sandhurst Rd, Tunbridge Wells","Saturday 7th August 2010 at 1.00pm|| <Fordham Music Festival> ||Cambridgeshire.||On stage at 1 pm. 45 min slot.","Sunday 8th August 2010 at 12.30pm|| <Wickham Festival> ||Hampshire.||On stage 12.30 45 min slot.","Friday 13th August 2010 at 9.00pm|| <The Jolly Sailor Inn> ||Princes Square, Looe","Saturday 14th August 2010 at 9.00pm|| <The Rising Sun> ||Kingsand Torpoint","Friday 20th August 2010 at 9.00pm|| <The Royal George> ||West Coker, Somerst.||Rare ( these days ) appearance of the duo Palmer featuring my darling daughter Mrs Holly Vivian and myself, one not to be missed I reckon!","Friday 27th August 2010 at 9.00pm|| <The Copley Arms> ||Hessenford, Torpoint.","Friday 3rd September 2010 at 9.00pm|| <The Crumplehorn> ||Polperro.","Saturday 4th September 2010 at 9.00pm|| <The Elliot Arms.> ||1, Fore St, St Germans. Polbathic","Friday 17th September 2010 at 9.00pm|| <The Jolly Sailor Inn> ||Princes Square, Looe")
//max lines on display
lineheight=9
//max characters for width of display (must never exceed width! - always use courier type font with equal character spacing)
charwidth=50
//ticker cursor
//tickertypeon="<font color='#FFFF00'><strong>&gt;</strong></font>"
tickertypeon="<span style='background:800000'>&nbsp;</span>"
tickertypeoff="&nbsp;"
//cursor flash speed
tickertypeflash=20
//ticker speed
tickerspeed=2
//pause between articles
tickerpause=150
//the more link name (not longer than char width (above) - 5
themorelink="<view Gig List for full details>"
//IN-HOUSE VARIABLES
//amount of news articles
newsarticleamount=newsstring.length
//get first news article ready
newsarticlecount=-1
currentarticle=""
getnextarticle()
//the news article so far
newspartial=""
//the character position of the next letter within the original string
newschar=0
//ticker type flash count
tickertypecount=0
//ticker type toggle
tickertypetoggle=0
//ticker type character display
tickertypedisplay=tickertypeon
//tickerspeed count
tickerspeedcount=0
//tickerpause count
tickerpausecount=0
//special character variables
addhtmlbefore=""
temphtmlafter=""
addhtmlafter=""
aftercursor=""
//characterwidthcount
charwidthcount=0
//where we break the next line
charwidthbreak=0
//line number on display count
lineheightcount=1
//get first char width count
getnextcharwidth()
//TICKER FUNCTION
function newsticker() {
	//flash cursor
	tickertypecount++
	if (tickertypecount>tickertypeflash) {
		tickertypecount=0
		if (tickertypetoggle==0) {
			tickertypetoggle=1
			tickertypedisplay=tickertypeoff
		} else {
			tickertypetoggle=0
			tickertypedisplay=tickertypeon
		}
	}
	//is it time to display the next character of the news article?
	if (tickerspeedcount>tickerspeed) {
		tickerspeedcount=0
		//new line invoked
		while (currentarticle.charCodeAt(newschar)==124) {
			addhtmlbefore+="<br>";lineheightinc()
			charwidthcount=0
			newschar++
			getnextcharwidth()
		}
		//if less than sign
		if (currentarticle.charCodeAt(newschar)==60) {
			addhtmlbefore+="<span class='newsbold'>"
			temphtmlafter+="</span>"
			newschar++
			charwidthcount++
		} else if (currentarticle.charCodeAt(newschar)==62) {
		//if greater than sign
			addhtmlafter+="</span>"
			newschar++
			charwidthcount++
		}
		//new line invoked
		while (currentarticle.charCodeAt(newschar)==124) {
			addhtmlbefore+="<br>";lineheightinc()
			charwidthcount=0
			newschar++
			getnextcharwidth()
		}
		//has line come to end of charater width setting
		if (charwidthcount>=charwidthbreak & newschar<newscharmax) {
			charwidthcount=0
			addhtmlbefore+="<br>";lineheightinc()
			getnextcharwidth()
		}
		//finished displaying news but have'nt reached total lines yet
		if (newschar>=newscharmax & lineheightcount<lineheight) {
			lineheightcount++
			aftercursor+="<br>&nbsp;";
		}
		//display article with cursor
		chartoaddhere=currentarticle.substr(newschar,1)
		newspartial=newspartial+addhtmlbefore+chartoaddhere+addhtmlafter
		result.innerHTML=newspartial+temphtmlafter+tickertypedisplay+aftercursor
		//increase char width count
		charwidthcount++
		//reset special character variables
		addhtmlbefore=""
		temphtmlafter=""
		addhtmlafter=""
		//have we reached the end of this particular article
		if (newschar<newscharmax) {
			newschar++
		//wait for pause before moving onto next article
		} else {
			tickerpausecount++
			//next article
			if (tickerpausecount>tickerpause) {
				tickerpausecount=0
				newspartial=""
				newschar=0
				charwidthcount=0
				aftercursor=""
				lineheightcount=1
				//get next article
				getnextarticle();
				//get first line break point
				getnextcharwidth();
			}
		}
	}
	tickerspeedcount++
	setTimeout("newsticker()", 1)
}
//work out where to break the next line
function getnextcharwidth() {
	charwidthbreak=charwidth
	thisloopend=newschar+charwidth
	if (thisloopend<newscharmax) {
		for (i=newschar;i<thisloopend;i++) {
			if (currentarticle.substr(i,1)=="|") {
				thisloopend=i //stop loop because we found line break
				charwidthbreak=charwidth
			}
			if (currentarticle.substr(i,1)==" ") {
				charwidthbreak=i-newschar
			}
		}
	}
}
//line height increase - stop news if hit bottom
function lineheightinc() {
	lineheightcount++
	if (lineheightcount>=lineheight) {
		if (addhtmlbefore.length>4){
			addhtmlbefore=addhtmlbefore.substr(0,addhtmlbefore.length-4)
			lineheightcount--
		}
		//change text to create link thus fooling ticker
		currentarticle=currentarticle.substr(newschar,charwidth-6-(themorelink.length))+"... "+themorelink
		newscharmax=currentarticle.length
		newschar=0
		charwidthcount=0
		charwidthbreak=charwidth
	}
}
function getnextarticle () {
	newsarticlecount++
	//choose first article once more
	if (newsarticlecount>=newsarticleamount) {
		newsarticlecount=0
	}
	//get length of this article
	currentarticle=newsstring[newsarticlecount]
	newscharmax=currentarticle.length
}