var closeBtnX = 0;
var showCapslock = 0;
var keyInCount = 0;
var checkVar = 0;

function getCookie(strName)
{
  var strArg = new String(strName + "=");
  var nArgLen, nCookieLen, nEnd;
  var i = 0, j;

  nArgLen    = strArg.length;
  nCookieLen = document.cookie.length;

  if(nCookieLen > 0) 
  {
    while(i < nCookieLen) 
    {
      j = i + nArgLen;

      if(document.cookie.substring(i, j) == strArg) 
      {
        nEnd = document.cookie.indexOf (";", j);
        if(nEnd == -1) nEnd = document.cookie.length;
        return unescape(document.cookie.substring(j, nEnd));
      }

      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
    }
  }
  return("");
}


function nextInput(field, nextField, length)
{
	if(length == null || length == "" || length == 0)
	{
		nextField.focus();
		nextField.select();
	}
	else
	{
		if(field.value.length >= length)
		{
			nextField.focus();
			nextField.select();
		}
	}
}

function idSrh()
{
	var fObj = xGetElementById("idsrhFrame");
	fObj.src = "mainapp/id_srh.jsp";
	closeBtnX = 60;
    xLeft("appBg", 0);
    xTop("appBg", 0);	
    xWidth("appBg", xClientWidth());
    xHeight("appBg", xClientHeight());	
    xLeft("idSrhFrameBG", (xClientWidth()/2)-(xWidth("idSrhFrameBG")/2));
    xTop("idSrhFrameBG", (xClientHeight()/2)-(xHeight("idSrhFrameBG")/2));	
	
	xShow("appBg");
	xShow("idSrhFrameBG");
}

function pwSrh()
{
	var fObj = xGetElementById("pwsrhFrame");
	fObj.src = "mainapp/pw_srh.jsp";
	closeBtnX =  72;
    xLeft("appBg", 0);
    xTop("appBg", 0);	
    xWidth("appBg", xClientWidth());
    xHeight("appBg", xClientHeight());	
    xLeft("pwSrhFrameBG", (xClientWidth()/2)-(xWidth("pwSrhFrameBG")/2));
    xTop("pwSrhFrameBG", (xClientHeight()/2)-(xHeight("pwSrhFrameBG")/2));	
	
	xShow("appBg");
	xShow("pwSrhFrameBG");
}

function idSrhClose()
{
    xLeft("appBg", xLeft("appBg")-xClientWidth());
    xTop("appBg", xTop("appBg")-xClientHeight());
    xLeft("idSrhFrameBG", xLeft("idSrhFrameBG")-xClientWidth());
    xTop("idSrhFrameBG", xTop("idSrhFrameBG")-xClientHeight());
    xLeft("pwSrhFrameBG", xLeft("pwSrhFrameBG")-xClientWidth());
    xTop("pwSrhFrameBG", xTop("pwSrhFrameBG")-xClientHeight());
    xLeft("idSrhClose", xLeft("idSrhClose")-xClientWidth());
    xTop("idSrhClose", xTop("idSrhClose")-xClientHeight());

	xHide("appBg");
	xHide("idSrhFrameBG");
	xHide("pwSrhFrameBG");
	xHide("idSrhClose");
}

function resizeDiv() {
	if(xVisibility("appBg") == "visible")
	{
	    xWidth("appBg", xClientWidth());
    	xHeight("appBg", xClientHeight());	
	    xLeft("idSrhFrameBG", (xClientWidth()/2)-(xWidth("idSrhFrameBG")/2));
    	xTop("idSrhFrameBG", (xClientHeight()/2)-(xHeight("idSrhFrameBG")/2));	
	    xLeft("idSrhClose", (xClientWidth()/2)+11);
    	xTop("idSrhClose", (xClientHeight()/2)+(xHeight("idSrhFrameBG")/2)-closeBtnX);	
	    xLeft("pwSrhFrameBG", (xClientWidth()/2)-(xWidth("pwSrhFrameBG")/2));
    	xTop("pwSrhFrameBG", (xClientHeight()/2)-(xHeight("pwSrhFrameBG")/2));	
	}
}
xAddEventListener(window, "resize", function() { resizeDiv() });

function showPrivate()
{
	// 개인정보보호의 날 관련 추가	
	var oWin = window.open("popup/pop_private.html","private","width=430,height=390");
	oWin.focus();
}

function showCyber()
{
    if ( getCookie('dsu_cyber') != "1" )
    {
		// 개인정보보호의 날 관련 추가	
		var oWin = window.open("popup/cyber_popup.html","cyber","width=414,height=420");
		oWin.focus();
		//return true;
	}
}

/*function showIE8()
{
    if ( getCookie('ie8') != "1" )
    {
		// IE8 관련 추가	
		var oWin = window.open("popup/ie8.html","ie8","width=800,height=520,toolbar=0,location=no,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
		oWin.focus();
		//return true;
	}
}
*/
function accountLock()
{
	msg = "5회 연속 잘못된 비밀번호를 입력하셨습니다.\n\n개인정보 보호를 위해 계정이 잠김 처리되었습니다.";
	msg +="\n\n20분간 잠김 설정되며 그 이후 자동 해제 됩니다.";
	msg +="\n\n\n문의 : 정보전산센터(061-330-3814)";
	alert(msg);
}

function accountFail()
{
	msg = "아이디 또는 비밀번호가 올바르지 않습니다. \n\n다시 입력하여 주십시오.";
	alert(msg);
}

function FailMsg(msg)
{
	alert(msg);
}

function OnLogon()
{
	if(document.form1.txtUserID.value == "")
	{
		alert("아이디를 입력하세요.");
		return;
	}
	
	if(document.form1.txtPwd.value == "")
	{
		alert("비밀번호를 입력하세요.");
		return;
	}

	document.form1.submit();
}
	
function focus_password() {
	if (event.keyCode==13) {
		document.form1.txtPwd.focus();
		document.form1.txtPwd.select();
	}
}

function _ieActivex(id)
{
	var _object=id.innerHTML;
	_object = _object.replace("<!--","");
	_object = _object.replace("-->","");
	document.write(_object); id.id="";
}

function HideCapsLockMsg()
{
	 xHide("capslock")
}

function ShowCapsLockMsg()
{
    xLeft("capslock",  (xClientWidth()/2)+100);
   	xTop("capslock", 320);
	keyInCount++;
	if(xVisibility("capslock") == '' || xVisibility("capslock") == 'hidden')
	{
		xShow("capslock");
	}
}

function capsLockCheck(e)
 {
  var keyCode = 0;
  var shiftKey = false;
  keyCode = e.keyCode;
  shiftKey = e.shiftKey;
  if ((keyCode >= 65 && keyCode <= 90) && !shiftKey)
  {
	ShowCapsLockMsg();
  }
}

function checkKeyIn()
{
	if(checkVar == keyInCount && keyInCount > 0 ) 
	{
		if(xVisibility("capslock") == '' || xVisibility("capslock") == 'visible')
		{
			HideCapsLockMsg();
		}
	}
	else 
	{
		checkVar = keyInCount;
	}
}
xAddEventListener(window, "load", function() { setInterval(checkKeyIn, 1000); });
