﻿var delay = 15000;
var fadetime = 1000;
var index = 0;
var Fading = false;
var FadeTimer;
var FaderTimer;

function Fade(id,ary,dot)
{
	var obj=document.getElementById(id);
	obj.innerHTML=GetReviewText( index );
	
	UnselectDots(dot, ary.length);
	SelectDot(dot, index);
	FadeIn(id);
	
	IncrimentIndex(ary.length);
	
	FaderTimer = window.setTimeout(function(){ FadeOut(id); },delay-fadetime);
	FadeTimer = window.setTimeout(function(){ Fade(id,ary,dot); },delay); //change text
}
function IncrimentIndex(max)
{
	//next one is random
	//var i = index;
	//while (i==index) index=Math.floor(Math.random()*max);
	
	//next one is sequential
 	index++;
 	if (index > max - 1) index=index % max;
}
function SetOpacity(id, opc)
{
	if (opc<0||opc>100){ return; }
	var divBox = document.getElementById(id);
	divBox.style.filter='alpha(opacity='+ opc +')';
	divBox.style.opacity=divBox.style.MozOpacity=divBox.style.KhtmlOpacity=opc/100-.001;
}
function FadeIn(id)
{
	FadeInOut(id,false);
}
function FadeOut(id)
{
	FadeInOut(id,true);
}
function FadeInOut(id,FadeIt)
{
	if (Fading == FadeIt)
	{
		var obj=document.getElementById(id);
		zxcBAnimator('opacity#',obj,0,100,fadetime/2);
		Fading = !FadeIt;
	}
}
function SelectDot(dot, i)
{
	var mapdot = document.getElementById(dot + '' + i);
	if (mapdot) mapdot.className = "selected";
}
function UnselectDots(dot, max)
{	
	var i=0;
	for(i=0; i<=max; i++)
	{
		var mapdot = document.getElementById(dot + '' + i);
		if (mapdot) mapdot.className = "";
	}
}