if(!aiviki.anim)
	aiviki.anim = aiviki.Class.create("aiviki.anim");


aiviki.anim.thread = aiviki.Class.create("aiviki.anim.thread")
aiviki.anim.thread.prototype = 
	{
	init:function(){},
	step:function()
		{
		if(this.thread===null)return;
		if(this.run==null)return;
		if(this.run()==false)
			{
			this.stop();
			this.destroy();
			return;
			}
		if(aiviki.debug==false)return;
		this.loadAmount++;
		
		if(this.isSecurity)
			if(this.security<=this.loadAmount)
				if(confirm("超出測試安全限制執行次數!，請確定是否繼續執行?"))
					{
					this.loadAmount=0;
					}else{
					this.stop();
					this.destroy();
					return;
					}
		},
	setDelay:function(sec)
		{
		this.delay=sec;
		},
	start:function(){
		this.loadAmount=0;
    if(this.thread === null)
			this.thread = setInterval(aiviki.bind(this.step,this), this.delay,this);
		},
	stop:function()
		{
		clearInterval(this.thread);
		this.thread=null;
		this.loadAmount=0;
		},
	setSecurityAmount:function(i)
		{
		this.security=i;
		},
	setSecurity:function(b)
		{
		this.isSecurity=b;
		},
	destroy:function(){},
	isSecurity:true,
	security:12,
	loadAmount:0,
	delay:10,
	thread:null,
	threadState:false,
	run:function()
		{
		return false;
		}
	}
