var delay=new Array();
var numElements=new Array();
var index=new Array();
var timeOutID=new Array();
var isRunning=new Array();

var tmpDisplayCount = 0;
var checkfirstFg = 0;

function backFlipperText(boxId)
{var updateDiv;var flipperContent;if((index[boxId]>=0)&&(index[boxId]<numElements[boxId]))
{if(isRunning[boxId])
{clearTimeout(timeOutID[boxId]);isRunning[boxId]=false;}
index[boxId]--;if(index[boxId]<0)
{index[boxId]=numElements[boxId]-1;}
if(getElement("hidden_"+boxId+'_'+index[boxId])===null)
{backFlipperText(boxId);}
else
{updateDiv=getElement("hidden_"+boxId+'_'+index[boxId]);flipperContent=getElement("flipperContent_"+boxId);flipperContent.innerHTML=updateDiv.innerHTML;}}}
function forwardFlipperText(boxId)
{var updateDiv;var flipperContent;if((index[boxId]<numElements[boxId])&&(index[boxId]>=0))
{if(isRunning[boxId])
{clearTimeout(timeOutID[boxId]);isRunning[boxId]=false;}
index[boxId]++;if(index[boxId]+1>numElements[boxId])
{index[boxId]=0;}
if(getElement("hidden_"+boxId+'_'+index[boxId])===null)
{forwardFlipperText(boxId);}
else
{updateDiv=getElement("hidden_"+boxId+'_'+index[boxId]);flipperContent=getElement("flipperContent_"+boxId);flipperContent.innerHTML=updateDiv.innerHTML;}}}
function pauseFlipperText(boxId)
{if(isRunning[boxId])
{clearTimeout(timeOutID[boxId]);isRunning[boxId]=false;}}
function startFlipperText(boxId)
{if(isRunning[boxId])
{clearTimeout(timeOutID[boxId]);isRunning[boxId]=false;}
timeOutID[boxId]=setTimeout('updateFlipperText(\''+boxId+'\')',delay[boxId]);isRunning[boxId]=true;}

/*
 * Name: 
 *	updateFlipperText
 *
 * Description:
 *	increments index for this boxId and changes
 *	flipperContent's innerHTML to that of the index's
 *
 * Pre-conditions:
 *	boxId		REQUIRED	stnBoxId string
 *
 * Post-conditions:
 *	flipperContent_boxId is updated
 *
 * Log:
 *	Doug Mears			5/8/2006
 *  Dipak A.Basantani	6/21/2006	
 *		- to reset the index[boxId] to the first feature selected from the cache
 *	- Creation
 *  Dipak A.Basantani	6/21/2006	
 *
 *  Ramu                07/17/2007
 *     --if  feature fifo not avialable move to next featureFifo
 */
function updateFlipperText(boxId) 
{
	var updateDiv;
	var flipperContent;
	index[boxId]++;

	if(index[boxId] > numElements[boxId])
	{
		//
		//if no feature fifos to display then assign -1 value to index[boxId]
		//to avoid javascript error , else assign $checkFirstFg
		//
		index[boxId] =0;
	}
	//
	if(getElement("hidden_" + boxId + '_' + index[boxId]) == null)
	{
		updateFlipperText(boxId);
	} //end if, boxid null
	else
	{
		updateDiv = getElement("hidden_" + boxId + '_' + index[boxId]);
		flipperContent = getElement("flipperContent_" + boxId);
		flipperContent.innerHTML = updateDiv.innerHTML;

		timeOutID[boxId] = setTimeout('updateFlipperText(\'' + boxId + '\')', delay[boxId]);

		isRunning[boxId] = true;
	}//end else
} 
//END function updateFlipperText

function runFlipperText(flipDelay, tmpDisplayCount, checkfirstFg, boxId, elementsCnt)
{
    delay[boxId] = flipDelay;
    
    if(checkfirstFg >= 0) 
    {
	    numElements[boxId] = elementsCnt;
	    numElements[boxId] += tmpDisplayCount;
	    index[boxId] = checkfirstFg;
    	
	    //if more than one FeatureFifo 
	    if(numElements[boxId] > 1)
	    {
		    timeOutID[boxId] = setTimeout('updateFlipperText(\'' + boxId + '\')', 5000);
	    } 
	    //end if more than one 
    	
	    isRunning[boxId] = true;
    	
	    if(document.getElementById)
	    {
	        flipperText = document.getElementById('hidden_' + boxId + '_0');
	    }
	    else
	    {
		    flipperText = document.all('hidden_' + boxId + '_0');
	    }
    	
    	if (flipperText != null)
    	{		
	        document.write(flipperText.innerHTML);
	    }
    } 
    //end if checkfirstFg
}

function getElement(elName)
{
    if(document.getElementByName)
    {
        return document.getElementByName(elName);
    }
    else if(document.getElementById)
    {
        return document.getElementById(elName);
    }
    else
    {
        return false;
    }
}

