
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
// 第四部分：显示开奖号码的动画
//
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

var bAnimationShow = false;
var iAnimationLoop = 0;
var iAnimationStep = 10;
var iAnimationDelay = 40;

function AnimationLoop()
{
	var aniobj = document.getElementsByName("AnimationCode");

	for(var i=0; i<game.lastcode.length; i++) {
		if(iAnimationLoop >= (i+1)*iAnimationStep) {
			if((iAnimationLoop % 2)==0) {
				aniobj[i].innerHTML = game.lastcode.substr(i,1);
			}
		}
		else {
			aniobj[i].innerHTML = "<font color=\"#FFEAAC\">" + parseInteger(Math.floor(Math.random() * 10)) + "</font>";
		}
	}
    iAnimationLoop++;
}

function AnimationNext()
{
	if(iAnimationLoop<(game.lastcode.length*iAnimationStep+5)) {
		AnimationLoop();
		setTimeout("AnimationNext()",iAnimationDelay);
	}
	else {
		document.getElementById("AnimationTips").innerHTML = "开奖结果";
		AnimationShow = true;
	}
}

function AnimationStart()
{
	if( ! bAnimationShow ) {
		game.lastcode = FilePureDigital(game.lastcode);
		document.getElementById("AnimationOpen").innerHTML = game.lastopen;
		document.getElementById("AnimationTips").innerHTML = "正在开奖";
		iAnimationLoop=0;
		bAnimationShow = true;
		AnimationNext();
	}
	else {
		var dNow = new Date();
		if(dNow.getHours()>=9 && dNow.getHours()<22) 
		{
			Graph.Load();
			var bArray = Graph.dataTrend.split("|");
			var lbuf = bArray[bArray.length-2].split(",");

			// 如果发现有新的开奖号码，则需要更新一系列图表
			if( parseInt(lbuf[0]) != parseInt(game.lastopen) ) {
				// 更新开奖期号与开奖号码
				game.lastopen = lbuf[0];
				game.lastcode = FilePureDigital(lbuf[1]);

				Graph.Reload();

				Channel.OnChange(Channel.Name);
				Command.OnChange(Command.Name);

				bAnimationShow = false;
				AnimationStart();
			}
		}
	}
}

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

