/* Define the number of frames to be used in the animation */

var animationFrames = new Array(10);
var frame = 0;
var runOnce = 0;

function init()
{
  /* Get a reference to the element that will contain the leaves */
  
  /* Fill the empty container with new leaves */
 // for (var i = 0; i < NUMBER_OF_FRAMES; i++) 
  //{
	
	   CreateFrames();
       if (runOnce == 0)
       {
        setTimeout("winking()", 250);
        runOnce = 1;
       }
intervalID = setInterval("winking()", 12000);

  //}
}


/*
	Uses an img element to create each frame of the animation.
*/
function CreateFrames()
{
  /* Start by creating an empty img element */

 // var image = document.createElement('img');
 
  var num = 0;
	for (num = 0; num < 12; num++)
	{
		animationFrames[num] = new Image();
  /* the newly created element */
  animationFrames[num].src = "images/mmeSequence/mme" + num + ".jpg";
   }
 
}



function winking()
{
		document.animation.src = animationFrames[frame].src;
		frame = (frame + 1)%12;
		timeout_id = setTimeout("winking()", 250);
		if (frame == 11)
		{
			document.animation.src = animationFrames[frame].src;
			clearTimeout(timeout_id);
		}
		

	
};

function changeWinkNum(num)
{
		//document.getElementById("animaDiv").style.backgroundImage = "url(" + animationFrames[num].src+")";
		document.animation.src = animationFrames[num].src;
		//alert("did something");
}


