
//初期化
////////////////////////////////////////////////////////////////////////////

var winHeight;
var winHeightDefault = new Array();
var winAlpha;
var winName;
var winRefer;
var animId;
var anim_flg;

//メイン
////////////////////////////////////////////////////////////////////////////

function winResize( _winId )
{
	winName = _winId;//ウィンドウのIDを入れとく
	winRefer = document.getElementById(_winId);//ウィンドウの参照先を入れとく

	try
	{
		//古いブラウザはさすがに…
		if ( _browser == 'ie' || _browser == 'ie6' || _browser == 'netscape' || _browser == 'otherMozilla' || _browser == 'unknown')
		{
			animNotPlay(_winId);
		}
		else if ( animSelect() )
		{
			
			//閉じているか、開いているかを取得しとく
			if ( winRefer.style.display != 'none' )
			{
				anim_flg = 'open';
				winAlpha = 100;
				winHeightDefault[_winId] = winHeight-2;//ウィンドウのデフォルトを取っておく。-2は仕様。
			}
			else
			{
				anim_flg = 'close';
				winAlpha = 0;
				winRefer.style.display = 'block';//ウィンドウのスタイルをデフォルトに戻しとく
			}
			
			//アニメ再生
			animId = setInterval('animPlay()',5);	
		}
		else
		{
			animNotPlay(_winId);
		}
	}
	catch(e)
	{
		animNotPlay(_winId);		
	}
}



function animSelect()
{
	//高さを取得できるか。出来なければ、アニメーションなしへ。
	try
	{
		winHeight = winRefer.getBoundingClientRect().bottom - winRefer.getBoundingClientRect().top;//ウィンドウの高さを取得		
		return true;
	}
	catch(e)
	{
		try
		{
			winHeight = document.getBoxObjectFor(winRefer).height//ウィンドウの高さを取得	
			return true;
		}
		catch(e)
		{
			if ( winRefer.clientHeight != 0 || winRefer.clientHeight != null )
			{
				winHeight = winRefer.clientHeight;
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}


//アニメーション関数
////////////////////////////////////////////////////////////////////////////
function animPlay()
{
	//開いてるとき
	if ( winHeight >2 && anim_flg == 'open')
	{
		winHeight *= 0.25;
		winRefer.style.height = winHeight +"px";
		
		winAlpha -= 20;
		winRefer.style.filter = 'alpha(opacity='+ winAlpha +')';
		winRefer.style.MozOpacity = winAlpha/100;
		winRefer.style.opacity = winAlpha/100;
		
	}
	else if ( winHeight<= 2 && anim_flg == 'open' )
	{
		winRefer.style.display = "none";				
		winRefer.style.filter = 'alpha(opacity=0)';
		winRefer.style.MozOpacity = 0;
		winRefer.style.opacity = 0;	

		document.getElementById( winName + "_btn").style.backgroundPositionY = "-30px";
		clearInterval( animId );
	}
	//閉じてるとき
	else if ( winHeight< winHeightDefault[winName] - 5 && anim_flg == 'close')
	{
		winHeight += (winHeightDefault[winName] - winHeight)/2 ;
		winRefer.style.height = winHeight+"px";		

		winAlpha += 20;
		winRefer.style.filter = 'alpha(opacity='+ winAlpha +')';
		winRefer.style.MozOpacity = winAlpha/100;
		winRefer.style.opacity = winAlpha/100;
	}
	else if ( winHeight >= winHeightDefault[winName] - 5  && anim_flg == 'close' )
	{
		winRefer.style.height = "auto";		
		winRefer.style.filter = 'alpha(opacity=100)';
		winRefer.style.MozOpacity = 1;
		winRefer.style.opacity = 1;

		document.getElementById( winName + "_btn").style.backgroundPositionY = "0px";
		clearInterval( animId );
	}
	//その他。もしものため
	else
	{
		clearInterval( animId );
	}
}

//アニメーションが再生不能用
function animNotPlay( _winId )
{
	if (document.getElementById(_winId).style.display == "none")
	{
		document.getElementById(_winId).style.display = "block";
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "-30px";
	}
	else
	{
		document.getElementById(_winId).style.display = "none";
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "0px";
	}
}


//他
////////////////////////////////////////////////////////////////////////////

//デフォルト状態
function winResizeDefult( _winId, _defultStatus )
{
	if ( _defultStatus == "close" )
	{
		winResize( _winId );
	}
}

//ロールーオーバー、ロールアウトなど
function winResize_rollover( _winId )
{
	if (document.getElementById(_winId).style.display == "none")
	{
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "-15px";
	}
	else
	{
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "-45px";
	}}

function winResize_rollout( _winId )
{
	if (document.getElementById(_winId).style.display == "none")
	{
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "0px";
	}
	else
	{
		document.getElementById(_winId + "_btn").style.backgroundPositionY = "-30px";
	}
}
