/*
this file was written by Jonathan Pittock
Cambridge Networks 2007

This script will load a serious of frames into an array of image 
objects and then play them in sequence once.
the objective is to have a non flash based animation that will play once and then stop after that.
*/

//some values and objects
var objectid = "uanimation";
var animspeed = 1;
var startdelay = 1000;
var animframestotal = 11;
var animframes = new Array();
var i = 0;
var timer;
var loadcount = animframestotal;
var frame = 0;

//setup the frames
for(i = 0; i <= 10; i++) {
	animframes[i] = new Image();
	animframes[i].onload = frameloaded;
	animframes[i].src = "images/stories/header_images/animated/frame"+i+".gif"
}
//StartAnimation();

function frameloaded() {
	loadcount = loadcount - 1;
	
	return true;
}

function LoadCheck() {
	if (loadcount <= 0) {
		StartAnimation();
	} else {
		setTimeout("LoadCheck()",100);
	}
}

function showframe() {
	document.getElementById(objectid).src = animframes[frame].src;
}

function nextframe() {
	if (frame+1 < animframestotal) {
		frame = frame + 1;
		showframe();
		timer = setTimeout("nextframe();",animspeed);
	}
}

function StartAnimation() {
	document.getElementById(objectid).style.visibility = "visible";
	showframe();
	timer = setTimeout("nextframe();",startdelay);
}