new function() 
{
    THREAD.anime = function(tar,timer) {
	this.tar = tar;
	if (timer)
	    this.timeout = timer;
	return this;
    }
    THREAD.anime.prototype = {
	div: undefined,	
	tar: undefined,
	parent: undefined,
	all: 10,
	cnt: 0,
	timeout: 100,
	tid: undefined,
	next: undefined,
	cover: false,
//
	go: undefined,
	end: undefined,
//
	self: function(tar)
	{
	    return function() {
		if (tar.go)
		    tar.go.apply(tar,[]);
	    }
	},
	cancel: function()
	{
	    var tid;
	    if (tid = this.tid) {
	        this.tid = undefined;
	        this.alpha = -1;
	        clearTimeout(tid);
	    }
	    if (this.end)
		this.end.apply(this,[]);
	    if (this.next)
		this.next.apply(this,[]);
	},
	treeOpenClose: function(cnt,h,func)
	{
	    this.next = func;
	    this.end = this.tocEnd;
	    this.all = cnt;
	    this.go = this.tocGo;

	    var tree1 = this.tar[0];
	    this.org1 = tree1.getBodyHeight();
	    this.dh1 = (h - this.org1)/cnt;
	    if (tree1 = this.tar[1]) {
	        this.org2 = tree1.getBodyHeight();
	        this.dh2 = this.org2/cnt;
	    }
	    this.go.apply(this,[]);
	},
	tocGo: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    var tree1 = this.tar[0];
	    var h = this.org1 + Math.floor(this.dh1 * this.cnt);
	    tree1.setBodyHeight(h);
	    
	    if (tree1 = this.tar[1]) {
	        h = this.org2 - Math.floor(this.dh2 * this.cnt);
		if (h < 0)
		    h = 0;
	        tree1.setBodyHeight(h);
	    }
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
	tocEnd: function()
	{
	    return;
	},
	tree1OpenClose: function(cnt,h,func)
	{
	    this.next = func;
	    this.end = this.toc1End;
	    this.all = cnt;
	    this.go = this.toc1Go;

	    var tree1 = this.tar;
	    this.org1 = tree1.getBodyHeight();
	    this.dh1 = (h - this.org1)/cnt;
	    this.go.apply(this,[]);
	},
	toc1Go: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    var tree1 = this.tar;
	    var h = this.org1 + Math.floor(this.dh1 * this.cnt);
	    tree1.setBodyHeight(h);
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
	toc1End: function()
	{
	    return;
	},
	openDoor: function(cnt,w,func)
	{
	    this.next = func;
	    this.end = this.odEnd;
	    this.all = cnt;
	    this.go = this.odGo;

	    var div = this.tar[0];
	    this.org1 = div.clientWidth;
	    this.dw = (w - this.org1)/cnt;
	    this.go.apply(this,[]);
	},
	odGo: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    var w = this.org1 + Math.floor(this.dw * this.cnt);
	    var div = this.tar[0];
	    div.style.width = w + 'px';
	    var div = this.tar[1];
	    div.style.left = w + 'px';
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
	odEnd: function()
	{
	    return;
	},
//
	alpha: function(al,cnt,func)
	{
	    this.next = func;
	    this.all = cnt;
	    this.alpha = al;
	    this.beta = undefined;
	    this.da = (al-10)/cnt;
	    this.go = this.alTimer;
	    this.end = this.alTimerEnd;
	    this.go.apply(this,[]);
	},
	beta: function(al,cnt,func)
	{
	    this.next = func;
	    this.all = cnt;
	    this.beta = al;
	    this.da = (10-al)/cnt;
	    this.go = this.alTimer;
	    this.end = this.alTimerEnd;
	    this.go.apply(this,[]);
	},
	alTimer: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    if (this.beta)
	       var al = this.beta + this.da * this.cnt;
	    else {
	       var al = 10 + this.da * this.cnt;
	    }
	    al = Math.floor(al);
	    THREAD.utl.tomei(this.tar,al);
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
	alTimerEnd: function()
	{
	    if (this.beta)
		THREAD.utl.tomei(this.tar,10);
	    else
		THREAD.utl.tomei(this.tar,this.alpha);
	},
	moveResize: function(x1,y1,w1,h1,x2,y2,w2,h2,cnt,func)
	{
	    this.next = func;
	    this.all = cnt;
	    this.div = document.createElement('div');
	    this.div.style.overflow = 'hidden';
	    this.div.style.position = 'absolute';
	    this.div.style.zIndex = 20000;
//	    this.div.style.backgroundColor = 'red';
	    this.mr(x1,y1,w1,h1);
	    this.parent = this.tar.parentNode;
	    this.parent.removeChild( this.tar );
	    this.parent.appendChild( this.div );
	    this.tar.style.visibility = 'visible';
	    this.tar.style.left= '0px';
	    this.tar.style.top= '0px';
	    this.div.appendChild( this.tar );
	    this.cover = true;

	    this.dx = (x2 - x1)/cnt;
	    this.dy = (y2 - y1)/cnt;
	    this.dh = (h2 - h1)/cnt;
	    this.dw = (w2 - w1)/cnt;
	    this.x1 = x1;
	    this.y1 = y1;
	    this.w1 = w1;
	    this.h1 = h1;
	    this.x2 = x2;
	    this.y2 = y2;
	    this.w2 = w2;
	    this.h2 = h2;

	    this.go = this.mrTimer;
	    this.end = this.mrTimerEnd;
	    this.go.apply(this,[]);
	},

	move: function(x1,y1,x2,y2,cnt,func)
	{
	    var w1 = undefined;
	    var h1 = undefined;
	    this.next = func;
	    this.all = cnt;
	    this.div = this.tar;
/*
	    this.div.style.overflow = 'hidden';
	    this.div.style.position = 'absolute';
	    this.div.style.zIndex = 20000;
*/
	    this.mr(x1,y1,w1,h1);
	    this.div.style.visibility = 'visible';
	    this.cover = false;

	    this.dx = (x2 - x1)/cnt;
	    this.dy = (y2 - y1)/cnt;
	    this.dh = undefined;
	    this.dw = undefined;
	    this.x1 = x1;
	    this.y1 = y1;
	    this.x2 = x2;
	    this.y2 = y2;

	    this.go = this.mrTimer;
	    this.end = this.mrTimerEnd;
	    this.go.apply(this,[]);
	},
	mr: function(x,y,w,h,alpha)
	{
	    if (x != undefined)
	        this.div.style.left = x + 'px';
	    if (y != undefined)
	        this.div.style.top = y + 'px';
	    if (w != undefined)
	        this.div.style.width = w + 'px';
	    if (h != undefined)
	        this.div.style.height = h + 'px';
	    if (alpha)
		THREAD.utl.tomei(this.div,alpha);
	},
	mrTimerEnd: function()
	{
		this.mr(this.x2,this.y2,this.w2,this.h2);
	 	if (this.cover) {
		    if (this.tar.parentNode == this.div) {
		        this.div.removeChild ( this.tar )
		        this.parent.removeChild ( this.div )
		    }
		    this.tar.style.left = this.x2 + 'px';
		    this.tar.style.top = this.y2 + 'px';
		    this.parent.appendChild ( this.tar )
		}
	},
	mrTimer: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    if (this.x1 != undefined)
	        var x = this.x1 + Math.floor(this.dx * this.cnt);
	    else
	        var x = undefined;
	    if (this.y1 != undefined)
	        var y = this.y1 + Math.floor(this.dy * this.cnt);
	    else
	        var y = undefined;
	    if (this.dw)
	        var w = this.w1 + Math.floor(this.dw * this.cnt);
	    else
	        var w = undefined;
	    if (this.dh)
	        var h = this.h1 + Math.floor(this.dh * this.cnt);
	    else
	        var h = undefined;
	     var a = undefined;
	    if (this.da) 
		a = this.alpha - this.da * this.cnt;
	    this.mr(x,y,w,h,a);
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
   	goto1: function(x,y,cnt,func)
	{
	    var len = this.tar.length;
	    this.all = cnt;
	    for(var i = 0;i < len;i++) {
		var s = this.tar[i];
		s.org_x = s.x;
		s.org_y = s.y;
		s.hx = x;
		s.hy = y;
		s.dx = (x - s.org_x)/cnt;
		s.dy = (y - s.org_y)/cnt;
	    }
	    this.end = func;
	    this.go = this.g1;
	    this.go.apply(this,[]);
	},
	g1: function()
	{
	    if (this.all <= this.cnt) {
		if (this.end)
		    this.end.apply(this,[]);
		return;
	    }
	    this.cnt++;
	    var len = this.tar.length;
	    for(var i = 0;i < len;i++) {
		var s = this.tar[i];
		var x = Math.floor(s.org_x + s.dx * this.cnt);
		var y = Math.floor(s.org_y + s.dy * this.cnt);
		s.moveTo(x,y);
	    }
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	}
//
	,listOpenClose: function(cnt,func)
	{
	    this.next = func;
	    this.end = this.locEnd;
	    this.all = cnt;
	    this.go = this.locGo;
	    this.cnt = 0;

	    var div = this.tar;
	    if (!div.closed) {	
		var h = div.height = div.org_height = div.clientHeight;
		div.start_height = h;
	        this.dh = (div.min_height - div.start_height) /cnt;
	    } else {
		div.start_height = div.height;
	        this.dh = (div.org_height - div.start_height)/cnt;
	    }
	    this.go.apply(this,[]);
	},
	locGo: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
	    var div = this.tar;
	    div.height = div.start_height + this.dh * this.cnt;
	    if (div.height < div.min_hdight)
	    	div.height  = div.min_hdight;
	    else if (div.org_hehgt < div.height)
	        div.height = div.org_height;
	    div.style.height = Math.floor(div.height) + 'px';
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	},
	locEnd: function()
	{
	    var div = this.tar;
	    if (this.dh < 0) {
	        div.style.height = div.min_height + 'px';
	        div.closed = true;
	        var msg = BBS.menu.list_open;
	    } else {
	        div.style.height = div.org_height + 'px';
	        div.closed = false;
	        var msg = BBS.menu.list_close;
	    }
	    if (div.button)
		div.button.childNodes[0].nodeValue = msg;
	},
	top : function(cnt) 
	{
	    this.end = this.topEnd;
	    this.all = cnt;
	    this.go = this.topGo;
	    this.cnt = 0;

            this.top = document.body.scrollTop;
	    var tl = THREAD.utl.getTL(this.tar);
            var t =  tl[1] - this.top;
	    this.dt = Math.floor(t / cnt);
	    this.go.apply(this,[]);
	},
	topEnd: function()
	{
	    return;
	},
	topGo: function()
	{
	    if (this.cnt == this.all) {
		this.end.apply(this,[]);
	        this.tid = undefined;
	        if (this.next)
	            return this.next(this.tar);
		return;
	    }
	    this.cnt++;
            window.scrollBy(0,this.dt);
	    this.tid = setTimeout(this.self(this),this.timeout);
	    return;
	}
    }
}

