var IMGOver = function(div,ns)
{
	this.img = div;
	this.ns = ns;
	this.org = div.src;
	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
	THREAD.event.addEventListenerBind(div,"mouseout",this,this.out);
}
IMGOver.prototype = {
    img: undefined,
    ns: undefined,
    over: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.img.src = this.ns;
    },
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.img.src = this.org;
    }
}

/*
 * 一瞬だけ光らせる
 */
var IMGOver1 = function(div,ns)
{
	this.img = div;
	this.ns = ns;
	this.org = div.src;
	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
    div.style.cursor = 'pointer';
}
IMGOver1.prototype = {
    img: undefined,
    ns: undefined,
    over: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.img.src = this.ns;

            function bind(tar,func)
            {
                return function()
                {
                    func.apply(tar,[]);
                }
            }
        setTimeout(bind(this,this.out),100);
    },
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.img.src = this.org;
    }
}
var Waku = function(div)
{
	this.div = div;

    /* 取り出す */
	var parent = this.parent = div.parentNode;
    var tl = this.tl = THREAD.utl.getTL(div);
    var size = THREAD.utl.getWindowSize();
    var h = this.height = div.clientHeight;     //
    var w = this.width = div.clientWidth;     //
    parent.removeChild(div);

    /* 枠を切り抜いてクリッピングする */
	var cover = this.cover = document.createElement('div');
    cover.style.position = 'absolute';
    cover.style.width = w + 'px';       /* 同じ幅 */
    var top = (size.h - h)/2;
    cover.style.top = top + 'px';   
    cover.style.overflow = 'hidden';
    cover.appendChild(div);
    div.style.visibility = 'visible';

/*
    if (!THREAD.browser.IE)
        cover.style.border = 'solid 1px black';
*/


    var n = this.anime = new THREAD.anime(this,THREAD.browser.IE ? 0: 40);

    /* 背景のアニメーション準備 */
    n.start_alpha = 2;
    n.end_alpha = 8;
    THREAD.utl.tomei(div,n.start_alpha);

    /* 移動のアニメーション準備 */
    n.start_x = size.w;
    n.end_x = tl[0];
    n.start_h = 3;
    n.end_h = this.height;
    n.start_y = top + h/2 - n.start_h/2;
    n.end_y = top;

    /**/
    document.body.appendChild(cover);

    /* スタート時点に移動する */
    this.moveTo(n.start_x,n.start_y,n.start_h);

//
    n.waku = this;
    n.next = this.next;
    n.go = this.go;
    n.end = this.end;
    n.cnt = 0;
    n.all = THREAD.browser.IE ? 0: 20;
    n.phase = 0;
}
Waku.prototype = {
    start: function()
    {
        this.anime.go();
    },

    /* 元の位置に貼り付け直す */
    moveToOrg: function()
    {
        this.cover.removeChild(this.div);
        document.body.removeChild(this.cover);
        this.parent.appendChild(this.div);

        APP.nuance.resize();
/*
        this.div.style.left = '0px';
        this.div.style.top = '0px';
*/
    },
    /* 移動する */
    moveTo: function(x,y,h) {
        this.cover.style.left = x + 'px';
        this.cover.style.top = y +'px';
        this.cover.style.height = h + 'px';
        this.div.style.top = ( h - this.height)/2   + 'px';
    },
    end: function()
    {
        onresize = APP.nuance.resize;
        if (APP.nuance.init4)
            APP.nuance.init4();
    },
    go: function()
    {
        if (this.cnt == this.all) {
            if (!this.phase++) {
                this.cnt = 0;
                this.all = THREAD.browser.IE ? 4: 10;
                this.waku.cover.style.border = 'none';
            } else {
                this.waku.moveToOrg();
                this.end.apply(this,[]);
                this.tid = undefined;
                THREAD.utl.tomei(this.waku.div,10);
                var child = this.waku.div.childNodes;
                var cnt = child.length;
                for(var i = 0;i < cnt;i++) {
                    if (child[i].nodeName == 'TABLE') {
                        child[i].style.backgroundColor = 'transparent';
                        break;
                    }
                }
                if (this.waku.next)
                    return this.waku.next(this.tar);
                return;
            }
        }
        this.cnt++;
        if (this.phase) {
            var x = this.end_x;
            var y = this.start_y + (this.end_y - this.start_y) * this.cnt/ this.all;
            var h = this.start_h + (this.end_h - this.start_h) * this.cnt/ this.all;
            var a = (this.end_alpha - this.start_alpha) * this.cnt / this.all + this.start_alpha;
            THREAD.utl.tomei(this.waku.div,a);
        } else {
            var x = this.start_x + (this.end_x - this.start_x) * this.cnt/ this.all;
            var y = this.start_y;
            var h = this.start_h;
        }
        this.waku.moveTo(x,y,h);
        this.tid = setTimeout(this.self(this),this.timeout);
    }
}

