function Resize(group, height, width) {

  for (var i = 0; i<this.last_image;i++) {
	  this.theImages[i].height = height;
	  this.theImages[i].width = width;
  }
}

function NextImage() {
   //this.num = this.num+1;


   if (this.animation == null) {
	 alert( "animation is null" );
   	 return false;
   }


   this.current_image++;
   this.current_image = this.current_image % this.last_image;

   this.animation.src = this.theImages[ this.current_image ].src;
   //alert( this.animation.src );
}

function NextImage2() {
   //this.num = this.num+1;


   if (this.animation == null) {
	 alert( "animation is null" );
   	 return false;
   }

   if (this.current_image > this.last_image-1) {
         this.current_image = this.first_image;
   }

   this.current_image++;
   this.animation.src = this.theImages[this.current_image-this.first_image].src;
}

function Animate()
{
/*
   if (!confirm("dentro"))
	   return false;
*/
   this.NextImage();

   try
   {
	 this.timeID = setTimeout(MiscelaneoTimeout, this.delay, this);
   }
   catch(e)
   {
 	 alert('Animate Exc ' + e.message);
   }
}

function MiscelaneoTimeout(obj) {
  if (typeof obj == 'undefined') {

 	if (!confirm("MiscelaneoTimeout obj==undefined"))
 		return false;

  }
  else
    //obj.PruebaRecursion();
    obj.Animate();
}

function PruebaRecursion() {

	if (confirm(this.delay)) {

	   try
   		{
			this.timeID = setTimeout(MiscelaneoTimeout, this.delay, this);
		}
		catch(e)
	   {
	 	 alert('PruebaRecursion Exc' + e.message);
	   }
	}
}

function SecuentialImage(imgID, folder, pref, imgType, delay, first_image, last_image) {
	var theImages = new Array();

	this.timeID = null;
	this.imgID = imgID;
	this.folder = folder;
	this.pref = pref;
	this.imgType = imgType;
	this.delay = delay;
	this.first_image = first_image;
	this.last_image = last_image;
	this.current_image = -1;

 	for (var i = 0; i<last_image; i++) {
	  theImages[i] = new Image();
	  theImages[i].src = folder + "/" + pref + (i+first_image) + imgType;
	  //alert(theImages[i].src);
    }

    this.animation = document.getElementById(imgID);

    if (this.animation == null) {
    	this.animation = findElementWithAttribute('img', 'alt', imgID);
	}

    this.theImages = theImages;
    this.Animate = Animate;
    this.Resize = Resize;
    this.PruebaRecursion = PruebaRecursion;
    this.NextImage = NextImage;
    this.num = -1;

    this.allowAnimate = (this.animation != null);

    if (! this.allowAnimate)
    	alert( "animation is null" );

}





