newsstring=new Array(" <GCC Quiz Night> ||We are holding another quiz night to raise much needed funds!     Please place your ticket order for the <GCC QUIZ NIGHT.> It is taking place on <Saturday 17th March> from 7.30 at St Thomas's School.      No need to be a genius just come and have a fun evening.    Tickets will be <£10.00> per head with a <MAXIMUM> of 8 people in a team.  A Team can added to on the night, so don't worry if your have not got a full complement.    A light supper will be provided and we will also have a licensed bar on the night.    Please do your utmost and support this event.     For tickets and enquires please contact <Terry Woolgar 01892 864821 or Geoff Smith 01892 864588>"," <WINTER NETS 2012> ||   I can now confirm that winter nets will start at <Holmewood House School on Tuesday 17th January> and will continue for 12 weeks.     We will have the whole hall for an hour and as usual the <session will start at 8pm>. The sessions will cost £3 a week or a one off payment of £25 (cheques made payable to Groombridge Cricket Club).    Please courage any potential new members to come along.     If you have any questions let me know    Jamie")
//the above variables of news articles are dynamically added by a php script automatically twice daily.
//This script is COPYRIGHT 2004 - PAUL W H MIDCALF - WEB SITE SORCERY.CO.UK
//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=41
//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="<visit the News Page for more>"
//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
}
