// JavaScript Document
var frameRate = Math.round(1000/50);
var initPos = 75;
var newPos = initPos;
var endPos = 0;
var scrollSpeed = 1;
var flashAlpha = 100;
var itemHomeImg = 1;
var imgDuration = 4000;

function initScroll()
{
	document.getElementById('nameDiv').style.top = newPos+"px";
	window.setTimeout('scrollVUp()', frameRate);
}
function scrollVUp()
{
	if(newPos>endPos)
	{
		newPos -= scrollSpeed + Math.round(newPos/5);
		document.getElementById('nameDiv').style.top = newPos+"px";
		window.setTimeout('scrollVUp()', frameRate);
	} else {
		document.getElementById('nameDivWhite').style.visibility = 'visible';
		flashAlpha = 100;
		flashUp();
	}
}
function flashUp()
{
	if(flashAlpha>0)
	{
		flashAlpha = flashAlpha - 10;
		document.getElementById('nameDivWhite').style.visibility = (flashAlpha % 50 == 0) ? 'hidden' : 'visible';
		window.setTimeout('flashUp()', frameRate);
		document.getElementById('mainImg').style.opacity = (100-flashAlpha)/100;
		document.getElementById('mainImg').style.filter = 'alpha(opacity=' + (100-flashAlpha) + ')';
	} else {
		document.getElementById('nameDivWhite').style.visibility = 'hidden';
		fade();
	}
}

function fade()
{
	var nextImg = (itemHomeImg<3) ? itemHomeImg + 1 : 1;
	document.getElementById('img1').src = 'pics/f_home' + itemHomeImg + '.png';
	document.getElementById('img2').src = 'pics/f_home' + nextImg + '.png';
	
	document.getElementById('mainImg').style.opacity = 1.0;
	document.getElementById('mainImg').style.filter = 'alpha(opacity=100)';
	
	document.getElementById('mainImg2').style.opacity = 0.0;
	document.getElementById('mainImg2').style.filter = 'alpha(opacity=0)';
	
	itemHomeImg = nextImg;
	flashAlpha = 100;
	window.setTimeout('fadeOut()', imgDuration);
}

function fadeOut()
{
	if(flashAlpha > 0)
	{
		flashAlpha = flashAlpha - 5;
		document.getElementById('mainImg').style.opacity = flashAlpha/100;
		document.getElementById('mainImg').style.filter = 'alpha(opacity=' + flashAlpha + ')';
		
		document.getElementById('mainImg2').style.opacity = (100-flashAlpha)/100;
		document.getElementById('mainImg2').style.filter = 'alpha(opacity=' + (100-flashAlpha) + ')';
		window.setTimeout('fadeOut()', frameRate);
	} else {
		window.setTimeout('fade()', imgDuration);
	}
}

