// Define parameters   
   var webfeedHeading = "ME-NET News Feed"
   var shouldDisplayHeading = false
   var shouldDisplayTime    = false
   var erfDisplaySource     = true
   var openNewWindow        = true
// Key stroke delay in milliseconds
   var strokeDelay = 15
// Line feed delay in milliseconds
   var linefeedDelay = 2500
// items separarators
// Headline Source Access Time
//^        ^      ^      ^
//|        |      |      |timeSeparator
//|        |      |accessSeparator
//|        |sourceSeparator
//|headlineSeparator
   var headlineSeparator="&nbsp;"
   var sourceSeparator="&nbsp;&nbsp;"
   var accessSeparator="&nbsp;"
   var timeSeparator = "&nbsp;"

// Define cursor
   var cursors = new Array("-","_","_")
   function updateCursor(nCharsTyped, charsInThisArticle) 
   {
   if (nCharsTyped == charsInThisArticle)
        return "";
   if (cursors != null && cursors.length > 0)
        return cursors [ nCharsTyped % cursors.length ];
   return "";
   }

// Define article item
   var articleItems = new Array(4);
   function updateArticleItems(theArticle)
   {
   articleItems[0] = new Array(theArticle.headline_text + "", theArticle.url);
   articleItems[1] = new Array(theArticle.source, theArticle.document_url);
   articleItems[2] = new Array(theArticle.access_status, theArticle.access_registration);
   time = new Date(theArticle.harvest_time);
   time.setHours(time.getHours() - (time.getTimezoneOffset() / 60 ));
   articleItems[3] = new Array(time.toString(), null);
   }
   var itemEndings = new Array("_headline", "_source", "_access", "_time", "_access_spacing");
   function TickerTypewriter(elementId, strokeDelay, linefeedDelay)
   {
   this.iCurrentArticle = -1;
   this.iCurrentItem = -1;
   this.elementId     = elementId;
   this.strokeDelay   = strokeDelay;
   this.linefeedDelay = linefeedDelay;
   this.nCharsTyped = 0;
   this.createTicker();
   this.activeTag = document.getElementById(this.elementId+itemEndings[0]);//the link
   this.theContent = "";
   this.theLink="#";
   }
   TickerTypewriter.prototype.createTicker = function()
   {
   var theTarget="_top";
   if (openNewWindow == true)
   {
   theTarget="_blank";
   }
   document.write(headlineSeparator);
   document.write("<a class='headlinetype' id='" + this.elementId + itemEndings[0] + "' href='#' target='"+theTarget+"'></a>");
   if (erfDisplaySource)
       document.write(sourceSeparator);
   document.write("<a class='sourcetype' id='" + this.elementId + itemEndings[1] + "' href='#' target='"+theTarget+"'></a>");
   document.write("<span id='"+ this.elementId + itemEndings[4]+"'></span>");
   document.write("<a class='accesstype' id='" + this.elementId + itemEndings[2]+ "' href='#' target='"+theTarget+"'></a>");
   if (shouldDisplayTime)
       document.write(timeSeparator);
   document.write("<span class='timetype' id='" + this.elementId + itemEndings[3] + "' target='"+theTarget+"'> </span>");
   }
   TickerTypewriter.prototype.nextEntry = function()
   {
   this.iCurrentItem = (this.iCurrentItem + 1) % 4;
   if (this.iCurrentItem == 0) 
   {
   this.iCurrentArticle = (this.iCurrentArticle + 1) % article.length;
   updateArticleItems(article[this.iCurrentArticle]);
   for(var i=0;i<itemEndings.length;i++)
   document.getElementById(this.elementId+itemEndings[i]).innerHTML = "";
   }
   }
   TickerTypewriter.prototype.nextItem = function()
   {
   this.nextEntry();
   if (this.iCurrentItem == 1 && !erfDisplaySource)
      this.nextEntry();
   theArticle = article[this.iCurrentArticle];  
   if (this.iCurrentItem == 2 && theArticle.access_status != "sub" && theArticle.access_status != "reg")
       this.nextEntry();
   else
       document.getElementById(this.elementId+itemEndings[4]).innerHTML = accessSeparator;
   if (this.iCurrentItem == 3 && !shouldDisplayTime)
       this.nextEntry();
   this.theContent = articleItems[this.iCurrentItem][0];
   this.theLink    = articleItems[this.iCurrentItem][1];
   this.activeTag = document.getElementById(this.elementId+itemEndings[this.iCurrentItem]);
   if (this.theLink != null)
        this.activeTag.href = this.theLink;
   }
   TickerTypewriter.prototype.lastItem = function()
   {
   var lastItem = 0;
   if ( erfDisplaySource )
        lastItem = 1;
   theArticle = article[this.iCurrentArticle];  
   if (theArticle.access_status == "sub" || theArticle.access_status == "reg")
        lastItem = 2;
   if (shouldDisplayTime)
        lastItem = 3;
   return lastItem;
   }
   TickerTypewriter.prototype.run = function()
   {
   if (this.nCharsTyped == 0)
   {
   this.nextItem();
   }
   this.activeTag.innerHTML = this.theContent.substring(0, this.nCharsTyped);
   this.activeTag.innerHTML += updateCursor(this.nCharsTyped, this.theContent.length);
   var nextDelay = this.strokeDelay;
   if(this.nCharsTyped != this.theContent.length) {
       this.nCharsTyped++;
   }
   else {
       this.nCharsTyped = 0;
       if (this.iCurrentItem == this.lastItem())
            nextDelay = this.linefeedDelay;
   }
   setTimeout(this.elementId+".run()", nextDelay);
   }


// Write ticker
   if (article == null)
       article = new Array();
   if (article.length == 0)
   {
   document.writeln("<center>Please reload this page to view the News/Information</center>");
   }
   else
   {
   var articleERF = new sa("http://www.me-net.combidom.com","","<font color=#ffff0c>Powered by ME-NET</font>", "text", " ", " ",    "http://www.me-net.combidom.com", article[0].harvest_time, " ", " ");
   article[article.length] = articleERF;
   document.writeln("<div class='containertype' width='100%'>");
   if (shouldDisplayHeading)
   {
   document.writeln("<span class='headingtype'>" + webfeedHeading + "</span>");
   }
   theTickerTypewriter = new TickerTypewriter("theTickerTypewriter", strokeDelay, linefeedDelay);
   theTickerTypewriter.run();
   document.writeln("</div>");
   }

