var fwHideMenuTimer,cycleTimer,flyoutTimer;
var cObj,fwStart,fwDHFlag;
var cycleCurrentId = -1;
var storyImg;
var storyImgSrc = new Array(
	"hp-story-0.jpg",
	"hp-story-1.jpg",
	"hp-story-2.jpg",
	"hp-story-3.jpg",
	"hp-story-4.jpg"
);
function FW_clearTimeout()
{
	window.fwHideMenuTimer = null;
	if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
	fwHideMenuTimer = null;
	fwDHFlag = false;
}
function FW_startTimeout(a)
{
	fwStart = new Date();
	fwDHFlag = true;
	fwHideMenuTimer = setTimeout("fwDoHide()", 200);
	clearTimeout(flyoutTimer);
}

function fwDoHide()
{
	if (!fwDHFlag) return;
	var elapsed = new Date() - fwStart;
	if (elapsed < 200) {
		fwHideMenuTimer = setTimeout("fwDoHide()", 2200-elapsed);
		return;
	}
	fwDHFlag = false;
	MM_hidenLayers();
	window.ActiveMenuItem = 0;
	storyImg.src="images/" + storyImgSrc[0];
	autoCycle();
}
function MM_hidenLayers() {
	rightMenu = document.getElementById("hp-nav").getElementsByTagName("div");
	for (i=0; i<rightMenu.length; i++ )
	{
		rightMenu[i].style.display = "none";
	}
	
}

function MM_showLayers(obj) {
	cObj = obj;
	flyoutTimer = window.setTimeout("MM_timeShowLayers()",2000);
	window.clearTimeout(cycleTimer);
	storyImg.src="images/" + storyImgSrc[obj.substr(1,1)];
}
function MM_timeShowLayers() {
	document.getElementById(cObj).style.display = "block";
}


function autoCycle() {
	cycleTimer = window.setTimeout("autoCycle()",5000);
	if (++cycleCurrentId == storyImgSrc.length)
	{
		cycleCurrentId = 0;
	}
	storyImg.src="images/" + storyImgSrc[cycleCurrentId];
}

window.onload = function () {
	storyImg = document.getElementById("story").firstChild;
	autoCycle();
}