/*
 * 重ねると別イメージが現れる
 */
var IMGOver2 = function(img,src,href)
{
	this.img = img;             /* 元 img */
	this.src = src;
	this.href = href;

    var div = img.parentNode;

    var d0 = document.createElement('div');
	d0.style.position = 'absolute';
	d0.style.left = '0px';
	d0.style.top = '0px';
	var nimg = document.createElement('img');
	nimg.src = this.src;
	nimg.style.border = '0px';
	nimg.style.width = img.clientWidth + 'px';
	d0.appendChild( nimg );
    THREAD.utl.tomei(d0,0);

	this.imgdiv = d0;

    /* 同じ場所に重ねて描く */
    div.appendChild( d0 );
    
	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
	THREAD.event.addEventListenerBind(div,"mouseout",this,this.out);
	THREAD.event.addEventListenerBind(div,"click",this,this.click);
}

IMGOver2.prototype = {
    current: {},
    div: undefined,
    over: function(evt)
    {
	   THREAD.event.preventDefault(evt);
       THREAD.event.stopPropagation(evt);

	    if (!this.active) {

            this.current.current = this;
            this.active = true;
            this.goIn(this.imgdiv);
            this.x = THREAD.event.getPageX(evt);
            this.y = THREAD.event.getPageY(evt);
        } 
    },
    click: function(evt)
    {
        this.location = this.href;
	    this.out2(evt);
    },    
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.out2(evt);
    },
    out2: function(evt)
    {
       var current = this.current.current;
       if (current && (current == this))
            this.current.current = undefined;

	    var img  = this.imgdiv;
	    this.active = false;
	    this.goOut(img);
    },
    goOut: function(div)
    {
         function xx(div,href)
         {
             return function() {
                THREAD.utl.tomei(div,0);
                if (href)
                    location.href = href;
             }
         }
         var n = new THREAD.anime(div,THREAD.browser.IE ? 0: 10);
         n.alpha(2,THREAD.browser.IE ? 2: 20,xx(div,this.location));
    },
    goIn: function(div)
    {
        var n = new THREAD.anime(div,THREAD.browser.IE ? 0: 10);
        n.beta(2,THREAD.browser.IE ? 2: 20,myfly(this));

                function myfly(my){
                        return function() { 
                            my.fly.apply(my,[]);
                        }
                }
    },
    fly: function()
    {
        var tl = THREAD.utl.getTL(this.imgdiv);
        new Fly(this.x,tl[1])
    }
}

var IMGOver2X = function(img,src,href)
{
	var div = this.img = img;             /* 元 img */
	this.org = img.src;
	this.src = src;
	this.href = href;

	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
//	THREAD.event.addEventListenerBind(div,"mouseout",this,this.out);
	THREAD.event.addEventListenerBind(div,"click",this,this.click);
}

IMGOver2X.prototype = {
    current: {},
    div: undefined,
    over: function(evt)
    {
	   THREAD.event.preventDefault(evt);
       THREAD.event.stopPropagation(evt);

	    if (!this.active) {

            this.current.current = this;
            this.active = true;
            this.img.src = this.src;
            this.x = THREAD.event.getPageX(evt);
        } 
            function bind(tar,func)
            {
                return function()
                {
                    func.apply(tar,[]);
                }
            }
        setTimeout(bind(this,this.out),100);
        this.fly();
    },
    click: function(evt)
    {
        this.location = this.href;
	    this.out2(evt);
    },    
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.out2(evt);
    },
    out2: function(evt)
    {
       var current = this.current.current;
       if (current && (current == this))
            this.current.current = undefined;

	    var img  = this.imgdiv;
	    this.active = false;
        this.img.src = this.org;
    },
    fly: function()
    {
        var tl = THREAD.utl.getTL(this.img);
        new Fly(this.x,tl[1])
    }
}

