  // FIFO buffer 
  
  // Added thedinfosNewsHeadLine to the buffer 7 Aug 2006 - MikeB  
  // Realized I needed the headline in the cycle news array too.
  // That makes 5 elements rather than 4.  Make sure to change the code in all places. - MikeB

  //Version History

  // v1.0.0 - 26/12/2000 - Initial prototyping
  // v1.0.1 - 27/12/2000 - Development to support element/fragment configuration
  //                     - First vbscript/database integration testing
  // v1.1.0 - 28/12/2000 - STABLE v1.1

  // Global variables
  var var_fifo_buffer;
  var var_fifo_temp;
  var var_fifo_sepchar;
  var var_fifo_errorstatus;

  //   Global arrays used to Cycle DINFOS News
  var dinfosNewsThumbFileName = new Array();
  var dinfosNewsImgAltTag = new Array();
  var dinfosNewsHeadLine = new Array();
  var dinfosNewsMoreContent = new Array();
  var dinfosNewsnewsId = new Array();
  
  var newsMaxCount; // Max count of the News Array
  
  var thisStory;
  
  var intMilliSec = 6000;  // setTimeout in f(x) cycleNews: change ad every 11 seconds - 11000
						//setTimout in f(x) cycleNews:change ad every 6 seconds modified - 2/6/07
  
  thisStory=0;  //Global index for the array used in the f(x) cycleNews



  // Call to initialise system
  function fifo_initialise(){
   var_fifo_buffer=""
   var_fifo_temp=""
   var_fifo_sepchar="~"
  }

  // Call to finalise system
  function fifo_finalise(){
  }

	// Push a new element into the buffer
	//---------------------------------------------------------------------------
	// Modified - 3 Aug 2006 Mike Benefiel for DINFOS Web
	//  If the new element is empty, set it to a space and add it
	// rather than raise error.
	//---------------------------------------------------------------------------
	function fifo_push(newelement){
		output=true;
		var_fifo_temp=newelement;
		if (var_fifo_temp.length==0){
			fifo_seterror(" ");
			var_fifo_temp = " ";
			//fifo_seterror("there is nothing to push!")
			//output=false
			} 
		if (var_fifo_temp.indexOf(var_fifo_sepchar)>0){
			fifo_geterror("illegal character");
			} 
		else {
			var_fifo_buffer=var_fifo_buffer+var_fifo_temp+var_fifo_sepchar;
			//alert('var_fifo_buffer: '+var_fifo_buffer);
		}
		//alert(fifo_countelements());
		return(output)
		}

  // Pop an element from the buffer
  function fifo_pop(){
   newlen=0
   var_fotjeff_temp=""
   if (var_fifo_buffer.length==0){
    fifo_geterror("there is nothing to pop!")
    } else {
     if (var_fifo_buffer.indexOf(var_fifo_sepchar)==-1){
      fifo_geterror("the "+var_fifo_sepchar+" character is illegal in the buffer")
      } else {
      var_fifo_temp=var_fifo_buffer.substr(0,(var_fifo_buffer.indexOf(var_fifo_sepchar)))
      newlen=var_fifo_buffer.length-(var_fifo_buffer.indexOf(var_fifo_sepchar))
      var_fifo_buffer=var_fifo_buffer.substr((var_fifo_buffer.indexOf(var_fifo_sepchar)+1),newlen)
     }
    }
    return(var_fifo_temp)
  }

  // Read the current buffer
  function fifo_readbuffer(){
   return(var_fifo_buffer)
  }

  // Set the current buffer
  function fifo_writebuffer(newvalue){
   var_fifo_buffer=newvalue
  }

  // Reset the current buffer
  function fifo_reset(){
   var_fifo_buffer=""
  }

  // Count the number of elements in the buffer
  function fifo_countelements(){
   count=0
   for (i=0; i<var_fifo_buffer.length; i++){
    if (var_fifo_buffer.substr(i,1)==var_fifo_sepchar){
    count=count+1
    }
   }
   return(count)
  }

  // Set the error status flag
  function fifo_seterror(message){
   var_fifo_errorstatus=message
  }

  // Get the error status flag
  function fifo_geterror(message){
   return(var_fifo_errorstatus)
  } 
	//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// Added 2 Aug 2006 Mike Benefiel for DINFOS Web
	//   Functions for the DINFOS News section
	//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

	//---------------------------------------------------------------------------
	// Load a record into the array - 2 Aug 2006 Mike Benefiel for DINFOS Web
	// Added thedinfosNewsHeadLine to the buffer 7 Aug 2006 - MikeB
	//---------------------------------------------------------------------------
	function load_news_record_in_array(theThumbFileName,theImgAltTag,thedinfosNewsHeadLine,theMoreContent,thenewsId){
		//alert('In load_news_record_in_array function before 1st push');
		fifo_push(theThumbFileName); 
		//alert('var_fifo_buffer: '+var_fifo_buffer);
		//alert('In load_news_record_in_array function after 1st push');
		fifo_push(theImgAltTag);
		fifo_push(thedinfosNewsHeadLine);
		fifo_push(theMoreContent); 
		fifo_push(thenewsId); 
		elements=fifo_countelements()/5;
		}
	//---------------------------------------------------------------------------
	// Load a record into the array - 2 Aug 2006 Mike Benefiel for DINFOS Web
	//---------------------------------------------------------------------------
	// We're using this a a debugging f(x)
	// Just assign a TAG with an ID of 'thelink'
	//---------------------------------------------------------------------------
	//   Need to write a f(x) to return the next element in the buffer.
	// Changed the subscript from4 to 5 to account for headline 
	//            elements=fifo_countelements()/5;   - MikeB 7 Aug 2006
	//        Also added pop() to the output.
	//---------------------------------------------------------------------------
	function render_list(){
		preserve=fifo_readbuffer(); // Pull off buffer contents
		//alert(preserve);
		elements=fifo_countelements()/5;
		html="<table border='1'><tr><td bgcolor='#cccccc'>DINFOS News Array</td></tr>";
		for (i=0; i<elements; i++){ // pop off elements from the BUFFER stack
				html=html+"<tr><td>"+fifo_pop()+", "+fifo_pop()+", "+fifo_pop()+", "+fifo_pop()+", "+fifo_pop()+" "+"</td></tr>";
			}
			html=html+"</table>";
			fifo_writebuffer(preserve); // Refill the buffer
			//alert('html: '+html);
			//document.all.thelink.innerHTML=html;
		}
		
	//---------------------------------------------------------------------------
	// just write an interim f(x) that moves the fifo buffer values into 4 arrays.
	//---------------------------------------------------------------------------
	//  Here it is.....
	//    I got the FIFO buffer functions from another site becuase they were not
	// copy written nor did the author seek any credit.  They were also very clean
	// and to the point.  But the stacks were not implemented as true arrays.
	//   The cycle function below is simple enough.  It would be straight forward
	// if the FIFO stacks were multidimensional arrays.  What I will now do is move
	// the data from the FIFO stacks into four separate one dimensional arrays for
	// the purpose of cycling the news articles.  That should be simple enough
	// for future programmers to follow. - MikeB 7 Aug 2006
	//   When you POP data off the stacks it looks like a destructive action.
	// But we use a technique that allows us to preserve the buffer contents.
	// We never destroy the data.  We restore the stack after popping off all
	// the values.
	//---------------------------------------------------------------------------

	//---------------------------------------------------------------------------
	//  Move FIFO Buffer into Cycle Arrays
	// Added dinfosNewsHeadLine to code making 5 elements. - MikeB 7 Aug 2006
	//   NOTE: Each pop() will sequentially remove an element from the stack,
	// while each array element is assigned by the index [i] value.
	//---------------------------------------------------------------------------
	//  Probably should consider changing the f(x) load_news_record_in_array
	// to load directly into these arrays rather than the FIFO buffer.
	// We are not really using the FIFO buffer for my original purpose. - MikeB 8 Aug 2006
	//---------------------------------------------------------------------------
	function setNewsArrays(){
		preserve=fifo_readbuffer(); // Pull off buffer contents
		//alert(preserve);
		elements=fifo_countelements()/5; // The buffer is stacked with elemenmts in order by fives
		// INIT the Five ARRAYS right here
		dinfosNewsThumbFileName=[]; // INIT array to EMPTY
		dinfosNewsImgAltTag=[]; // INIT array to EMPTY
		dinfosNewsHeadLine=[];
		dinfosNewsMoreContent=[]; // INIT array to EMPTY
		dinfosNewsnewsId=[]; // INIT array to EMPTY
		for (i=0; i<elements; i++){ // pop off elements from the BUFFER stack into the arrays
				dinfosNewsThumbFileName[i]	=fifo_pop();
				dinfosNewsImgAltTag[i]		=fifo_pop();
				dinfosNewsHeadLine[i]		=fifo_pop();
				dinfosNewsMoreContent[i]	=fifo_pop();
				dinfosNewsnewsId[i]			=fifo_pop();
			}
			newsMaxCount = i;
			//alert('newsMaxCount: '+newsMaxCount);
			fifo_writebuffer(preserve); // Refill the buffer
			//alert('In the setNewsArrays function - Count: '+newsMaxCount);
		}
		
	//---------------------------------------------------------------------------
	//   This function advances the story in the news cycle
	// Move next
	//---------------------------------------------------------------------------
	function cycleNewsNext(){
	//newsMaxCount 1 to max
	//thisStory array index ; 0 to n-1 ; 0 is the 1st index value
		if (newsMaxCount-1){
			if (thisStory==newsMaxCount-1){
				// at the last story in ARRAY, to set to 1st
					thisStory=0;
			}
			else {
					thisStory=thisStory+1;
			}
		setNewsTagElements ();
		}
		else{
			alert('There is no News ');
		}
	}
	//---------------------------------------------------------------------------
	//   This function decrements the story in the news cycle
	// Move last
	//**************** Not working yet 8 Aug 2006 MikeB
	//---------------------------------------------------------------------------
	function cycleNewsPrev(){
		if (newsMaxCount-1){ // If this evaluates to a positive integer it is TRUE
			if (thisStory==0){// at 1st entry, so goto max
					thisStory=newsMaxCount-1; // so goto the top of the array
			}
			else {// anywhere from the 1st to n-1, where n=last
					thisStory=thisStory-1; // decrement index
			}
		setNewsTagElements ();
		}
		else{
			alert('There is no News ');
		}
	}
		
	//---------------------------------------------------------------------------
	//  function cycleNews()
	// - - - - - - - - - - - - - - - 
	//   thisStory is the Index for the NewsArray
	// Advance the Index every(n) seconds based on the setTimeout f(x).
	//
	//   Call setNewsArrays() after the buffer is loaded.
	// 		setNewsArrays(); // populate the news arrays from the stack buffer
	//==============
	// Start by setting the index to '0'
	//---------- Completed 8 Aug 2006 Mike Benefiel - Sloppy, but it works
	// ROW ONE - Cell ONE
	//	TD Set the background of the cell url from the database path of the next ARRAY value (NAV)
	//	Set the IMAGE in the cell's ALT to the database NewsImgAltTag NAV
	// ROW TWO - Cell ONE
	//	Set the innerHTML of the cell this time, rather than the cell format properties
	//    Append the NAV for NewsHeadLine + NewsMoreContent + NewsnewsId
	//			NewsMoreContent is either a space or a prebuilt URL to the full news article
	//			NewsnewsId is either a space or a prebuilt URL to a picture gallery
	//---------------------------------------------------------------------------
	function cycleNews(){
		
		// compare the and increment the index in relation to the ARRAY size
		//  Base it off HeadLine as we will ALWAYS have a healine, but not always a picture
		if(++thisStory==dinfosNewsHeadLine.length){
			thisStory=0;
		} //move to next ad
		setNewsTagElements ();		
		// Self-Referencing
		setTimeout("cycleNews()", intMilliSec);  
	}
	
	function setNewsTagElements (){
		var strInnerHTML;
		var strTemp;
		document.getElementById('DinfosNewsTextImage').style.backgroundImage = 'url(/DINFOSCommon/images/FrontPageNews/'+dinfosNewsThumbFileName[thisStory]+')';
		document.getElementById('DinfosNewsImage').alt=dinfosNewsImgAltTag[thisStory];
		document.getElementById('DinfosNewsImage').title=dinfosNewsImgAltTag[thisStory];
		strInnerHTML=dinfosNewsHeadLine[thisStory];
		strTemp=dinfosNewsMoreContent[thisStory]+dinfosNewsnewsId[thisStory];
		document.getElementById('DinfosNewsText').innerHTML=strInnerHTML+strTemp;
	}
