/* -------------------------------------
사용 방법
minHeight// 높이를 설정한다. (설정값은 마이너스(-)로 잡으면된다.)
만약 열어놓은 상태로 시작하려면 temHeight를 0으로 바꾸고 
State = "max"로 놓은다음 실행화면에서 cutInit 스크립트 실행을 하지 않으면 된다.
 ------------------------------------- */
var maxHeight = 0;
var minHeight = -174;
var intervalId;
var tmpHeight = minHeight;
//var tmpHeight = 0;
var expandFlag = true;
var iframeObj;
var State = "min";
//var State = "max";
var iframeObj = document.getElementById("menu");

function cutInit()
{
	try
	{
		iframeObj = document.getElementById("menu");

		if (State == "min")
		{
			tmpHeight = minHeight;
			iframeObj.style.top = minHeight+'px';
			expandFlag = false;
		}

	} catch (e) {}
}


function top_slide_menu()
{
	if (State == "min")
	{
		stockExpand();
	}
	else
	{
		stockCut();
	}
}


function stockExpand()
{
	if( !expandFlag )
	{
		expandFlag = true;
		clearInterval(intervalId);
		intervalId = setInterval("expandFinal()",15);
	}
}

function expandFinal(){
	try 
	{
		tmpHeight +=(maxHeight - tmpHeight)/13; 
		tmpHeight ++;
		iframeObj.style.top = tmpHeight+'px';

		if (maxHeight < tmpHeight) 
		{
			clearInterval(intervalId);
			iframeObj.style.top = maxHeight+'px';
			tmpHeight = maxHeight;
			State = "max";
		}
	} 
	catch (err) 
	{
		expandFinal();
		alert("확장실패 : " + iframeObj.height);
	}
}

function stockCut()
{
	if( expandFlag )
	{
		expandFlag = false;
		clearInterval(intervalId);
		intervalId = setInterval("cutFinal()",15);
	}
}

function cutFinal(){
	try
	{
		tmpHeight -=(tmpHeight - minHeight)/13;
		tmpHeight--;
		iframeObj.style.top = tmpHeight+'px';

		if ( minHeight > tmpHeight ) 
		{
			clearInterval(intervalId);
			iframeObj.style.top = minHeight+'px';
			tmpHeight = minHeight;
			State = "min";
		}
	}
	catch (err)
	{
		cutFinal();
		alert("축소실패 : " + iframeObj.height);
	}
}