var IMGOver3 = function(div)
{
	this.div = div;
	var tl 	  = THREAD.utl.getTL(div);
	var tlp   = THREAD.utl.getTL(div.parentNode.parentNode);
	this.orgX = Math.floor(tl[0] - tlp[0]);
	this.orgY = Math.floor(tl[1] - tlp[1]);
	this.orgW = div.clientWidth;
	this.orgH = div.clientHeight;
	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
	THREAD.event.addEventListenerBind(div,"mouseout",this,this.out);
	THREAD.event.addEventListenerBind(div,"click",this,this.click);
}
IMGOver3.prototype = {
    div: undefined,
    over: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.goIn(this.div );
    },
    click: function(evt)
    {
	    this.out2(evt);
    },    
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    this.out2(evt);
    },
    out2: function(evt)
    {
	    return;
    }
    ,goIn: function(div)
    {
        THREAD.utl.tomei(div,2);
        var n = new THREAD.anime(div,20);
        n.beta(2,20);
    }
}
var Fly = function(x,y)
{
    var d0 = this.div = document.createElement('div');
	d0.style.position = 'absolute';
	d0.style.left = x + 'px';
	d0.style.top = y + 'px';
	d0.style.zIndex = 100;

	var img = document.createElement('img');
	img.src = 'img/fly_heart.gif';
	img.style.border = '0px';
	d0.appendChild( img );

    document.body.appendChild( d0 );
    var n = new THREAD.anime2(this,THREAD.browser.IE ? 1: 40);
    n.go = this.go;
    n.end = this.end;
    n.alpha = 10;
    n.all = this.pos.length;
    n.da = (1 - 10)/ n.all;
    n.start_x = x;
    n.start_y = y - 10;
    n.tid = setInterval(n.self(n,n.go),n.timeout);
}

Fly.prototype = {
    pos: [ {x:0,y:0},{x:1,y:5},{x:3,y:9},{x:8,y:10},{x:10,y:6},{x:5,y:7},{x:6,y:12},{x:9,y:14},{x:14,y:15} ],
    end: function()
    {
    },
    go: function()  /* Fly */
    {
        if (this.cnt == this.all) {
            if (this.tid)
                clearInterval(this.tid);
            this.tid = undefined;

            this.end.apply(this,[]);
            var div = this.tar.div;
            div.parentNode.removeChild(div);
            if (this.next)
                return this.next(this.tar);
            return;
        }
        var pos = this.tar.pos[this.cnt++];
        this.tar.div.style.left= this.start_x + pos.x + 'px';
        this.tar.div.style.top= this.start_y  - pos.y + 'px';
        var al = this.alpha + this.da * this.cnt;
        al = Math.floor(al);
        THREAD.utl.tomei(this.tar.div,al);
    },
    next: function()    /* Fly */
    {
    }
}

