function getRndMainImage()
{
	var poolSize = mainImagePool.length;
	if (poolSize > 0)
	{
		var rnd = Math.round((poolSize-1) * Math.random());
		var mainImage = mainImagePool[rnd];
		var imgStr = "<img src=\"" + mainImage.path + "\" border=\"\" width=\"160\" height=\"149\" alt=\"" + mainImage.alt + "\"/>";
		document.write(imgStr);
	}
}

function getRndSectionFrontHeroImage()
{
	var poolSize = sectionFrontImagePool.length;
	if (poolSize > 0)
	{
		var rnd = Math.round((poolSize-1) * Math.random());
		var mainImage = sectionFrontImagePool[rnd];
		var imgStr = "<img src=\"" + mainImage.path + "\" border=\"0\" width=\"728\" height=\"210\" alt=\"" + mainImage.alt + "\"/>";
		document.write(imgStr);
	}
}

////////////////////////////////
var poolSize = sectionFrontImagePool.length;
var herotimer = 0;
var heroindex = -1;
var herodelay = 5*1000;
var herocnt = poolSize;

function rotateImages()
{
	var str = "";
	var delay = 20*1000;

	str += "<div id=\"rotateImg\" style=\"display:block;\">";
	//var poolSize = sectionFrontImagePool.length;
	for (var i=0; i<poolSize; i++)
	{
		var mainImage = sectionFrontImagePool[i];
		//str += "<img id=\"sectionhero"+i+"\" src=\"" + mainImage.path + "\" border=\"0\" width=\"728\" height=\"210\" alt=\"" + mainImage.alt + "\"  style=\"position:absolute;opacity:0;filter:alpha(opacity=0);visibility:visible;zoom:1;\" />";
		str += "<div id=\"sectionhero"+i+"\" style=\"display:inline-block;opacity:0;filter:alpha(opacity=0);position:absolute;zoom:1;\"><img src=\"" + mainImage.path + "\" border=\"0\" width=\"728\" height=\"210\" alt=\"" + mainImage.alt + "\"></div>";
	}	
	str += "</div>";
	//str += "<script>herotimer=0;heroindex=-1;herodelay="+delay+";herocnt="+poolSize+";</script>";
	document.write(str);
}

function doRotate()
{
	clearTimeout(herotimer);
	if (herocnt>1)
	{
		herotimer = setTimeout(doRotate, herodelay);
		if (heroindex>-1)
		{
			var prevHero = document.getElementById("sectionhero"+heroindex);
			new Effect.Opacity(prevHero, {duration:1, from:1, to:0});
		}
		if  ( (heroindex==(herocnt-1)) || (heroindex<0) )
		{
			heroindex = 0;
		}
		else
		{
			heroindex++;
		}		
		var currHero = document.getElementById("sectionhero"+heroindex);
		new Effect.Opacity(currHero, {duration:1, from:0, to:1});
	}
}
