/*
 2 thousandths of second wait per cycle (ThousandthsOfSecondPause),  500 cycles per second (Fullsecond) = FASTEST scrolling speed
 4               250
 5               200
 8               125
10               100
20                50
25                40
40                25
50                20
100               10 = SLOWEST scrolling speed
*/
// var ThousandthsOfSecondPause=25
var FullSecond=1000/ThousandthsOfSecondPause
// var MaxWait=5
var ThousandthsOfSecond=0;
var secondsCounter=0;
var newsItemNumber=0;
var newsItemSubstringIndex=1;
var nowScrolling=0;
var firstIteration=0;
var rSec=0;
var lastSecond=0;

function rTime() {

now = new Date();
rSec = now.getSeconds();

	if (rSec>lastSecond || (rSec==0 && lastSecond==59)) {
 
		if (rSec==0) {
			min++;

			if (min==60) {
				min=0;
				hr++;

				if(hr==24) {
				hr=0;
				}
			}
		}		

	var ampm, nampm, nhr, nmin, nsec;

	if (hr>= 12) {nampm = "PM"};
	else {nampm = "AM"};

	if(hr > 12) {nhr = hr -12};
	else {nhr = hr};

	if (hr == 0) {nhr = "12"};
	else {nhr = nhr};

	if (min < 10) {nmin = "0" +min};
	else {nmin = min};

	if (rSec < 10) {nsec = "0" +rSec};
	else {nsec = rSec};

	var printIt = nhr+ ":" +nmin+ ":" +nsec+ " " +nampm;
	if (typeof bottom.document != "unknown" && typeof bottom.document.clock != "undefined" && typeof bottom.document.clock.clockface != "undefined") { bottom.document.clock.clockface.value = printIt; }
	secondsCounter++; // measures pause for scrolling text
	}

	if (news.length>0) {

		if ((firstIteration==0 || secondsCounter==MaxWait) && (nowScrolling==0)) {
			if (typeof bottom.document != "unknown" && typeof bottom.tickernews != "undefined") {
				bottom.tickernews.innerHTML = " ";
			}
			nowScrolling=1;
			firstIteration=1;
		}		

		if (nowScrolling==1) {
			if (typeof bottom.document != "unknown" && typeof bottom.tickernews != "undefined") {
				bottom.tickernews.innerHTML = news[newsItemNumber].substring(0,newsItemSubstringIndex);
				}

			if (newsItemSubstringIndex==news[newsItemNumber].length) {
				newsItemSubstringIndex=1;
				nowScrolling=0;
				secondsCounter=1;
				newsItemNumber++;

				if (newsItemNumber==news.length) {
					newsItemNumber=0;
					}
			} else {
				newsItemSubstringIndex++;
			}
		}
	}

lastSecond=rSec;
ThousandthsOfSecond++;
if (ThousandthsOfSecond==FullSecond) { ThousandthsOfSecond=0 }; // FullSecond = number of iterations per second 
var KeepItGoing=setTimeout("rTime()",ThousandthsOfSecondPause); // thousandths of second pause between iterations
//var KeepItGoing=setTimeout("rTime()","1000");
}
function getVal (num) {
	num=String(num);
	var num1="1234567890"
	var num2="48631914522875931599"
	var idx = num1.indexOf(num)
	return num2.substr(idx*2,2)
}