/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// News Box Alert Scroller v2.1 Written for the Pennsylvania Turnpike Commission by Voicenet
///// Modify the following 4 lines to suit your needs or include these values in the function call
var n_txtArrDef=""
///// For hyperlinks format text as follows - "TITLE|MESSAGE|URL" - Example:
//var n_txtArrDef="1/1/2001 12:30 PM: Test Title|This is a test message link to go back home.|home.htm"
var n_marqueewidth="706px"			// Width of the scrolling box in pixels
var n_marqueebgcolor="#FFFFFF"		// Background color of the Scroll Box
var n_marqueeborder="#FFFFFF"		// Color of the Scroll Box Border
///// To use insert the following into your html source:
/////     <SCRIPT Language="JavaScript1.2" src="NewsBoxSimple.js"></SCRIPT>
/////     <SCRIPT Language="JavaScript1.2">showNewsBox();</SCRIPT>
///// OR, include the following lines to override the variable values:
/////     <SCRIPT Language="JavaScript1.2" src="NewsBoxSimple.js"></SCRIPT>
/////     <SCRIPT Language="JavaScript1.2">n_mkTextArray('Your Message Here','500px','#FDFFE6','#CECECE');</SCRIPT>
///// OR, to include the PTC's live Emergency Notification Service Scrolling Banner use the following:
/////     <SCRIPT Language="JavaScript1.2" src="http://www.paturnpike.com/NewsBox.aspx"></SCRIPT>
/////											(Use http:// OR https:// where applicable)
/////     <SCRIPT Language="JavaScript1.2">n_mkTextArray('','600px','');</SCRIPT>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Other useful variables which might need modification to suit your needs
var n_marqueeheight="14px"
var n_scrollborder=1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var n_ii=0
var n_marqueespeed=2
var n_pauseit=1
var n_timerRunning = false
var n_timerRunning2 = false
n_marqueespeed=(document.all)? n_marqueespeed : Math.max(1, n_marqueespeed-1) //slow speed down by 1 for NS
var n_copyspeed=n_marqueespeed
var n_pausespeed=(n_pauseit==0)? n_copyspeed: 0
var n_iedom=document.all||document.getElementById
var n_marqueecontent, n_cross_marquee, n_ns_marquee, n_lefttime, n_lefttime_var2
var n_actualwidth=1
var n_movetonext=0
var n_txtArr = new Array()
n_txtArr[0]=n_txtArrDef

function showNewsBox(){
	n_mkTextArray('','','','');
}

function n_mkTextArray(n_sclText, n_sclMarqueewidth, n_sclMarqueebgcolor, n_sclMarqueeborder) {
	var n_mtext = n_txtArrDef;
	if (n_sclText.length > 0) n_mtext = n_sclText
	if (n_sclMarqueewidth.length > 0) n_marqueewidth = n_sclMarqueewidth
	if (n_sclMarqueebgcolor.length > 0) n_marqueebgcolor = n_sclMarqueebgcolor
	if (n_sclMarqueeborder.length > 0) n_marqueeborder = n_sclMarqueeborder
	n_txtArr = new Array()
	var n_mstring = n_mtext
	var n_txtArrL = 0
	if (n_mstring.length > 0) {
		n_mstring = n_mstring + "\r\n";
		n_myarray = n_mstring.split("\r\n");
		for (n_key in n_myarray) {
			var n_tline = n_myarray[n_key];
			if (n_tline.length > 0) {
				n_txtArr[n_txtArrL] = n_tline;
				n_txtArrL ++;
			}
		}
	}else{
		n_txtArr[0]=n_txtArrDef;
		n_scrollborder=0;
		n_copyspeed=1;
		n_pauseit=0;
	}
	n_writeScroller();
}

