var PNGAnimation = function(container,filename,suffixFrom,suffixTo,method,width,height){
	this.method = method;
	this.width = width;
	this.height = height;
	this.delayTime = 100;
	this.container = container;
	this.fileName = filename;
	this.images = Array();
	this.image = null;
	this.fromNum = parseInt(suffixFrom);
	this.toNum = parseInt(suffixTo);
	this.imagesLoaded = 0;
	this.imagesToLoad = 0;
	this.cutout = null;
	this.attachCutout = function(cutout){
		this.cutout = cutout;
	}
	this.loadImages = function(){
		var num = this.fromNum;
		while (num != this.toNum){
			this.imagesToLoad++;
			var frame = new Image();
			frame.parent = this;
			frame.onload = function(){
				this.parent.imagesLoaded++;
				this.parent.imageLoadedEvent();
			}
			if (this.toNum >= 10){
				var fileName = this.fileName + addPreZeros(num,2) + ".png";
			}else{
				var fileName = this.fileName + num  + ".png";
			}
			//console.log(fileName);
			frame.src = fileName;
			this.images[this.images.length] = frame;
			if (this.toNum > this.fromNum){
				num++;
			}else if(this.toNum < this.fromNum){
				num--;
			}else{
				//bail out
				break;
			}
		}
		if (this.fromNum == this.toNum){
			this.container.style.position = "relative";
			this.container.style.overflow = "hidden";
			this.container.style.width = this.width + "px";
			this.container.style.height = this.height + "px";
			this.image = new Image();
			this.imagesToLoad++;
			this.image.parent = this;
			this.image.onload = function(){
				this.parent.imagesLoaded++;
				this.parent.imageLoadedEvent();
			}
			this.image.src = this.fileName + ".png";
		}
	}
	this.startLoop = function(){
		switch(this.method){
			case "SwapFromMemory":
				var animator = new SwapImageFromMemory(this);
			break;
			case "CSSDisplay":
				var animator = new SwapImageWithCSSDisplay(this);
			break;
			case "CSSVisibility":
				var animator = new SwapImageWithCSSVisibility(this);
			break;
			case "top":
				var animator = new SwapImageWithTop(this);
			break;
		}
		animator.start();
	}
	this.imageLoadedEvent = function(){
		if (this.imagesLoaded == this.imagesToLoad){
			this.startLoop();
		}
	}
	this.loadImages();
}
