// <script type="text/javascript" src="/js/prototype.js"> 프레임워크 적용

function resizeFrame(frameName)
{
	var targetFrame = $(frameName);
	var targetBody	= eval(frameName+".document.body");
	targetFrame.style.height = targetBody.scrollHeight + (targetBody.offsetHeight - targetBody.clientHeight);
}

function comboClear(idName)
{
	var obj = document.getElementById(idName);
	for (var i = obj.length - 1; i >= 0; i--)
	{
		obj.options[i] = null;
	}
}

function comboInsert(idName, key, val)
{
	var obj = document.getElementById(idName);
	obj.options[obj.length] = new Option(key, val);
}

function comboUpdate(idName, key, val)
{
	var obj = document.getElementById(idName);
	for (var i = 0; i < obj.length; i++)
	{
		if (obj.options[i].value == val)
		{
			obj.options[i].text = key;
		}
	}
}

function comboDelete(idName, val)
{
	var obj = document.getElementById(idName);
	for (var i = 0; i < obj.length; i++)
	{
		if (obj.options[i].value == val)
		{
			obj.options[i] = null;
		}
	}
}

function resizeCenter(w, h)
{
	window.resizeTo(w, h + 20);
	var c_x = (screen.availWidth	- w) / 2;
	var c_y = (screen.availHeight - h) / 2;
	window.moveTo(c_x, c_y);
}

function resizeWindow(w, h)
{
	window.resizeTo(w, h + 20);
}

function resizeFull()
{
	self.moveTo(0, 0);
	self.resizeTo(screen.availWidth, screen.availHeight);
}

function exchangeOption(opt1, opt2)
{
	var tmp1, tmp2;

	tmp1 = opt1.value;
	tmp2 = opt1.text;

	opt1.value = opt2.value;
	opt1.text = opt2.text;

	opt2.value = tmp1;
	opt2.text = tmp2;
}

// 메세지 경고창
function show_info(msg)
{
	alert(msg);
}

// id Tag 영역 숨기고 보이게
function showManagePane(paneName)
{
	var obj = $(paneName).style;
	if (obj.display == "inline" || obj.display == "")
	{
		obj.display = "none";
	}
	else
	{
		obj.display = "inline";
	}
}

// 팝업창 간소화 : openWin(url, name, width, height, scroll)
function openWin(url, name, width, height, scroll)
{
  window.open(url, name, 'scrollbars='+scroll+', width='+width+', height='+height+'');
}

function moveCenter()
{
  var w = document.body.offsetWidth;
  var h = document.body.offsetHeight;
  var c_x = (screen.availWidth  - w)  / 2;
  var c_y = (screen.availHeight - h) / 2;
  window.moveTo(c_x, c_y);
}

// 레이어 닫기
function closeLyr(id)
{
  $(id).style.display = "none";
}

// 레이어 오픈
function openLyr(id)
{
  $(id).style.display = "inline";
}

// 입력글자수 제한(textarea)
// frm: 폼네임, name:textarea name, limit_str : 제한 글자수
function checkLength(frm, name, limit_str)
{
  var target = eval("$(frm)."+name+".value.length");

  idCurLen.innerHTML = target;
  if (target > limit_str)
  {
		var keycode = window.event.keyCode;
		if (keycode == 8 || keycode == 46) return;
		alert(limit_str+"자 이내로 작성해주세요~");
		return;
  }
}

// 경고창 출력후 해당 폼으로 포커싱
// 사용예: return err(member.user_id, "회원 아이디 중복 검사를 먼저 하십시오.");
function err(frm, text)
{
  if (text != "")
  {
    window.alert(text);
  }
  if (frm != "")
  {
    frm.focus();
  }
  return false;
}


// 임시(포토리뷰등에서 쓰이는 드림위버 온로드 이벤트
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    return '';
}

function doPopup(url, nWidth, nHeight, scrollbarsYesNo) {
	window.open(url, '_blank', 'width='+nWidth+',height='+nHeight+',scrollbars='+scrollbarsYesNo);
}
