﻿/*
Typing Scroller
Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
With modifications by Dynamicdrive.com
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/

var timerId = 0;

//Secify scroller contents
//var line=new Array();
//line[1]="<a href='#'>This is an awsome script</a>"
//line[2]="It brings up the text you want..."
//line[3]="One letter at a time"
//line[4]="You can add and subtract lines as you like."
//line[5]="It\'s very cool and easy to use"

//Specify font size for scoller
//var ts_fontsize="12px"

//--Don't edit below this line

var longestmessage=1;
for (i=2;i<line.length;i++)
{
	if (line[i].length>line[longestmessage].length)
	{
		longestmessage=i;
	}
}

//Auto set scroller width
var tscroller_width=line[longestmessage].length

lines=line.length-1; //--Number of lines

temp="";
nextchar=-1;
nextline=1;
cursor="";

function animate(time)
{
	if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines)
	{
		nextline++;
		nextchar=-1;
		document.getElementById("twitter2").innerHTML=temp;
		temp="";
//		timerId = setTimeout("nextstep()",time);
		timerId = setTimeout("newline()",time);
	}
	else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length)
	{
		nextline=1;
		nextchar=-1;
		document.getElementById("twitter2").innerHTML=temp;
		temp="";
		timerId = setTimeout("nextstep()",time);
	}
	else
	{
		nextstep();
	}
}

function newline()
{
	if (link[nextline] != "")
	{
		document.getElementById("twitter").innerHTML="<a href='"+link[nextline]+"' id='twitter2'></a>";
	}
	else
	{
		document.getElementById("twitter").innerHTML="<div id='twitter2'></div>";
	}

	nextstep();
}

function nextstep()
{
	nextchar++;
	temp+=line[nextline].charAt(nextchar);

	document.getElementById("twitter2").innerHTML=temp+cursor;
	timerId = setTimeout("animate(2000)",50);
}

//if IE 4+ or NS6
if (document.all||document.getElementById)
{
//	window.onload=animate;
	window.onload=newline;
}

function Pause()
{
	document.getElementById("imgPlayPause").src="/_layouts/NccPageLayouts/SiteLandingPage/Images/Play.gif";
	document.getElementById("imgPlayPause").onclick=Play;
	temp=line[nextline];
	document.getElementById("twitter2").innerHTML=temp;
	clearTimeout(timerId);
}

function Play()
{
	document.getElementById("imgPlayPause").src="/_layouts/NccPageLayouts/SiteLandingPage/Images/Pause.gif";
	document.getElementById("imgPlayPause").onclick=Pause;
	temp=line[nextline];
	animate(1);
}

function Previous()
{
	document.getElementById("imgPlayPause").src="/_layouts/NccPageLayouts/SiteLandingPage/Images/Play.gif";
	document.getElementById("imgPlayPause").onclick=Play;
	clearTimeout(timerId);
	if (nextline>1)
	{
		nextline--;
		nextchar=-1;
	}
	else
	{
		nextline=lines;
		nextchar=-1;
	}
	
	temp=line[nextline];
	updateHtml();
}

function Next()
{
	document.getElementById("imgPlayPause").src="/_layouts/NccPageLayouts/SiteLandingPage/Images/Play.gif";
	document.getElementById("imgPlayPause").onclick=Play;
	clearTimeout(timerId);
	if (nextline!=lines)
	{
		nextline++;
		nextchar=-1;
	}
	else
	{
		nextline=1;
		nextchar=-1;
	}
	
	temp=line[nextline];
	updateHtml();
}

function updateHtml()
{
	if (link[nextline] != "")
	{
		document.getElementById("twitter").innerHTML="<a href='"+link[nextline]+"' id='twitter2'>"+line[nextline]+"</a>";
	}
	else
	{
		document.getElementById("twitter").innerHTML="<div id='twitter2'>"+line[nextline]+"</div>";
	}
}
