// Ticker engine file

var mtc_sitecodes_NEW="MTCSITE100";
var mtc_tickerwidth_NEW="540px";

var mtc_content_NEW = new Array();
var mtc_sitecodes_NEW = new Array();
var mtc_urls_NEW = new Array();
var mtc_enddates_NEW = new Array();

/*
var mtc_content = new Array();
var mtc_urls = new Array();
mtc_content[0] = "Welcome to the new 511.org. Please take a look around...";
mtc_content[1] = "Again welcome to the new 511.org. Please take a look around...";
mtc_urls[0] = "";
mtc_urls[1] = "";
*/

//Get msg content from http://ticker.511.org/include/tickerengine.js
if(typeof(mtc_content) != "undefined" && typeof(mtc_content[0]) != "undefined" && mtc_content[0] != '') {
	
	for (var i=0; i < 10; i++) {
		if(typeof(mtc_content[i]) != "undefined" && mtc_content[i] != '') {
			mtc_content_NEW[i] = mtc_content[i];
			mtc_sitecodes_NEW[i] = "MTCSITE100~";
			mtc_urls_NEW[i] = mtc_urls[i];
			//alert(mtc_content_NEW[i]);
		}
	}
	
} else {
	
	//mtc_content_NEW[0] = "<a href='http://swirl.net' target='_blank'>Welcome to the new 511.org. Please take a look around...</a>&nbsp;&nbsp;&nbsp;<a href='http://swirl.net' target='_blank'>Again welcome to the new 511.org. Please take a look around...</a>";
	mtc_content_NEW[0] = "";
	mtc_sitecodes_NEW[0] = "MTCSITE100~";
	mtc_urls_NEW[0] = "";
	
}

if (!mtc_content_NEW)
    var mtc_content_NEW = new Array();
if (!mtc_sitecode_NEW)
    var mtc_sitecode_NEW = "~";
if (!marqueecontent_NEW)
    var marqueecontent_NEW="";
if (!mtc_tickerwidth_NEW)
    var mtc_tickerwidth_NEW="700px";
if (!marqueespeed_NEW)
    var marqueespeed_NEW=2;
if (!marqueebgcolor_NEW)
    var marqueebgcolor_NEW="#FFFFFF";
if (!mtc_tickersep_NEW)
    var mtc_tickersep_NEW = " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";

for (var i = 0; i < mtc_content_NEW.length; i++)
{
    var siteCodeString_NEW = mtc_sitecodes_NEW[i];
    
    if ((siteCodeString_NEW.search( mtc_sitecode_NEW ) != -1))
    {
        marqueecontent_NEW = marqueecontent_NEW + mtc_content_NEW[i];
        if (i != (mtc_content_NEW.length - 1))
        {
			marqueecontent_NEW = marqueecontent_NEW + mtc_tickersep_NEW;
        }
    }
}

//Specify the marquee's height
var marqueeheight_NEW="25px";

//Pause marquee onMousever (0=no. 1=yes)?
var pauseit_NEW=1;

////NO NEED TO EDIT BELOW THIS LINE////////////
marqueespeed_NEW=(document.all)? marqueespeed_NEW : Math.max(1, marqueespeed_NEW-1) //slow speed down by 1 for NS
var copyspeed_NEW=marqueespeed_NEW
var slowspeed_NEW=0;
//var pausespeed_NEW=(pauseit_NEW==0)? copyspeed_NEW: 0
var pausespeed_NEW=(pauseit_NEW==0)? copyspeed_NEW: slowspeed_NEW;
var iedom_NEW=document.all||document.getElementById
if (iedom_NEW)
document.write('<span id="temp_NEW" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent_NEW+'</span>')
var actualwidth_NEW=''
var cross_marquee_NEW, ns_marquee_NEW

function populate_NEW(){
    if (iedom_NEW){
        cross_marquee_NEW=document.getElementById? document.getElementById("iemarquee_NEW") : document.all.iemarquee_NEW
        cross_marquee_NEW.style.left=0; //parseInt(mtc_tickerwidth_NEW)+8+"px"
        cross_marquee_NEW.innerHTML=marqueecontent_NEW
        actualwidth_NEW=document.all? temp.offsetWidth : document.getElementById("temp_NEW").offsetWidth
        // mc: test 
        //alert(actualwidth_NEW);
    }
    else if (document.layers_NEW){
        ns_marquee_NEW=document.ns_marquee_NEW.document.ns_marquee2_NEW
        ns_marquee_NEW.left=parseInt(mtc_tickerwidth_NEW)+8
        ns_marquee_NEW.document.write(marqueecontent_NEW)
        ns_marquee_NEW.document.close()
        actualwidth_NEW=ns_marquee_NEW.document.width
    }
    lefttime_NEW=setInterval("scrollmarquee_NEW()",20)
    
    // Hide the DIV that contains the ticker if maruqeecontent is blank
    if (marqueecontent_NEW != "")
    {
        var tickerDiv_NEW = document.getElementById('tickerDisplay_NEW');
		tickerDiv_NEW.style.display = "block";
    }
}

// window.onload=populate_NEW

function addLoadEvent_NEW(func)
{    
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    } 
    else 
    {
        window.onload = function()
        {
            oldonload();
            func();
        }
    }
}

addLoadEvent_NEW(populate_NEW);

function scrollmarquee_NEW(){
    if (iedom_NEW){
        if (parseInt(cross_marquee_NEW.style.left)>(actualwidth_NEW*(-1)+8))
            cross_marquee_NEW.style.left=parseInt(cross_marquee_NEW.style.left)-copyspeed_NEW+"px"
        else
            cross_marquee_NEW.style.left=parseInt(mtc_tickerwidth_NEW)+8+"px"
    }
    else if (document.layers_NEW){
        if (ns_marquee_NEW.left>(actualwidth_NEW*(-1)+8))
            ns_marquee_NEW.left-=copyspeed_NEW
        else
            ns_marquee_NEW.left=parseInt(mtc_tickerwidth_NEW)+8
    }
}

