function fncom_chk_strlength_cut(vn_maxlength, vn_str)
{
 var vn_sumlength=0;
 var vn_restr='';
 for(var i= 0;i < vn_str.length; i++)
 {
  if( escape(vn_str.charAt(i)).length > 3 ) { vn_length = 2; }
  else if (vn_str.charAt(i) == '<' || vn_str.charAt(i) == '>') { vn_length = 4; }
  else { vn_length = 1 ; }
  if ( vn_maxlength < (vn_sumlength + vn_length) ) { break; }
  vn_sumlength += vn_length;
  vn_restr += vn_str.charAt(i);
 }
 return (vn_restr);
}

//SELECT -> LAYER변환
function getSelectToLayer(obj,lwidth,href)
{

	obj.style.display = 'none';
	var newsb = obj.id + "_sbj";
	var newid = obj.id + "_tmp";
	var newim = obj.id + "_img";
	var LayerTag = "";
	var objindex=fncom_chk_strlength_cut(22,obj.options[obj.selectedIndex].text);
	LayerTag += "<div  STYLE='position:absolute;cursor:default;z-index:2000;'><TABLE WIDTH='"+lwidth+"' CELLSPACING=0 CELLPADDING=0 border=0 align=center>";
	LayerTag += "<TR HEIGHT=1><TD></TD></TR><TR><TD align=center>";
	LayerTag += "<TABLE BGCOLOR='#FFFFFF' HEIGHT=15 WIDTH=160 CELLSPACING=1 CELLPADDING=0 align=center STYLE='border:1 solid #C0C0C0;line-height:117%;' onmouseover='getSelectLayerOver(this,document.all."+newim+",document.all."+newid+");' onmouseout='getSelectLayerOut(this,document.all."+newim+",document.all."+newid+");'>";
	
	LayerTag += "<TR WIDTH=100% onclick='getSelectSubLayer(document.all."+newid+",document.all."+newsb+");'>";
	LayerTag += "<TD ID='"+newsb+"' WIDTH=95% onblur='getSelectLayerBlur(this);'>" + objindex + "</TD>";
	LayerTag += "<TD ALIGN=RIGHT><IMG ID='"+newim+"' SRC='./skin_img/dot_select.gif' ALIGN=absmiddle STYLE='filter:gray();'></TD></TR>";
	LayerTag += "</TABLE>";

	LayerTag += "<div class=scroll ID='"+newid+"' dir='rtl' STYLE='display:none;border:0 solid #C0C0C0; z-index:2000; height=200;filter=alpha(opacity=80);' BGCOLOR='#FFFFFF'><table cellspacing=0 cellpadding=0 border=0 width=160 height=200><tr><td colspan=3 height=3><img src='skin_img/list_strok.gif' width=160></td></tr><tr><td width=5 background='skin_img/list_strok_r.gif'></td><td align=center><div id=sok STYLE='display:none;border:0 solid #C0C0C0; z-index:2000; height=194; width=150; overflow=auto; background-color:#ffffff;'><TABLE onblur='getSubLayerClose(this);' WIDTH=150 CELLSPACING=0 CELLPADDING=0 border=0>";
	for (var i = 0 ; i < obj.length; i++)
	{
		var objtext=fncom_chk_strlength_cut(22,obj.options[i].text);
		LayerTag += "<TR height=20 onmouseover='getSelectMoveLayer(this);' onmouseout='getSelectMoveLayer1(this);' onclick=\"getSelectChangeLayer(document.all."+obj.id+",document.all."+newid+",document.all."+newsb+",'"+objtext+"','"+obj.options[i].value+"','"+href+"');\" ";
		if (obj.value == obj.options[i].value)
		{
			LayerTag += "STYLE='background:#225588;color:#FFFFFF;'><TD align=left>";
		}
		else {
			LayerTag += "STYLE='background:#FFFFFF;color:#000000;'><TD align=left>";
		}

		LayerTag += obj.options[i].text;
		LayerTag += "</TD><td width=3>&nbsp;</td></TR><tr><td bgcolor=#ffffff background='skin_img/dot.gif'></td><td width=3></td></tr>";
	}
	LayerTag += "</TABLE></div></td><td width=5 background='skin_img/list_strok_l.gif'></td></tr><tr><td colspan=3 height=3><img src='skin_img/list_strok2.gif' width=160></td></tr></table><div>";
	LayerTag += "</TD></TR></TABLE></div><IMG SRC='' WIDTH='"+lwidth+"' HEIGHT=0>";

	document.write(LayerTag);
}

//서브레이어보이기
function getSelectSubLayer(obj,sobj)
{
	if(obj.style.display == 'none')
	{
		sobj.style.background = '#FFFFFF';
		sobj.style.color = '#000000';	
		obj.style.display = 'block';
		document.all.sok.style.display='block';
		obj.focus();
	}
	else {
		sobj.style.background = '#225588';
		sobj.style.color = '#FFFFFF';
		obj.style.display = 'none';
	}
}

//서브레이어체크
function getSelectSubLayer1(obj)
{
	if(obj.style.display != 'none')
	{
		obj.style.display = 'none';
	}
}

//타이틀레이어 MouseOver
function getSelectLayerOver(obj,img,nobj)
{
	if (nobj.style.display == 'none')
	{
		obj.style.border = '1 solid #225588';
		img.style.filter = '';
	}
}

//타이틀레이어 MouseOut
function getSelectLayerOut(obj,img)
{
	obj.style.border = '1 solid #C0C0C0';
	img.style.filter = 'gray()';
}


//서브레이어 MouseOver
function getSelectMoveLayer(obj)
{
	if (obj.style.color == '#000000')
	{
		obj.style.background = '#225588';
		obj.style.color = '#FFFFFF';
	}
}
//서브레이어 MouseOut
function getSelectMoveLayer1(obj)
{
	obj.style.background = '#FFFFFF';
	obj.style.color = '#000000';
}

//새레이어선택
function getSelectChangeLayer(obj,fobj,sobj,text,value,href)
{
	
	fobj.style.display = 'none';
	sobj.innerHTML = '&nbsp;' + text;
	sobj.style.background = '#225588';
	sobj.style.color = '#FFFFFF';
	sobj.focus();
	obj.value = value;
	oBook.GotoPage(obj.value);
}

//타이틀레이어 blur
function getSelectLayerBlur(obj)
{
	obj.style.background = '#FFFFFF';
	obj.style.color = '#000000';
}

//서브레이어 닫기
function getSubLayerClose(obj)
{
	if (obj.style.display != 'none')
	{
		setTimeout("document.all." + obj.id + ".style.display = 'none';" , 200);
	}
}