
// Don't change these variables below  :-)
lineImage = ""
lineText=""
timerID=null
timerRunning=false
spaces=""
charNo=0
charMax=0
charMiddle=0
lineNo=0
lineWait=0
charEndVisible=1
ticker=0				// show blinking cursor at end of typed line
tickRate=1				// set cursor visible every x number or letters

function Line(text, url, frame, type, wait, image) { 
this.text=text
this.url=url
this.frame=frame
this.Display=type
this.wait=wait
this.ximage=image
}

function StringFill(c, n) {
	var s=""
	while (--n >= 0) {
	s+=c
	}
	return s
}

function getNewRandomInteger(oldnumber, max) {
	var n=Math.floor(Math.random() * (max - 1) + 1)
	if (n >= oldnumber) {
	n++
	}
	return n
}

function getRandomInteger(max) {
	var n=Math.floor(Math.random() * max + 1)
	return n
}

function GotoUrl(url, frame) {
	if (frame != '') {
		if (frame == 'self') 
			self.location.href=url
		else 
			if (frame == 'parent') 
				parent.location.href=url
			else 
				if (frame == 'top') 
					top.location.href=url
				else {
					s=eval(top.frames[frame])
					if (s != null) 
						top.eval(frame).location.href=url
					else 
						window.open(url, frame, "toolbar=yes,status=yes,scrollbars=yes")
				}
		}
	else 
		window.location.href=url
}

function Static() {
	document.all.buttonFace.innerHTML=this.text
	timerID=setTimeout("ShowNextLine()", this.wait)
}

function TypeWriter() {
	lineText=this.text
	lineImage=this.ximage
	lineWait=this.wait
	charMax=lineText.length
	spaces=StringFill(" ", charMax)
//	if(lineImage.length > 0)
//		document.all.imageDiv.innerHTML="<IMG src='" + lineImage + "'>"
//	else
//		document.all.imageDiv.innerHTML=""
	TextTypeWriter()
}

function TextTypeWriter() {
	if (charNo <= charMax) {
		if (ticker==1) {
			if (charNo < charMax) {
				if (charEndVisible == tickRate) {
					charEnd = '_'
					charEndVisible = 1
				}
				else {
					charEnd = ''
					charEndVisible++
				}
			}
			else
				charEnd = ''
		}
		else
			charEnd = ''

		document.all.buttonFace.innerHTML=lineText.substring(0, charNo) + charEnd +spaces.substring(0, charMax-charNo)
		charNo++
		timerID=setTimeout("TextTypeWriter()", typeWriterWait)
	}
	else {
		charNo=0
		timerID=setTimeout("ShowNextLine()", lineWait)
	}
}

function Blink() {
	lineText=this.text
	charMax=lineText.length
	spaces=StringFill(" ", charMax)
	lineWait=this.wait
	TextBlink()
}

function TextBlink() {
	if (charNo <= blinkMax * 2) {
		if ((charNo % 2) == 1) {
			document.all.buttonFace.innerHTML=lineText
			blinkWait=blinkTextWait
		}
		else {
			document.all.buttonFace.innerHTML=spaces
			blinkWait=blinkSpacesWait
		}
		
		charNo++
		timerID=setTimeout("TextBlink()", blinkWait)
		}
	else {
		charNo=0
		timerID=setTimeout("ShowNextLine()", lineWait)
	}
}

function Expand() {
	lineText=this.text
	charMax=lineText.length
	charMiddle=Math.round(charMax / 2)
	lineWait=this.wait
	TextExpand()
}

function TextExpand() {
	if (charNo <= charMiddle) {
		document.all.buttonFace.innerHTML=lineText.substring(charMiddle - charNo, charMiddle + charNo)
		charNo++
		timerID=setTimeout("TextExpand()", expandWait)
		}
	else {
		charNo=0
		timerID=setTimeout("ShowNextLine()", lineWait)
   }
}

function Scroll() {
	spaces=StringFill(" ", scrollWidth)
	lineText=spaces+this.text
	charMax=lineText.length
	lineText+=spaces
	lineWait=this.wait
	TextScroll()
}

function TextScroll() {
	if (charNo <= charMax) {
	document.all.buttonFace.innerHTML=lineText.substring(charNo, scrollWidth+charNo)
	charNo++
	timerID=setTimeout("TextScroll()", scrollWait)
	}
	else {
		charNo=0
		timerID=setTimeout("ShowNextLine()", lineWait)
	}
}

function StartHeadliner() {
	StopHeadliner()
	timerID=setTimeout("ShowNextLine()", 2000)
	timerRunning=true
}

function StopHeadliner() {
	if (timerRunning) { 
		clearTimeout(timerID)
		timerRunning=false
	}
}

function ShowNextLine() {
	if (randomLines) 
		lineNo=getNewRandomInteger(lineNo, lineMax)
	else (lineNo < lineMax) ? lineNo++ : lineNo=1

	lines[lineNo].Display()
}

function LineClick(lineNo) {
	document.all.buttonFace.blur()
	if (lineNo > 0) 
		GotoUrl(lines[lineNo].url, lines[lineNo].frame)
}
	