function n_populate(){
	if (n_iedom){
		n_cross_marquee=document.getElementById? document.getElementById("n_iemarquee") : document.all.n_iemarquee
	}
	else if (document.layers){
		n_ns_marquee=document.n_ns_marquee.document.n_ns_marquee2
	}
	n_addText(n_ii)
}
function n_addText(n_z){
	n_myarray = n_txtArr[n_z].split("|");
	if (n_myarray.length == 3)
		n_marqueecontent = '<nobr><a href="' + n_myarray[2] + '" class="slink"><font size=2 face="Arial" STYLE="font-color:#000000;font-size:11px;font-face:Arial"><b><font size=3 color="#FF3333" STYLE="font-size:12px;font-color:#FF3333;font-weight:bold">' + n_myarray[0] + '</b></font>&nbsp;&nbsp;' + n_myarray[1] + '</font></a></nobr>'
	else
		n_marqueecontent = '<nobr><font size=2 face="Arial" STYLE="font-size:12px;font-face:Arial;"><b></b>' + n_txtArr[n_z] + '</b></font></nobr>'
	if (n_iedom){
		n_cross_marquee.style.left=parseInt(n_marqueewidth)+8+"px"
		n_cross_marquee.innerHTML=n_marqueecontent
		n_cross_marquee.title='Click For More Details'
		n_actualwidth=document.all? n_iemarquee.offsetWidth : document.getElementById("n_iemarquee").offsetWidth
	}
	else if (document.layers){
		n_ns_marquee.left=parseInt(n_marqueewidth)+8
		n_ns_marquee.document.write(n_marqueecontent)
		n_ns_marquee.document.close()
		n_actualwidth=n_ns_marquee.document.width
	}
	n_doTimer()
}
function n_scrollmarquee(){
	if (n_iedom){
		if (n_actualwidth == 0) n_actualwidth=document.all? n_iemarquee.offsetWidth : document.getElementById("n_iemarquee").offsetWidth
		var n_cleft = parseInt(n_cross_marquee.style.left)
		var n_cright = n_actualwidth + n_cleft
		if (n_cleft<n_marqueespeed && n_scrollborder == 1 && (n_actualwidth < parseInt(n_marqueewidth) || (n_actualwidth > parseInt(n_marqueewidth) && n_cright < parseInt(n_marqueewidth)) ))
			n_movetonext = 1
		else if (n_cleft>(n_actualwidth*(-1)+8))
			n_cross_marquee.style.left=n_cleft-n_copyspeed+"px"
		else if (n_cleft>(n_actualwidth*(-1)))
				n_movetonext = 2
		else
			n_cross_marquee.style.left=parseInt(n_marqueewidth)+8+"px"
	}
	else if (document.layers){
		if (n_actualwidth == 0) n_actualwidth=n_ns_marquee.document.width
		var n_cleft = n_ns_marquee.left
		var n_cright = n_actualwidth + n_cleft
		if (n_cleft < n_marqueespeed && n_scrollborder == 1 && (n_actualwidth < parseInt(n_marqueewidth) || (n_actualwidth > parseInt(n_marqueewidth) && n_cright < parseInt(n_marqueewidth)) ))
			n_movetonext = 1
		else if (n_cleft>(n_actualwidth*(-1)+8))
			n_ns_marquee.left-=n_copyspeed
		else if (n_cleft>(n_actualwidth*(-1)))
			n_movetonext = 2
		else
			n_ns_marquee.left=parseInt(n_marqueewidth)+8
	}
	if (n_movetonext == 1){
		n_doTimer();
		n_doTimer2(2000);
	}
	else if (n_movetonext == 2){
		n_doTimer();
		n_doTimer2(10);
	}
}
function n_nextMsg(){
	if (n_timerRunning2) {
		if (n_ii<n_txtArr.length-1)
			n_ii++
		else
			n_ii=0
		n_addText(n_ii)
		n_movetonext = 0
		n_timerRunning2 = false;
	}
}
function n_doTimer(){
	if (n_timerRunning){
		n_timerRunning = false;
		clearInterval(n_lefttime);
	} else {
		n_timerRunning = true;
		n_lefttime=setInterval("n_scrollmarquee()",30);
	}
}
function n_doTimer2(n_t2dur){
	if (n_timerRunning2 || n_t2dur == 0){
		n_timerRunning2 = false;
		clearTimeout(n_lefttime_var2);
	} else if (parseInt(n_t2dur) > 0) {
		n_timerRunning2 = true;
		n_lefttime_var2 = setTimeout("n_nextMsg()",n_t2dur);
	}
}
function n_killTimers() {
	if (n_timerRunning){
		clearInterval(n_lefttime);
		n_timerRunning = false;
	}
	if (n_timerRunning2){
		clearTimeout(n_lefttime_var2);
		n_timerRunning2 = false;
	}
}
function n_writeScroller(){
	if (n_iedom||document.layers){
		with (document){
			write('<STYLE>')
			write('a.slink:link {			color : #000000; text-decoration : none}')
			write('a.slink:hover {			color : #000000; text-decoration : none}')
			write('a.slink:visited {		color : #000000; text-decoration : none}')
			write('a.slink:visited:hover {	color : #ff3333; text-decoration : none}')
			write('</STYLE>')
			write('<table border=0 cellspacing=0 cellpadding=0 ID="Table1"><tr><td>')
			write('<table border="2" cellspacing="0" cellpadding="0" bordercolor="'+n_marqueeborder+'" ID="Table2"><tr>')
			write('<td bgcolor='+n_marqueebgcolor+'>')
			if (n_iedom){
				write('<div style="position:relative;width:'+n_marqueewidth+';height:'+n_marqueeheight+';overflow:hidden"><IMG height=10 width=2 src="images/spacer.gif">')
				write('<div style="position:absolute;width:'+n_marqueewidth+';height:'+n_marqueeheight+';background-color:'+n_marqueebgcolor+'" onMouseover="if(n_pauseit==1) n_killTimers()" onMouseout="if(n_pauseit==1) n_doTimer()">')
				write('<div id="n_iemarquee" style="position:absolute;left:0px;top:0px"></div>')
				write('</div></div>')
			}
			else if (document.layers){
				write('<ilayer width='+n_marqueewidth+' height='+n_marqueeheight+' name="n_ns_marquee" bgColor='+n_marqueebgcolor+'>')
				write('<layer name="n_ns_marquee2" left=0 top=0 onMouseover="if(n_pauseit==1) n_killTimers()" onMouseout="if(n_pauseit==1) n_doTimer()"></layer>')
				write('</ilayer>')
			}
			write('</td></tr></table></td></tr></table>')
		}
	}
	n_populate();
}
