// JavaScript Document
var position=75;//少しだけ上部を開けておく幅
var parsent=300, vector=1;
var minus = position;
var num, timerId, parsent, number, minus, heightArr=new Array();
var flgArr=new Array()
flgArr=[false,false,false];
var areaHeight;
var maxNum = 2;
window.onload = accoding;
function accoding(){
	for(var i=0; i<=maxNum; i++){
		num=i;
		//heightArr=new Array()
		heightArr[num] = document.getElementById("text"+num).scrollHeight;
		toClose(num);
	}
}
function toClose(num){
	//clearTimeout(timerId);
	document.getElementById("open"+num).style.display = "inline";
	document.getElementById("text"+num).style.height = minus+"px";
	document.getElementById("text"+num).style.overflow = "hidden";
	document.getElementById("close"+num).style.display = "none";
	if(flgArr[num]){
		flgArr[num]=false;
		_smoothOpen(num);
	}
}
function toOpen(num){
	document.getElementById("open"+num).style.display = "none";
	document.getElementById("close"+num).style.display = "inline";
	flgArr[num]=true;
	_smoothOpen(num);
}
function _smoothOpen(num){
	numHeight = heightArr[num];
	if(!flgArr[num]){
		maxHeight = 0;
		minus = position;
		vector = -1;
	}else{
		maxHeight = numHeight;
		minus = 0;
		vector = 1;
	}
	smoothOpen();
	function smoothOpen(){
		if(numHeight<=1){
			document.getElementById("text"+num).style.height = maxHeight+minus+"px";
			clearTimeout(timerId);
		}else{
			numHeight*=0.9;
			document.getElementById("text"+num).style.height = ((maxHeight-numHeight)*vector)+minus+"px";
			timerId = setTimeout(smoothOpen, 1);
		}
	}
}

