// JavaScript Document

var ajaxRequest;   
var url = "http://www.brownsville-pub.com/news/marquee.asp";
var myScrollingText="*";
var loadVar;

function makeAjaxRequest(url, callback) {   
   if (window.XMLHttpRequest) {   
      ajaxRequest = new XMLHttpRequest();   
   } else if (window.ActiveXObject) {   
      ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");   
   }   
    
   ajaxRequest.open("GET", url, true);   
   ajaxRequest.onreadystatechange = callback;   
   ajaxRequest.send(null);   
}   

function MakeReq(){    

makeAjaxRequest(url,updateCities);

}

function addLoadEvent(func) 
{  
	  var oldonload = window.onload;  
	  if (typeof window.onload != 'function') 
	  {  
	   // window.onload = func;  
	  } else {  
	    window.onload = function() {  
	      if (oldonload) {  
	        oldonload();  
	      }  
	      func();  
	    }  
	  }  
}
    
    addLoadEvent(makeAjaxRequest(url,updateCities));
    
function updateCities() {   
   if (ajaxRequest.readyState == 4) {   
      if (ajaxRequest.status == 200) {   
        // do something here   
		//document.getElementById("myScroll").innerHTML=ajaxRequest.responseText;
		myScrollingText = ajaxRequest.responseText;
		if (myScrollingText.length > 3){
		SetVar();
		}
      } else {   
         document.getElementById("myScroll").innerHTML=" ";  
      }   
   }   
}  


//**************************************
//**************************************
// JavaScript Document

var nPos;
var nLen;
var nMsg;
var nMsg2;
var nBox_len;
var nBlank;

function SetVar()
{

	nMsg = "     ...       ";
	nMsg2 = "-"
	nMsg+= myScrollingText;
	

	nLen = nMsg.length;
	nBox_len = 65;
	nPos = -1;
	nBlank = "";
	//fill variable nBlank with blank characters.
	for (i=0;i<=nBox_len;i++)
	{
		nBlank+=" ";
	}	
	
	if (nMsg.length > 4)
	{
	clearInterval(loadVar);
	Begin();
	}



}

function Begin()
{
	Populate();
	lefttime=setInterval("myPar()",150)

}


function myPar()
{
//"this is a message that is longer than twenty characters.   . . .  ";
	//1.  Copy blanks to a variableX.   (Populate{})
	//2.  Copy text to end of variableX.(Populate{})
	//3.  Copy blanks again to end of varialbeX.(Populate{})
	//4.  Display from posX with a lenght of nBox.
	//5.  Increment value for posX
	//6.  If value from posX >= nBox.Length then start at step 1.

	//4......
	var strDisplay="";
	strDisplay = nMsg2.substr(0,nBox_len)
	document.getElementById("myScroll").innerHTML=strDisplay;  //Write the output.
	//5.........
	nPos++;
	nMsg2 = nMsg2.substr(1,nMsg2.length);
	//6.........
	if ((nPos >= nMsg.length )) //nBox_len) )
	{    Populate();	}

}

function Populate()
{
	if (nPos==-1){
	nMsg2 = nBlank;
	}

	nMsg2+= nMsg;
	if (nBox_len>nMsg.length){
	nMsg2+= nBlank.substr(0,nBox_len-nMsg.length);
	}
	nPos=0;
}