if (iedom_NEW||document.layers_NEW) {
	
    with (document) {
		
		//If no ticker message is entered above, show the static Welcome message box.
		if (!mtc_content_NEW[0] || mtc_content_NEW[0].length == 0) {
			
			//Write this next line only so that no js error occurs
			document.write('<div id="iemarquee_NEW" style="position: absolute; top: -9999px;"></div>');
			
			document.write('<div class="double-wide">');
				document.write('<h1>Welcome to 511.org</h1>');
				document.write('<div class="left">');
					document.write('<p>511 is your one-stop phone and web source for up-to-the-minute transportation information. It\'s FREE and available whenever you need it &ndash; 24/7 &ndash; from anywhere in the nine-county Bay Area.</p>');
				document.write('</div><!-- END left-->');
					
				document.write('<div class="right">');
					document.write('<a href="call-511.asp" onclick=javascript:pageTracker._trackEvent("Portal","Entries","dial_511");><img src="img/icons/announce-phone.gif" alt="Dial 511 It\'s Free" id="Dial511" onmouseover=MM_swapImage("Dial511","","img/icons/announce-phone_over.gif",1) onmouseout=MM_swapImgRestore() /></a>');
				document.write('</div><!-- END right-->');
				document.write('<div class="clear"></div>');
			document.write('</div><!-- END double-wide-->');
		
		//Else if a ticker message is entered above, show the scrolling ticker.
		} else {
			
			document.write('<div id="tickerOuter" style="height:101px">');
			document.write('<div id="tickerDisplay_NEW" style="display:none">');
			document.write('<div class="double-wide_red">');
				document.write('<h1 style="padding-top: 7px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Breaking News</h1>');
				
				document.write('<div style="position: relative; margin-top: -22px; margin-right: 13px !important; margin-right: /* */7px; float: right; font-size: 11px; color: #990000; text-align: right;"><span id="stopScroll" style="display: block;" onClick=stopScroll();><span style="position: absolute; top: 2px; right: 20px; white-space: nowrap;">Stop Scrolling</span>&nbsp<img src="/img/global/checkbox.gif" alt="checkbox" /></span><span id="startScroll" style="display: none;" onClick=startScroll();><span style="position: absolute; top: 2px; right: 20px; white-space: nowrap;">Stop Scrolling</span>&nbsp<img src="/img/global/checkbox_checked.gif" alt="checkbox" /></span></div>');
				
				document.write('<div class="left">');
					document.write('<div id="breakingNewsTicker">');
			
						document.write('<p>');
						if (iedom_NEW)
						{
							write('<div style="position:absolute;width:'+mtc_tickerwidth_NEW+';height:'+marqueeheight_NEW+';overflow:hidden;">');
							write('<div style="position:absolute;width:'+mtc_tickerwidth_NEW+';height:'+marqueeheight_NEW+';background-color:'+marqueebgcolor_NEW+'" onMouseover="stopScroll_rollover();" onMouseout="startScroll_rollover();">');
							write('<div id="iemarquee_NEW" style="position:absolute; left:0px; top:8px; color: #990000; font-weight: bold;"></div>');
							write('</div></div>');
						}
						else if (document.layers_NEW)
						{
							write('<ilayer width='+mtc_tickerwidth_NEW+' height='+marqueeheight_NEW+' name="ns_marquee_NEW" bgColor='+marqueebgcolor_NEW+'>');
							write('<layer name="ns_marquee2_NEW" left=0 top=8 onMouseover="stopScroll_rollover();" onMouseout="startScroll_rollover();"></layer>');
							write('</ilayer>');
						}			   
						document.write('</p>');
					document.write('</div><!-- END #breakingNewsTicker-->');	
				document.write('</div><!-- END left-->');
					
				document.write('<div style="position: relative;">');
				document.write('<div class="right" style="position: absolute; top: 0px; left: 567px;">');
					document.write('<a href="call-511.asp" onclick=javascript:pageTracker._trackEvent("Portal","Entries","dial_511");><img src="img/icons/announce-phone_red.gif" alt="Dial 511 It\'s Free" id="Dial511" onmouseover=MM_swapImage("Dial511","","img/icons/announce-phone_over_red.gif",1) onmouseout=MM_swapImgRestore() /></a>');
				document.write('</div><!-- END right-->');
				document.write('</div><!-- END -->');
				document.write('<div class="clear"></div>');
			document.write('</div><!-- END double-wide_red-->');
			document.write('</div><!-- END tickerDisplay-->');
			document.write('</div><!-- END tickerOuter-->');
			
		}
		
    }
}

function stopScroll() {
	  document.getElementById('stopScroll').style.display = 'none';
	  document.getElementById('startScroll').style.display = 'block';
	  copyspeed_NEW=pausespeed_NEW;
}
function startScroll() {
	  document.getElementById('startScroll').style.display = 'none';
	  document.getElementById('stopScroll').style.display = 'block';
	  copyspeed_NEW=marqueespeed_NEW;
}
function stopScroll_rollover() {
	  copyspeed_NEW=pausespeed_NEW;
}
function startScroll_rollover() {
	  if(document.getElementById('startScroll').style.display == 'block') {
	  	// do nothing
	  } else {
		  document.getElementById('startScroll').style.display = 'none';
		  document.getElementById('stopScroll').style.display = 'block';
		  copyspeed_NEW=marqueespeed_NEW;
	  }
}