function Sprite(names, x, y, oneshot, divide){
	var i=0;
	var c=0;
	var scene=0;
	var count=names[0].length;
	this.once=oneshot;
	//var div=(divide)? divide:2;
	this.div=(divide)? divide:2;
	var img = new Element('img', {'class': 'spriteimg','src': 'res/images/'+names[i]+'.gif', 'style': 'left:'+x+'px;top:'+y+'px;'});
	var pos=[x,y];
	img.src='res/images/'+names[scene][0]+'.gif';
	Element.insert($('main'), img);
	var z=0;
	this.enabled=true;
	this.once=false;
	this.update=function(){
		if(++c%this.div==0){
			i = (i<count-1)? i+1: 0;
			if(this.once && i==0){
				this.hide();
				//nghosts--;
			}
			else{
				img.src='res/images/'+names[scene][i]+'.gif';
			}
		}
	}
	this.setscene=function(n){
		count=names[n].length;
		scene=n;
		i=0;
		img.src='res/images/'+names[scene][i]+'.gif';
	}
	this.seti=function(i_){
		i=i_;
		img.src='res/images/'+names[scene][i]+'.gif';
	}
	this.getscene=function(){
		return scene;
	}
	this.setz=function(n){
		this.z=n;
		img.style.zIndex=n;
	}
	this.setopacity=function(n){
		Element.setOpacity(div, n);
	}
	this.move=function(x, y){
		pos=translate(x,y);
		img.style.left=pos[0]+'px';
		img.style.top=pos[1]+'px';
	}
	this.moveBy=function(x, y){
		pos[0]+=x;
		pos[1]+=y;
		img.style.left=(pos[0])+'px';
		img.style.top=(pos[1])+'px';
	}
	this.remove=function(){
		img.remove();
	}
	this.hide=function(){
		img.hide();
	}
	this.show=function(){
		img.show();
	}
}