var Intro = function(div) {

    this.div = div;

    for(var i = 0;i < this.pageMax;i++) {
        var img = new Image();
        img.src = this.pages[i];
    }

    var n = this.anime = new THREAD.anime(this,THREAD.browser.IE ? 0: 40);
    n.next = this.next;
    n.go = this.go;
    n.end = this.end;
    n.all = THREAD.browser.IE ? 3: 20;
    n.beta = 1;
    n.alpha_start = 1;
    n.da = (10 - n.alpha_start)/n.all;
    this.start();
};
Intro.prototype = {
    pages: [
        'img/back01.jpg',
        'img/back02.jpg',
        'img/back05.jpg',
        'img/back03.jpg',
    ],
    currentPage: 0,
    pageMax: 4,
    start: function()
    {
        this.div.src = this.pages[this.currentPage];
        APP.nuance.resize();
        this.div.style.visibility = 'visible';
        THREAD.utl.tomei(this.div,this.anime.alpha_start);
        this.restart();
    },
    restart: function()
    {
        var n = this.anime;
        n.cnt = 0;
        n.go();
    },
    restart2: function()
    {
        APP.nuance.resize();
        THREAD.utl.tomei(this.div,this.anime.alpha_start/2);

            function bind(tar,func)
            {
                return function()
                {
                    func.apply(tar,[]);
                }
            }
        setTimeout(bind(this,this.restart),this.timeout * 2);
    },
    go: 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.alpha_start + this.da * this.cnt;
        } else {
           var al = 10 - this.da * this.cnt;
        }
        al = Math.floor(al);
        THREAD.utl.tomei(this.tar.div,al);
        this.tid = setTimeout(this.self(this),this.timeout);
    },
    next: function(tar)
    {
            function bind(tar,func)
            {
                return function()
                {
                    func.apply(tar,[]);
                }
            }
        var intro = tar;
        if (this.beta && intro.currentPage == intro.pageMax - 1) {
            /* 終わり */
            var waku = APP.nuance.waku;
            if (waku) {
                this.tid = setTimeout(bind(waku,waku.start),2000);
            }
            APP.nuance.wakuBeta();
            return;
        }
        if (intro.currentPage < intro.pageMax) {
            if (this.beta) {
                /* フェイドアウト */
                this.beta = false;
                this.tid = setTimeout(bind(intro,intro.restart),1000);
                return;
            }
            this.beta = true;
            if (intro.currentPage++ < intro.pageMax) {
                intro.div.src = intro.pages[intro.currentPage];
                if (THREAD.browser.IE)
                    this.tid = setTimeout(bind(intro,intro.restart2),1000);
                else
                    this.tid = setTimeout(bind(intro,intro.restart),1000);
                return;
            } 
        }
    },
    end: function()
    {
        if (this.beta)
            THREAD.utl.tomei(this.tar.div,10);
        else
            THREAD.utl.tomei(this.tar.div,0);
    }
};

var APP = {};

