
//--edAjax
  var reInteger = /^\d+$/;  
  function isDigit (c)
  {   
    return reInteger.test(c);
  }
  
  // add a leading zero if number is single-digit
  function addZero(a)
  { 
    return (a < 10)? a = '0'+a : a; 
  }
      
  // get todays date and return as yymmdd
  function getTodaysDate()
  {
    var d=new Date();   
    var mm=d.getMonth()+1;
    mm=addZero(mm);
    var dd=d.getDate();
    dd=addZero(dd);
    var yy=d.getFullYear().toString().substring(2);
    return(yy+mm+dd);
 }
  
  // asynchronous HTTP requests from the browser to the server.
  function initRequest() 
  {
    xmlReq=false;
    if (window.XMLHttpRequest) 
    {
      xmlReq = new XMLHttpRequest();
    } 
    else 
      if (window.ActiveXObject) 
      {
         try 
         {
           xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
         } 
         catch (e) 
         {
           try 
           {
             xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
           } 
           catch (E) 
           {
             xmlReq = false;
           }
         }
       }
       else
       {
         alert("Warning - something else!");
       }
       return xmlReq;
  }
  
  // called when HTML page initially loaded..
  function init2() 
  {
    url = "/lbp/featured_articles/"; 
    getDirFile(url);   
  }   
  
  function getDirFile(url) 
  {
    var req = initRequest();
    req.onreadystatechange = function() 
    {
      if (req.readyState == 4) 
      {
        if (req.status == 200) {
              findFileName(req.responseText); 
        } 
        else if (req.status == 204)
        {
           clearTable();
        }
        else
          alert ("getdirfile status="+req.status);
       }
     }; // end function def
     req.open("get", url, true);
     req.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
     //req.setRequestHeader("Content-Type","test/html"); 
     req.send(null);            
   }
    
   function getDataFile(url) 
   {
     var req = initRequest();
     req.onreadystatechange = function() 
     {
        if (req.readyState == 4) 
        {
          if (req.status == 200) {
               updateForm(req.responseText); 
          } 
           else if (req.status == 204)
            {
              clearTable();
            }
            else
            alert ("getdatafile status="+req.status);
         }
      };
      req.open("get", url, true);
      req.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
      //req.setRequestHeader("Content-Type","test/html"); 
      req.send(null);            
  }
  // There are 3 TD cells that need to be filled with data from the
  // "fa_mmddyy.html" file. They are identified by div sections within 
  // the TD cell. This function extracts the data based on keywords/symbols
  // and populates the divs.
  function updateForm(data) 
  {    
    //var img2Div = document.getElementById('div_image2'); 
    var linkDiv1 = document.getElementById('div_link1'); 
    var linkDiv2 = document.getElementById('div_link2'); 
    //var titlDiv = document.getElementById('div_title');    
  
    var tBuf = data;
    var start=tBuf.indexOf('"title"')+8;
    var end=tBuf.substring(start).indexOf("</p>");
    end=end + start;
    var sTitle=tBuf.substring(start,end);
 
    tBuf = tBuf.substring(end);
    start = tBuf.indexOf("images");
    end = tBuf.substring(start).indexOf("hspace");
    end = end + start;
    var sImg2=tBuf.substring(start,end); 
    tBuf = tBuf.substring(end);
    start = tBuf.indexOf("/>") +2;
    end = tBuf.substring(start).indexOf("</p>");
    end = start+end;
    var sImg2Txt = tBuf.substring(start,end); 
    var sImg2Tmp = '<img src="featured_articles/' + sImg2 + " align='right'>" + sImg2Txt; 
  
    tBuf = tBuf.substring(end);
    start = tBuf.indexOf("/lbp")+5;
    end = tBuf.substring(start).indexOf(">")-1;
    end = start+end;
    var sLink="lbp/"+tBuf.substring(start,end); 
    var sLinkTmp1 = "<a href=/MOAframe.asp?ButHit=Pub&Main="+sLink+"?section=CA> <img src='../images/featuredarticle.gif' border='0' alt='"+sTitle+"'></a>";
    var sLinkTmp2 = "<a href=/MOAframe.asp?ButHit=Pub&Main="+sLink+"?section=CA><font color='#999999'>"+sTitle+"</a>";
    //titlDiv.innerHTML = '';  
    //img2Div.innerHTML = '';   
    linkDiv1.innerHTML = '';
    linkDiv2.innerHTML = '';
    //titlDiv.innerHTML += "<b>"+sTitle+"</b>";    
    //img2Div.innerHTML += sImg2Tmp; 
    linkDiv1.innerHTML += sLinkTmp1 ;    
    linkDiv2.innerHTML += sLinkTmp2 ;        
  } 
   
  function findFileName(data)
  {
    var todaysDate=getTodaysDate();
    var index=0;
    var start=0;
    var end=0;
    var reorderedName="";  
    var newFileName="/lbp/featured_articles/";
    var arrayNames=new Array();
    index=data.indexOf("fa_",start);
    start=index;
    end=start+14;
    while (index != -1)
    { 
      var partialName = data.substring(start+3,start+9);
      if(isDigit(partialName)==true)
      {
        reorderedName=partialName.substring(4)+partialName.substring(0,2)+partialName.substring(2,4);       
        arrayNames.push(reorderedName);
      }
      index=data.indexOf("fa_",end);
      start=index;
      end=start+14; 
    }   
    arrayNames.sort();    
    var lastName=arrayNames[0];
    for (j=0; j<arrayNames.length; j++) 
    {
      reorderedName=arrayNames[j];
      if (reorderedName > todaysDate)
      {
        break;
      }
      else
      {
        lastName=reorderedName;
      }
    }
    newFileName = newFileName + "fa_"+lastName.substring(2,4)+lastName.substring(4)+lastName.substring(0,2)+".html?section=CA";
    getDataFile(newFileName);
  }  
  
  // <--edAjax 
 