
var uid = 'ctsarea';
var _tx,_ty;

var mcf = (is.p === 'mac' && is.cr);

var dat = [
	{
		id: uid,	/* ID名 */
		sccol: '#fff',	/* スクロールエリアの色 */
		bgcol: '#666',	/* スクロールエリアのバックグラウンド色 */
		bgimg: {url:'../lib/img/base/little_pluses.png',rep:'repeat',pos:'left top'},
		outfg: 1,
		scfunc: function(x,y,w,h){	/* スクロール完了時にコールされる */
			if(y !== _ty){
				var p = (is.ios) ? 5 : 0;
				y = -y - p;
				$.title.timerTo({'y':y},'easeOutQuad',500,function(){
					var fg = this.easingState();
					if((fg && this.y < p) || !fg){
						_tx = x;
						_ty = y;
						var th = Math.abs(y)+this.h;
						if(th > h)
							this.clipTo(-this.y-p,this.w,this.h-(th-h+p),0);
						else	this.clipTo(-this.y-p,this.w,this.h,0);
					}
				},is.ios);

				if(typeof moveCtrlMenu === 'function')
					moveCtrlMenu(y);
			}
		},
		hidefg:true	/* 移動完了後にスクロールバーを消す */
	}
];



var timeid = null;
var initfg = false;

gg.resize(function(sz){

	var minw = 350;
	var w = sz.w;
	var h = sz.h;
	var id = _etbl[uid];

	$.ctsarea.resizeTo(w,h);
	_sc.resizeArea(id,w,h,(w<minw)?minw:w);
	_sc.moveBarX(id,null,h-(7+1));
	_sc.moveBarY(id,w-(7+1),null);

	if($.ctsmask.getDisplay()){
		$.wait_top.moveToAg((w-16)/2,(h-16)/2);
	}

	if(initfg){

	}

	$.addr.resizeTo(null,h);

	// ブロックの再調整
	_sc.resetBlock(id);
	// スクロールバーの再調整
	_sc.resetScrollBar(id);

	clearTimeout(timeid);
	timeid = setTimeout(function(){

		// 右タイトルを上下左右にスライド
		var x = ((w<minw)?minw:w) - $.title.w;
		var y = _sc.getContentPosition(id).y;
		var h = _sc.getContentSize(id).h;
		var p = (is.ios) ? 5 : 0;
		y = -y - p;
		$.title.timerTo({'x':x,'y':y},'easeOutQuad',500,function(){
			var fg = this.easingState();
			if((fg && this.y < p) || !fg){
				_tx = x;
				_ty = y;
				var th = Math.abs(y)+this.h;
				if(th > h)
					this.clipTo(-this.y-p,this.w,this.h-(th-h+p),0);
				else	this.clipTo(-this.y-p,this.w,this.h,0);
			}
		},is.ios);

		sz.minw = minw;
		if(typeof moveCtrlMenu === 'function')
			moveCtrlMenu(sz);
	},500);

});


function getFirstNode(e)
{
	while(e.nodeType === 3){e = e.nextSibling;}
	return e;
}


function loadStart()
{
	var e;
	
}



gg.ready(function(){

	_etbl = _sc.init(dat);

//$.ctsarea.Show();

	//if(is.ie7under)
	//	console.init();

	gg.$('ctsmask').setAlpha(100);
	if(is.p === 'ipn'){
		$.ctsmask.resizeTo(416,416);
	}
	gg.$('title');
	gg.$('addr');
	gg.$('contentgroup');

	var sz = gg.clientSize();

	var ins = document.createElement('div');
	var img = document.createElement('img');
	ins.setAttribute((is.ie7under)?'className':'class','indc');
	ins.id = 'wait_top';
	img.src = '../lib/img/wait.gif';
	ins.appendChild(img);
	//ins.style.marginLeft = ((sz.w-16)/2)+'px';
	//ins.style.marginTop = ((sz.h-16)/2)+'px';
	$.ctsmask.elm.appendChild(ins);

	var e = gg.$(ins.id);
	//e.setAlpha(0);
	e.moveToAg((sz.w-16)/2,(sz.h-16)/2);

	if(typeof initCtrlMenu === 'function')
		initCtrlMenu();

	initfg = true;

	//console.init();

});

gg.compt(function(){

	setTimeout(function(){
		$.ctsarea.Show();
		$.ctsmask.timerTo({'opacity':0},'swing',1000,function(){
			if(!this.easingState()){
				$.ctsmask.Display(false);
				loadStart();
			}
		});
	},2000);

});