new function() 
{
    APP.nuance  = {
	middle: 0,
	init: function()
	{
	},
	init2: function()
	{
        if ((navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || 
            (navigator.userAgent.indexOf('iPod') > 0) || 
            (navigator.appVersion.indexOf('iPod') > 0) || 
            (navigator.userAgent.indexOf('webkit') > 0 && navigator.userAgent.indexOf('mobile') > 0 ) || 
            (navigator.userAgent.indexOf('BlackBerry') > 0) || 
            (navigator.userAgent.indexOf('Android') > 0)) {
            APP.isSmartPhone = true;
            window.scrollTo(0,1);
        }
        //APP.isSmartPhone = true;
        if (location.href.match(/index.html/))
            APP.nuance.isTop = true; 
        /* コンテンツ領域の初期化 */
        var waku = APP.nuance.contents = document.getElementById('waku');
        if (waku) 
            APP.nuance.waku = new Waku(waku);

        APP.nuance.waku.next = APP.nuance.start3;

        /* 背景チェック */
        var backImage = APP.nuance.backImage = document.getElementById('back_img');
        if (backImage) {
            if(navigator.cookieEnabled == true){
                function getCookie(name) {
                    var regexp = new RegExp('; ' + name + '=([^;]*);');
                    var match  = ('; ' + document.cookie + ';').match(regexp);
                    if (match) 
                        return match[1];
                    return null;
                }
                if (getCookie("intro")  != "done") {
                    document.cookie = "intro=done";
                    new Intro(backImage);
                    return;
                }
            }
            /* ランダムに貼る */
            var bgimages = APP.nuance.bgimages;
            var cnt = bgimages.length;
            var url;
            if (location.href.match(/index.html/))
                url = bgimages[2];
            else if (location.href.match(/concept.html/))
                url = bgimages[4];
            else if (location.href.match(/menu.html/))
                url = bgimages[1];
            else
                url = bgimages[ Math.floor(Math.random() * 100 %  cnt)];
            backImage.src = url;
            THREAD.utl.tomei(backImage,0);
            APP.nuance.resize();

            /* １発背景 */
            if (backImage) {
                function xxx(waku){
                        return function() { 
                            if (waku)
                                 waku.start();
                        }
                }
                var n = new THREAD.anime(backImage,THREAD.browser.IE ? 0: 10);
                n.beta(2,THREAD.browser.IE ? 4: 20,xxx(APP.nuance.waku));
            }
        } else {
            /* 背景が存在しない場合 */
            document.body.style.backgroundImage = 'url('+url+')';
        }
        APP.nuance.wakuBeta();
    },
	wakuBeta: function()
    {
        var waku2 = document.getElementById('waku_font2');
        if (waku2) 
            APP.nuance.alpha(waku2); 

        /* 上段メニューの初期化 */
        APP.nuance.initMenu() ;

        /* ページの追加処理 */
        if (APP.nuance.init3)
            APP.nuance.init3();

        if (!APP.nuance.waku) 
            onresize = APP.nuance.resize;
	},

    /* 上段メニューの初期化 */
    initMenu: function() 
    {
        /* メニュー */
	    var imgs = document.getElementsByTagName("img");
	    if (imgs) {
		   var cnt = imgs.length;
		   var menu1 = [];
		   var menuov = [];
		    for(var i = 0;i < cnt;i++) {
                menu1.push(imgs[i]);
            }
            cnt = menu1.length;
		    for(var i = 0;i < cnt;i++) {
		        var img1 = menu1[i];
                if (img1.className != 'menu1') {
                    if (img1.className == 'menuov') 
                        menuov.push(img1);
                    continue;
                }
                var parent = img1.parentNode;   /* a */
                parent.removeChild(img1);
                var div;
                parent.appendChild(div = document.createElement('div'));
                div.style.position = 'relative';
                div.style.width = 'auto';
                div.style.padding = '0px';
                div.style.margin = '0px';
                div.appendChild(img1);
//                var ns = img1.src.replace(/.gif/,'_b.gif');
                var ns = img1.src.replace(/.png/,'_2.png');
			    new IMGOver2X(img1,ns,parent.href);
		    }
            cnt = menuov.length;
		    for(var i = 0;i < cnt;i++) {
		       var img1 = menuov[i];
               var ns = img1.src.replace(/.png/,'_2.png');
               new IMGOver1(img1,ns);
            }
		}
    },
	alpha: function(td)
    {
	    var div0 = this.cover = document.createElement('div');
        div0.style.position = 'relative';
        div0.style.backgroundColor = 'transparent';
        td.insertBefore(div0,td.childNodes[0]);

	    var back = this.cover = document.createElement('div');
        back.className = 'font2_mask';
        back.style.width = td.clientWidth + 'px';
        back.style.height = td.clientHeight + 'px';
        back.style.backgroundColor = '#ffffff';
        back.style.position = 'relative';
	    var div = this.cover = document.createElement('div');
        div.style.padding = '20px';
        div.style.width = td.clientWidth - 40 + 'px';
        div.style.height = td.clientHeight - 40 + 'px';
        div.style.backgroundColor = 'transparent';
        div.style.position = 'absolute';
        div.style.left = '0px';
        div.style.top = '0px';
        td.style.backgroundColor = 'transparent';
        td.style.padding = '0px';

        div0.appendChild(back);
        div0.appendChild(div);
        var cnt = td.childNodes.length;
        for(var i = 1; i < cnt;i++) {
            var d1 = td.childNodes[1];
            td.removeChild(d1);
            div.appendChild(d1);
        }

        /* table の背景も 50% 透過にする */
        var waku2 = document.getElementById('waku1');
        if (waku2) 
            waku2.style.backgroundImage = 'url(/2011/img/waku_left_top_50.png)';
        if (waku2 = document.getElementById('waku1_ue'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_top_50.png)';
        if (waku2 = document.getElementById('waku2'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_right_top_50.png)';
        if (waku2 = document.getElementById('waku1_left'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_left_50.png)';
        if (waku2 = document.getElementById('waku2_right'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_right_50.png)';
        if (waku2 = document.getElementById('waku4'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_left_bottom_50.png)';
        if (waku2 = document.getElementById('waku3_bottom'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_bottom_50.png)';
        if (waku2 = document.getElementById('waku3'))
            waku2.style.backgroundImage = 'url(/2011/img/waku_right_bottom_50.png)';
    },

    /*
     * リサイズ処理
     */
	resize: function()
    {
        var backImage = APP.nuance.backImage;

        var div = backImage.parentNode;     /* 背景エリア div */

        var size = THREAD.utl.getWindowSize();
        size.h -= 10;
        var left = 0;
        var top = 0;
        if (size.h/size.w >= 1072/1600) {   /* 縦長 */
            var hi = size.h/1072;
            left = 1600 * hi - size.w;
        } else {    /* 横長 */
            var hi = size.w/1600;
            top = 1072 * hi - size.h;
        }
        backImage.style.width  = 1600 * hi + 'px';
        backImage.style.height = 1072 * hi + 'px';
        backImage.style.left  =  (-left/2)+ 'px';
        backImage.style.top = (-top/2) + 'px';

        div.style.display = 'block';
        div.style.width = size.w + 'px';
        div.style.height = size.h + 'px';

        var cover = APP.nuance.cover;
        if (cover && THREAD.browser.IE && (THREAD.browser.IE < 8)) {
            var size = THREAD.utl.getWindowSize();
            cover.style.height = size.h + 'px';
        }
        var contents = APP.nuance.contents;
        if (contents) {
            var top = (size.h - contents.clientHeight)/2;
            contents.style.position = 'absolute';
            contents.style.top = top + 'px';
        }
        var dialog = APP.nuance.dialog;
        if (dialog) {
            var div = dialog.detail;
            if (APP.isSmartPhone) {
                div.style.position = 'absolute';
                div.style.top = '1px';
                div.style.left = '0px';
            } else {
                var top = (size.h - div.clientHeight)/2;
                var left = (size.w - div.clientWidth)/2;
                div.style.position = 'absolute';
                div.style.top = top + 'px';
                div.style.left = left + 'px';
            }
        }
    },
    /*
     * 背景一覧
     */
    bgimages: [
        'img/back01.jpg',
        'img/back02.jpg',
        'img/back03.jpg',
        'img/back04.jpg',
        'img/back05.jpg',
        'img/back06.jpg',
        'img/back07.jpg',
        'img/back08.jpg',
        'img/back09.jpg',
        'img/back10.jpg',
        'img/back11.jpg'
    ]
    }

    onload = APP.nuance.init2;

/*
    var cnt = APP.nuance.bgimages.length;
    for(var i = 0;i < cnt;i++) {
        var img = new Image();
        img.src= APP.nuance.bgimages[i];
    }
*/
}

var CtlTip = function(target,div)
{
    if (div.parentNode)
        div.parentNode.removeChild(div);

    this.div = div;
    this.div.style.zIndex = 19;
    this.target = target;
}
CtlTip.prototype = {
    close: function()
    {
        var p = this.div.parentNode
        if (p)
            p.removeChild(this.div);
    },
    start: function(oksize)
    {
	    var target = this.target;
	    var div = this.div;
        var tl = THREAD.utl.getTL(target);

        div.style.visibility = 'hidden';
        document.body.appendChild(div);

        if (!oksize) {
            this.target.style.height = this.target.clientHeight + 'px';
            this.target.style.width = this.target.clientWidth + 'px';
        }
        this.target.style.overflow = 'visible';

        this.top  = tl[1] + target.clientHeight - div.clientHeight;
        this.left = tl[0] + target.clientWidth;
        div.style.top = this.top + 'px';
        div.style.left = this.left - div.clientWidth + 'px';

        div.style.left = this.left - div.clientWidth + 'px';
        div.style.top = this.top + 'px';
        div.style.visibility = 'visible';

        var anime = new THREAD.anime(div,THREAD.browser.IE ? 0: 40);
        anime.move(this.left-div.clientWidth,this.top,this.left,this.top,
            THREAD.browser.IE ? 2: 10,bind(this,this.end));

        function bind(tar,func) {
            return function() {
                func.apply(tar,[]);
            }
        }
    },
    end: function()
    {
        var tl = THREAD.utl.getTL(this.target);
        var h = this.div.clientHeight;
        this.div.parentNode.removeChild(this.div);
        this.div.style.left = this.target.clientWidth + 'px';
        this.div.style.top =  (this.target.clientHeight - h) + 'px';
        this.div.style.zIndex = 100;
        this.target.appendChild(this.div);
        THREAD.utl.tomei(this.target,10);
    }
}

var IMGAlpha = function(div)
{
	this.div = div;
	THREAD.event.addEventListenerBind(div,"mouseover",this,this.over);
	THREAD.event.addEventListenerBind(div,"mouseout",this,this.out);
}
IMGAlpha.prototype = {
    img: undefined,
    ns: undefined,
    over: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    THREAD.utl.tomei(this.div,5);
    },
    out: function(evt)
    {
	    THREAD.event.preventDefault(evt);
        THREAD.event.stopPropagation(evt);
	    THREAD.utl.tomei(this.div,10);
    }
}

