
/** Timer methods and variables */
var c=1.0;
var d = 100;
var t;
var timer_is_on=0;
var slide = 2;
var starting = false;
var paused = false;
var firstRun = true;
var pauseTime = 0;
var pauseLimit = 7000;

function timedCount()
{
var flash_area = document.getElementById('slide');

// If flash script just started, pause it for a moment
if (firstRun)
{
    paused = true;
    firstRun = false;
}

if (!paused)
{
// Update the flash area appropriately
if (starting)
{
    c = c + 0.05;
    if (c >= 1.0)
    {
        c = 1.0;
    }

    d = d + 5;

    flash_area.style.opacity = c;
    flash_area.style.filter = 'alpha(opacity=' + d + ')';

    if (d >= 100)
    {
        paused = true;
        starting = false;
    }
}
else
{
    // Fadeout
    if (c >= 1.0)
    {
        c = 1.0;
    }
    c = c - 0.10;

    d = d - 10;

    flash_area.style.opacity = c;
    flash_area.style.filter = 'alpha(opacity=' + d + ')';

    if (d <= 0)
    {
        starting = true;

        // Set the next slide
        slide = slide + 1;
        if (slide > 5)
        {
            slide = 1;
        }

        // Determine which background to show
        switch (slide)
        {
            case 1:
                flash_area.style.background = "url('http://www.wlispeak.org/p36/img/slide_1.png') no-repeat";
            break;

            case 2:
                flash_area.style.background = "url('http://www.wlispeak.org/p36/img/slide_2.png') no-repeat";
            break;

            case 3:
                flash_area.style.background = "url('http://www.wlispeak.org/p36/img/slide_3.png') no-repeat";
            break;

            case 4:
                flash_area.style.background = "url('http://www.wlispeak.org/p36/img/slide_4.png') no-repeat";
            break;

            case 5:
                flash_area.style.background = "url('http://www.wlispeak.org/p36/img/slide_5.png') no-repeat";
            break;
        }
    }
}
}
else
{
    // Stop for now
    pauseTime = pauseTime + 100;

    if (pauseTime >= pauseLimit)
    {
        pauseTime = 0;
        paused = false;
    }
}

// Update timer
t = setTimeout("timedCount()",50);
}

function doTimer()
{
  if (!timer_is_on)
  {
    timer_is_on=1;
    timedCount();
  }
}

/** This method rotates the main images on the screen. */
function rotator()
{
    document.getElementById('slide').style.background = "url('http://www.wlispeak.org/p36/img/slide_1.png') no-repeat black";
    // Update settings after the hand shows
    var flash_area = document.getElementById('slide');
    flash_area.style.height = '270px'
    flash_area.style.position = 'relative';
    flash_area.style.top = '0';
    pauseLimit = 7000;
    doTimer();
}
