/****************************************************************************************
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'     *##  *##
'     ##   ##             Copyright 2007 H & B Solutions
'    ##***##              All Rights Reserved
'   ##   ##               
' *##  *#&##**%           Authors: Hernandez, Bailey
'        ##   ##          Date:    Oct 2007
'       ##***%            Version: 0.01
'      ##    ##  
'    *##****^  Solutions
'||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*****************************************************************************************/

/****************************************************
This variables will set the delay and amount of news.
*****************************************************/
var ArrInd;
var TimeDelay;
var strInternal;
var spanCurrent;
var spanTotal;
var runningNews;
spanCurrent = "";
spanTotal = "";
ArrInd = 0;
TimeDelay = 5000; //*** In Milliseconds 1000 = 1 second.****
runningNews = true;

//****************************************************

/********************************************************
Initialize strInternal and kicks off the News ticker.
*********************************************************/
function StartNews(strObj, strCurrent, strTotal){
	strInternal = strObj;
	spanCurrent = strCurrent;
	spanTotal = strTotal;
	debugger;
	writeSpan();
}//End Start News


function previousNews(){
    
}//***End previousNews***

function forwardNews(){

}//***End forwardNews***

function PlayPauseNews(){
    if (runningNews == true)
    {
        document.getElementById("imgPlayPause").src = "./img/play.jpg";
        runningNews = false;
    }
    else
    {
        document.getElementById("imgPlayPause").src = "./img/pause.jpg";
        runningNews = true;
        writeSpan();
    }
}//***End PlayPauseNews***

/********************************************************
Writes the news information to the News span object in the page.
*********************************************************/
function writeSpan()
{
    if (runningNews == true)
    {
	    //************* Write the Amount of news where available ********
	    if ( (spanCurrent != "") && (spanTotal != "") )
	    {
		    document.getElementById(spanCurrent).innerHTML = ArrInd + 1;
		    document.getElementById(spanTotal).innerHTML = NewsArray.length;
	    }
	    //****************************************************************

	    //*************Write the information to the Span Object and increment the Array seed*************
	    document.getElementById(strInternal).innerHTML = "" + NewsArray[ArrInd];
	    ArrInd++;
	    //************************************************************************************************

	    //*************Reset the Array Seed*************
	    if (ArrInd == NewsArray.length)
		    ArrInd = 0;
	    //**********************************************
    	
	    //*************Show the News for N seconds*************
	    //var myImg = new Image();
	    //myImg.src = './img/pause.jpg';
	    //document.getElementById("imgPlayPause").src = myImg.src
	    setTimeout('writeSpan()',TimeDelay);	    
	} //end if
	 
	//*****************************************************	
}//Write Span Ends

/********************************************************
Scrolls one item UP at a time.
*********************************************************/
function UpNews(){

    if (runningNews == true)
    {
        PlayPauseNews();
    }
        
    //************* Write the Amount of news where available ********
    if ( (spanCurrent != "") && (spanTotal != "") )
    {
        if (ArrInd == 0)
            ArrInd = NewsArray.length - 1;
        else
            ArrInd--;

  	    document.getElementById(spanCurrent).innerHTML = ArrInd + 1;
	    document.getElementById(spanTotal).innerHTML = NewsArray.length;
    }
    //****************************************************************

    //************* Decrement the Array seed and Write the information to the Span Object *************
    document.getElementById(strInternal).innerHTML = "" + NewsArray[ArrInd];

    //************************************************************************************************

}// UpNews Ends

/********************************************************
Scrolls one item DOWN at a time.
*********************************************************/
function DownNews(){

    if (runningNews == true)
    {
        PlayPauseNews();
    }
        
    //************* Write the Amount of news where available ********
    if ( (spanCurrent != "") && (spanTotal != "") )
    {
        if (ArrInd == (NewsArray.length - 1))
  	        ArrInd = 0;
    	else
            ArrInd++;

        document.getElementById(spanCurrent).innerHTML = ArrInd + 1;
	    document.getElementById(spanTotal).innerHTML = NewsArray.length;
    }
    //****************************************************************

    //************* Decrement the Array seed and Write the information to the Span Object *************
    document.getElementById(strInternal).innerHTML = "" + NewsArray[ArrInd];

    //************************************************************************************************

    //*************Reset the Array Seed*************
    if (ArrInd == NewsArray.length)
	    ArrInd = 0;
    //**********************************************

}// DownNews Ends
