
var flashRunning = 0;
var onFlash = 0;
var flashRunningIcons = [];
var onFlashIcons = [];

var alphaPNG = [];


function initFlashHome()
{
	gCapes["tapaBlanca"] 	= MM_findObj("tapaBlancaDiv")
	gCapes["tapaBlanca1"] = MM_findObj("tapaBlanca1Div")
	gCapes["tapaBlanca2"] = MM_findObj("tapaBlanca2Div")
	gCapes["tapaBlanca3"] = MM_findObj("tapaBlanca3Div")
	flashRunningIcons[1]=0; flashRunningIcons[2]=0; flashRunningIcons[3]=0;
	onFlashIcons[1]=0; 			onFlashIcons[2]=0; 			onFlashIcons[3]=0;

	if (!es.ie)
	{
		if (!window.jsNivellHtml) window.jsNivellHtml = "../";
		
		alphaPNG[100] = new Image();
		alphaPNG[100].src = window.jsNivellHtml+"img/flash-100.png";
		alphaPNG[75] = new Image();
		alphaPNG[75].src = window.jsNivellHtml+"img/flash-75.png";
		alphaPNG[50] = new Image();
		alphaPNG[50].src = window.jsNivellHtml+"img/flash-50.png";
		alphaPNG[25] = new Image();
		alphaPNG[25].src = window.jsNivellHtml+"img/flash-25.png";
		
		gCapes["tapaBlanca1"].style.left = "28px";
		gCapes["tapaBlanca2"].style.left = "28px";
		gCapes["tapaBlanca3"].style.left = "27px";

	}
}

function flashIcons(i)
{
	capa = gCapes["tapaBlanca"+i];
	if (es.ie)
	{
		if (flashRunningIcons[i] == 0 && onFlashIcons[i] == 0 && capa.style.visibility == "hidden")
		{
			flashRunningIcons[i] = 1;
			onFlashIcons[i] = 1;
			capa.style.visibility = "visible";
			capa.style.background = "#FFFFFF";
			canviaAlphaIcons(100, i);
		}
	}
	else
	{
		if (flashRunningIcons[i] == 0 && onFlashIcons[i] == 0 && capa.style.visibility == "hidden")
		{
			flashRunningIcons[i] = 1;
			onFlashIcons[i] = 1;
			capa.style.visibility = "visible";
			canviaPNGsIcons(125, i);
		}
	}
}

function canviaPNGsIcons(a, i)
{
	temps = 150;
	a = a - 25;
	
	if (a > 0)
	{
		MM_setTextOfLayer("tapaBlanca"+i+"Div", "", "<img src='"+alphaPNG[a].src+"' border='0' width='181' height='48'>");
		setTimeout("canviaPNGsIcons("+a+", "+i+");", temps);
	}
	else
	{
		MM_setTextOfLayer("tapaBlanca"+i+"Div", "", "");
		capa = gCapes["tapaBlanca"+i];
		capa.style.visibility = "hidden";
		flashRunningIcons[i] = 0;
	}
}

function canviaAlphaIcons(a, i)
{
	inc = 5;
	temps = 50;
	if (a < 50) inc *= 2;
	if (a < 25) inc *= 2;
	capa = gCapes["tapaBlanca"+i];
	a -= inc;
	if (a < 0) a = 0;
	capa.style.filter = "alpha(opacity="+a+");";
	if (a > 0) setTimeout("canviaAlphaIcons("+a+","+i+");", temps);
	else {
		capa.style.visibility = "hidden";
		flashRunningIcons[i] = 0;
	}
}

function outFlashIcons(i, deFlash)
{
	if (deFlash == 1 && flashRunningIcons[i] == 1)
	{
		onFlashIcons[i] = 0;
	}
	else if (deFlash == 0 && flashRunningIcons[i] == 0)
	{
		onFlashIcons[i] = 0;
	}
	
}


function flash()
{
	capa = gCapes["tapaBlanca"];
	if (es.ie)
	{
		if (flashRunning == 0 && onFlash == 0 && capa.style.visibility == "hidden")
		{
			flashRunning = 1;
			onFlash = 1;
			capa.style.visibility = "visible";
			capa.style.background = "#FFFFFF";
			canviaAlpha(100);
		}
	}
	else
	{
		if (flashRunning == 0 && onFlash == 0 && capa.style.visibility == "hidden")
		{
			flashRunning = 1;
			onFlash = 1;
			capa.style.visibility = "visible";
			canviaPNGs(125);
		}
	}
}


function canviaPNGs(a)
{
	temps = 150;
	a = a - 25;
	
	if (a > 0)
	{
		MM_setTextOfLayer("tapaBlancaDiv", "", "<img src='"+alphaPNG[a].src+"' border='0' width='825' height='340'>");
		setTimeout("canviaPNGs("+a+");", temps);
	}
	else
	{
		MM_setTextOfLayer("tapaBlancaDiv", "", "");
		capa = gCapes["tapaBlanca"];
		capa.style.visibility = "hidden";
		flashRunning = 0;
		onFlash = 0;
	}
}

function canviaAlpha(a)
{
	inc = 5;
	temps = 50;
	if (a < 50) inc *= 2;
	if (a < 25) inc *= 2;
	capa = gCapes["tapaBlanca"];
	a -= inc;
	if (a < 0) a = 0;
	capa.style.filter = "alpha(opacity="+a+");";
	if (a > 0) setTimeout("canviaAlpha("+a+");", temps);
	else {
		capa.style.visibility = "hidden";
		flashRunning = 0;
		onFlash = 0;
	}
}
