/* load image array */
var images = new Array(16);
images[0] = new Array();
images[1] = new Array();
images[2] = new Array();
images[3] = new Array();
images[4] = new Array();
images[5] = new Array();
images[6] = new Array();
images[7] = new Array();
images[8] = new Array();
images[9] = new Array();
images[10] = new Array();
images[11] = new Array();
images[12] = new Array();
images[13] = new Array();
images[14] = new Array();
images[15] = new Array();
/* set your file names here */
images[0]["url"] = "animation_1.jpg";
images[1]["url"] = "animation_2.jpg";
images[2]["url"] = "animation_3.jpg";
images[3]["url"] = "animation_4.jpg";
images[4]["url"] = "animation_5.jpg";
images[5]["url"] = "animation_6.jpg";
images[6]["url"] = "animation_7.jpg";
images[7]["url"] = "animation_8.jpg";
images[8]["url"] = "animation_9.jpg";
images[9]["url"] = "animation_10.jpg";
images[10]["url"] = "animation_11.jpg";
images[11]["url"] = "animation_12.jpg";
images[12]["url"] = "animation_13.jpg";
images[13]["url"] = "animation_14.jpg";
images[14]["url"] = "animation_15.jpg";
images[15]["url"] = "animation_16.jpg";

/* generates a random number for the animation */
function animationRand() {
	var result = 15;
	result = Math.random() * result;
	result = Math.round(result);
	return result;
}
/* animation function */
function animationRun(images) {
	
	var choosen  = animationRand();
	var img_node = document.getElementById("animation");
	
	img_node.setAttribute("src", "img/animation/"+images[choosen]["url"]);
	window.setTimeout('animationRun(images)',5000);
}
function validaElementoform(elemento,msg)
{
	var objeto = document.getElementById(elemento)
	if(objeto!=null)
	{
		if (objeto.value=='')
		{
			if(msg!='')
			{
				alert(msg);
				objeto.focus();
			}
			return true;
		}
	}
	else
	{
		alert('ocurrio un error')
		return true
	}
	return false
}

window.onload = function(){setTimeout("animationRun(images);",5000)}
