
var flashelem;
function dosetup()
{
	flashelem=document.getElementById("flashbutton");
	if (flashelem == null)
	{
		return;
	}
	window.setInterval("flashtimer.doaction()", 40);
}

var flashtimer={};

flashtimer.delay=100;
flashtimer.baseGreen=204;
flashtimer.blueHs=102;

flashtimer.wait=function()
{
	flashtimer.delay--;
	if (flashtimer.delay < 0)
	{
		flashtimer.doaction =flashtimer.flare;
		flashelem.style.backgroundImage="none";
		flashtimer.green=221;
		flashtimer.blue=51;
		flashelem.style.backgroundColor="rgb(255,"+flashtimer.green+","+flashtimer.blue+")";
	}
};

flashtimer.setup=function()
{
	flashtimer.delay=Math.floor(Math.random()*100)+20;
	flashtimer.doaction=flashtimer.wait;
};

flashtimer.flare=function()
{
	if (flashtimer.green<255)
	{
		flashtimer.green+=17;
	}
	if (flashtimer.blue<255)
	{
		flashtimer.blue+=51;
		flashelem.style.backgroundColor="rgb(255,"+flashtimer.green+","+flashtimer.blue+")";
	}
	else
	{
		flashtimer.fade();
		flashtimer.doaction=flashtimer.fade;
	}
}

flashtimer.fade=function()
{
	flashtimer.blue-=51;
	if (flashtimer.blue==0)
	{
		flashelem.style.backgroundImage="url(http://evchallenge.swantafe.wa.edu.au/images/metal.gif)";
		flashtimer.setup();
	}
	else if (flashtimer.blue < 153)
	{
		flashtimer.green -= 17;
	}
	flashelem.style.backgroundColor="rgb(255,"+flashtimer.green+","+flashtimer.blue+")";
}

flashtimer.doaction=function()
{
	flashtimer.setup();
	flashtimer.delay=Math.floor(Math.random()*40)+10;
}

window.onload=function()
{
	dosetup();
};

 
