 var stopRotation = false



// Load first panel by default

var firstPanel = document.getElementById("newsPanel0");

if (firstPanel != null)

{

    // This line works around a display bug in Gecko-based browsers

    firstPanel.style.display = 'inline';

    

    // Show the panel

    firstPanel.style.display = 'block';

}





// Load up all panels

var newspanels = new Array('newsPanel0','newsPanel1','newsPanel2','newsPanel3');



function showNewsPanel(tab, panelName, pnlImgName, pnlImgLocation)

{

	// Panels to hide    

	for(i = 0; i < newspanels.length; i++)

	{

		// Get the current panel & button

		var curNewsPanel = document.getElementById(newspanels[i]);

        

		// If it exists, hide it

		if (curNewsPanel != null)

			curNewsPanel.style.display = 'none';

	}



    // Panel to show

	var newsPanelToShow = document.getElementById(panelName);

	

	// This line works around a display bug in Gecko-based browsers

	newsPanelToShow.style.display = 'inline';



	// Show the panel

	newsPanelToShow.style.display = 'block';



    // Load appropriate image

	var imgToShow = document.getElementById(pnlImgName);

	var imgLocation = document.getElementById(pnlImgLocation);

	var imgPath = "UserFiles/Image/NewSlide/" + imgToShow.value;

	imgLocation.src = imgPath;

	

    // Stop rotation when item is clicked

    stopRotation = true

    rotatePanels()

	

	return false;

}



// BEGIN - Panel Rotator

var panelIndex = -1;

// Negative 1 allows rotator to start at 0

// for the first image which is zero-based



function getNextPanel() {

    panelIndex = (panelIndex + 1) % newspanels.length;

    return panelIndex;

}



// Image names

var imgNames = new Array('imgName0','imgName1','imgName2','imgName3');



// Image Locations

var imgLocations = new Array('headlineImg0','headlineImg1','headlineImg2','headlineImg3');



function rotatePanels() {

    // Rotate panels unless one has already been clicked

    if (stopRotation != true)

    {

        for(i = 0; i < newspanels.length; i++)

	    {

		    // Get the current panel

		    var curNewsPanel = document.getElementById(newspanels[i]);



		    // If it exists, hide it

		    if (curNewsPanel != null)

			    curNewsPanel.style.display = 'none';

	    }

    	

    	// Determine next panel to show

        var nextPanel = getNextPanel();

        var newsPanelToShow = document.getElementById(newspanels[nextPanel]);

    

        // This line works around a display bug in Gecko-based browsers

	    newsPanelToShow.style.display = 'inline';



	    // Show the panel

	    newsPanelToShow.style.display = 'block';

        

        // Load appropriate image

	    var imgToShow = document.getElementById(imgNames[nextPanel]);

	    var imgLocation = document.getElementById(imgLocations[nextPanel]);

	    var imgPath = "UserFiles/Image/NewSlide/" + imgToShow.value;

	    imgLocation.src = imgPath;

	

	    // Keep rotating every 6 seconds

        var recall = "rotatePanels()";

        setTimeout(recall, 6000);

     }

}



// Start rotation when page loads

rotatePanels();



// END - Panel Rotator