document.write("<script language='javascript' src='/js/messages.js'></script>");

/*
//  create new window in center of screen
//  param : url   : link string
//          name  : window name
//          width,height : width,height of new window
*/
function centerNewWin(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubars=yes,status=yes';
  var newwin = window.open(url, name, info);
  newwin.focus();
/*  return newwin;*/
}

function centerNewWinBar(url, name) {

  name = name + 'rglinux';

  var width = 816;
  var height = 730;
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'resizable=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes, left=' + (wi/2) + ',top=' + (hi/3) + ',width='  + width + ',height=' + height + '';
  var newwin = window.open(url, name, info);
  newwin.focus();

  /*return newwin;*/
}

function centerNewWM(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',menubar=no,status=yes,resizable=yes,scrollbars=yes';
  var newwin = window.open(url, name, info);
  newwin.focus();
  //return newwin;
}
function centerNewWin1(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',menubar=no,status=no,resizable=no,scrollbars=yes';
  var newwin = window.open(url, name, info);
  newwin.focus();
  //return newwin;
}

function centerNewWin2(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',menubar=no,status=no,resizable=no,scrollbars=auto';
  var newwin = window.open(url, name, info);
  newwin.focus();
  //return newwin;
}
function Newcalendar(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',resizable=no,scrollbars=no,menubars=no,status=no';
  var newwin = window.open(url, name, info);
  newwin.focus();
}

function Newcalendar1(url, name, width, height) {
  var wi = screen.width - width;
  var hi = screen.height - height;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + (wi/2) + ',top=' + (hi/2) + ',width='  + width + ',height=' + height + ',resizable=no,scrollbars=no,menubars=no,toolbar=no, location=no';
  var newwin = window.open(url, name, info);
  newwin.focus();
}
function leftNewWinMain(url, winName, width, height) {
  var wi = 10;
  var hi = 10;

  var info = 'left=' + wi + ',top=' + hi + ',width='  + width + ',height=' + height + ',resizable=no,scrollbars=no,menubars=no,toolbar=no, location=no';
  var newwin = window.open(url,winName,info);
  newwin.focus();
}
function rightNewWinMain(url,winName, width,height) {
  var wi = screen.width - width - 10;
  var hi = 10;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + wi + ',top=' + hi + ',width='  + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubars=no,status=yes';
  var newwin = window.open(url, name,info);
  newwin.focus();
}
/*************************************************************************
  create new window in right-top of screen
  param : url   : link string
          name  : window name
          width,height : width,height of new window
*************************************************************************/
function rightNewWin(url,winName, width,height) {
  var wi = screen.width - width - 10;
  var hi = 10;

  if( wi < 0 ) wi = 0;
  if( hi < 0 ) hi = 0;

  var info = 'left=' + wi + ',top=' + hi + ',width='  + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubars=no,status=yes';
  var newwin = window.open(url, name,info);
  newwin.focus();
}

/*************************************************************************
  create new window in left-top of screen
  param : url   : link string
          name  : window name
          width,height : width,height of new window
*************************************************************************/
function leftNewWin(url, winName, width, height) {
  var wi = 10;
  var hi = 10;

  var info = 'left=' + wi + ',top=' + hi + ',width='  + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubars=no';
  var newwin = window.open(url,'new',info);
  newwin.focus();
}


/************************************************************************************
  check if is only number enterd in input
  event : onkeypress
************************************************************************************/
function isNumber(){
 	if ((event.keyCode<48)||(event.keyCode>57)){
  		event.returnValue=false;
 	}
}

/***********************************************************************************
  move focus to next input when thisTabSize characters enterd
  param : thisTab : object has focus
          nextTab : next object to have focus
          thisTabSize : length of string can enter
  event : onKeyPress
***********************************************************************************/
function tabOrder(thisTab,nextTab, thisTabSize) {
    if (thisTab.value.length == thisTabSize) {
        nextTab.select();
        nextTab.focus();
        return;
     }
}



/*********************************************************************************
   ÄÚµå¸¦ ¼öÁ¤ÇÏ¸é ÀÚµ¿À¸·Î ÄÚµå¸íÀÌ ÃÊ±â ºó »óÅÂ·Î µÇ¾î¾ß ÇÑ´Ù.
   ÀÌ¸¦ À§ÇÑ ÇÔ¼ö ÀÌ´Ù.
   ÀÔ·Â Ç×¸ñ
          - cdObj : ÄÚµå°ªÀ» ÀÔ·ÂÇÑ input °´Ã¼
          - nmObj: ÄÚµå¸íÀ» Ãâ·ÂÇÑ input °´Ã¼
          - cdLength :  ÄÚµå ±æÀÌ
      ÄÚµå±æÀÌ °¡  ÇöÀç ÀÔ·ÂÇÑ ÄÚµå°ªÀÇ ±æÀÌ¿Í °°Áö ¾ÊÀ¸¸é ÄÚµå¸íÀ» Áö¿î´Ù.
   °ü·ÃÀÌº¥Æ® : onKeyUp
*********************************************************************************/
function isFullCode(cdObj, nmObj ,cdLength) {
  if(cdObj.value.length != cdLength) {
    nmObj.value="";
  }
}

/*********************************************************************************
   ÄÚµå¸¦ ¼öÁ¤ÇÏ¸é ÀÚµ¿À¸·Î ÄÚµå¸íÀÌ ÃÊ±â ºó »óÅÂ·Î µÇ¾î¾ß ÇÑ´Ù.
   ÀÌ¸¦ À§ÇÑ ÇÔ¼ö ÀÌ´Ù.
   ÀÔ·Â Ç×¸ñ
          - cdObj : ÄÚµå°ªÀ» ÀÔ·ÂÇÑ input °´Ã¼
          - nmObj: ÄÚµå¸íÀ» Ãâ·ÂÇÑ input °´Ã¼ÀÇ ½ºÆ®¸µ ÀÌ¸§(','·Î ºÐ¸®µÈ´Ù.)
          - cdLength :  ÄÚµå ±æÀÌ
      ÄÚµå±æÀÌ °¡  ÇöÀç ÀÔ·ÂÇÑ ÄÚµå°ªÀÇ ±æÀÌ¿Í °°Áö ¾ÊÀ¸¸é ÄÚµå¸íÀ» Áö¿î´Ù.
   °ü·ÃÀÌº¥Æ® : onKeyUp
*********************************************************************************/
function isFullCode2(cdObj, nmObj ,cdLength) {

  if(cdObj.value.length != cdLength) {
    var nmObjs = nmObj.split(",");
    for(var i = 0; i < nmObjs.length; i++) {
      eval(nmObjs[i]).value="";
    }
  }
}

/***************************************************************************
   Input type="Text"¸¦ µ·¿¡ °ü·ÃµÈ ³»¿ëÀ¸·Î »ç¿ë
   µ·¿¡ '100,000'°ú °°ÀÌ ','À» Ãß°¡ ½ÃÄÑÁØ´Ù.

   Event Handlers : onBlur
   °ü·Ã ÇÔ¼ö : removeFormattedMoney(), isNumber(), util.js::reverse()
   »ç¿ë ¹æ¹ý : onBlur="formattedMoney(this)"
***************************************************************************/
function formattedMoney(v) {
  var format = "";
  var money = v.value;

  money = reverse(money);
  for(var i = money.length-1; i > -1; i--) {
    if((i+1)%3 == 0 && money.length-1 != i) format += ",";
    format += money.charAt(i);
  }
  v.value = format;
  return v.value;
}


/*************************************************************************
   Input type="Text"¸¦ µ·¿¡ °ü·ÃµÈ ³»¿ëÀ¸·Î »ç¿ë
   formattedMoney¿¡¼­ »ç¿ëµÈ ','À» Á¦°Å ½ÃÄÑÁØ´Ù.

   Event Handlers : onFocus
   °ü·ÃÅ¸ÀÔ : text
   °ü·ÃÇÔ¼ö : formattedMoney(), isNumber()
   ¿¹Á¦¹æ¹ý :  onFocus="removeFormattedMoney(this)"
**************************************************************************/
function removeFormattedMoney(v) {
  var unformat = "";
  var money = v.value;
  var arr = money.split(",");
  for(var i = 0; i < arr.length; i++) {
    unformat += arr[i];
  }
  v.value = unformat;
  return v.value;
}


/**********************************************************************************
  ÀÌÇÁ·Î±×·¥Àº ¸®½ºÆ®ÀÇ »ö»ó°ú Ä¿¼­¸¦ º¯Çü½ÃÅ°´Â ±â´ÉÀ» ´ã´çÇÏ°í ÀÖ´Ù.

  °ü·ÃÀÌº¥Æ® : onMouseOver, onMouseOut, onClick

  ex) <tr> ÅÂ±×³ª <td> ÅÂ±×¿¡ ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
      onClick½Ã Æ¯º°ÇÑ Çàµ¿À» ÇÏ±âÀ§ÇØ¼­´Â onClick ¿¡ Ãß°¡ÀûÀ¸·Î ÇÔ¼ö¸¦ È£ÃâÇÏ¸é µÈ´Ù.
      <td onMouseOver='mouseOverCell(this)'
          onMouseOut='mouseOutCell(this)'
          onClick='selectedCell(this)'>Ç×¸ñ</td>
***********************************************************************************/
var prevObj;
var defaultColor    = '#FFFFFF';
var onMouseColor    = '#e9fad4';
var selecctedColor  = '#b9caa4';

function selectedCell(obj) {
  if( prevObj == null ) {
    prevObj = obj;
    prevObj.style.background = selecctedColor;
  }
  else {
    prevObj.style.background = defaultColor;
    obj.style.background = selecctedColor;
    prevObj = obj;
  }
}

function mouseOverCell(obj) {
  if( prevObj != obj ) {
    obj.style.background = onMouseColor;
  }
  obj.style.cursor = 'hand';
}

function mouseOutCell(obj) {
  if( prevObj != obj ) {
    obj.style.background = defaultColor;
  }
  obj.style.cursor = 'auto';
}

/************************************************************************
   Text¿¡ ¿µ¹®ÀÚ ¼Ò¹®ÀÚ¸¦ ´ë¹®ÀÚ·Î ¹Ù²ãÁØ´Ù.
   °ü·Ã ÀÌº¥Æ® : onKeyPress

   »ç¿ë¹ý :
   <input type="text" onKeyPress="toUpperCase()">
************************************************************************/
function toUpperCase() {
  if(!(event.keyCode < 97 || event.keyCode > 122)) {
    event.keyCode -= 32;
    event.returnValue=true;
  }
}

/************************************************************************
   Text¿¡ ¿µ¹®ÀÚ ´ë¹®ÀÚ¸¦ ¼Ò¹®ÀÚ·Î ¹Ù²ãÁØ´Ù.
   °ü·Ã ÀÌº¥Æ® : onKeyPress

   »ç¿ë¹ý :
   <input type="text" onkeyPress="toLowerCase()">
************************************************************************/
function toLowerCase() {
  if(!(event.keyCode < 65 || event.keyCode > 90)) {
    event.keyCode += 32;
    event.returnValue=true;
  }
}


/*********************************************************************
   ÀÌ ÇÔ¼ö´Â ÀÔ·Â ÇÊµå È®ÀÎ½Ã »ç¿ëÇÑ´Ù. ÃÖ½Å¹öÁ¯

   Event Handlers : input, textarea, select
   °ü·Ã Å¸ÀÔ :
   Arguments : vck, title, maxLangth
   ¿¹Á¦ : <input type=text name=aaa value='' vck=1 maxLangth='' title='ÀÌ¸§'>
   Áß¿ä : vck = 1 text, 2 select, 3 radio, 4 check, 5 textarea, 0 ¾øÀ½
   		  title Àº È­¸é¿¡ Ãâ·ÂµÉ ÀÌ¸§
**********************************************************************/

function inCheck(oForm)
{
	/* vck = 1 text, 2 select, 3 radio, 4 check, 5 textarea, 0 nothing    */
	var T;
	if (oForm == null)
		T = eval("document.myform");
	else
		T = eval("document." + oForm);
	var cnt = 0;
	for (i = 0; i < T.length; i++)
	{
		var oT = eval("T.elements[" + i + "]");

		switch (oT.vck)
		{
			case '1' :	 /* text ÀÌ¸é       */
				if (oT.value.length <= 0 )
				{
					alert(oT.title + MSGmustEnter );
					oT.focus();
					return -1;
				}
			  else if(oT.value.length > oT.maxLangth ) {
			    alert(oT.maxLength + MSGbyteLimitExceed );
					oT.focus();
					return -1;
			  }
				break;
			case '2' :	 /*  select ÀÌ¸é      */
				if (oT.selectedIndex == -1)
				{
					alert(oT.title + MSGmustEnter );
					oT.focus();
					return -1;
				}
				break;
			case '3' :	 /*  radio ÀÌ¸é   */

				var oN = eval("document.myform." + oT.name);

				var nck = 0;
				for (j = 0; j < oN.length; j++)
				{
					if (oN[j].checked)
						nck++;

				}
				if (nck == 0)
				{
					alert(oT.title + MSGmustCheckOneMore );
					oT.focus();
					return -1;
				}

				break;
			case '4' :	 /*  checkbox ÀÌ¸é    */

				var N = oT.name.substring(0, oT.name.length-1);
				var oLangth = 0;
				var nck = 0;

				for (j = 0; j < T.length; j++)
				{
					if (T.elements[j].name.indexOf(N) >= 0)
						oLangth++;
				}

				for (j = 0; j < oLangth; j++)
				{
					var oN = eval("document.myform." + N + j);
					if (oN.checked)
						nck++;
				}
				if (nck == 0)
				{
					alert(oT.title + MSGmustCheckOneMore );
					oT.focus();
					return -1;
				}


				break;

			case '5' :	 /* textarea ÀÌ¸é   */
				alert(oT.title + MSGmustEnter );
				if (oT.value == '')
				{
					oT.focus();
					return -1;
				}
				break;
		}
	}
	return 0;

}
/*
    ÇÔ ¼ö : cal_byte(aquery , limit)
    ¼³ ¸í : TextAreaÀÇ Text±æÀÌ¸¦ Á¦ÇÑÇÑ´Ù.
    param : ¿øº»¹®ÀÚ¿­, Á¦ÇÑ±æÀÌ(byte)
    ¸® ÅÏ : boolean
 */
function cal_byte(aquery , limit)
{
	var tmpStr;
	var temp=0;
	var onechar;
	var tcount;
	tcount = 0;

	tmpStr = new String(aquery);
	temp = tmpStr.length;

	for (k=0;k<temp;k++) {
		onechar = tmpStr.charAt(k);

		if (escape(onechar).length > 4) {
			tcount += 2;
		}
		else if (onechar!='\r') {
			tcount++;
		}
	}

	if(tcount > limit) {
		reserve = tcount-limit;
		alert( limit + MSGbyteLimitExceed );
		return -1;
	}
	return 0;
}

function seminarOpen(url) { 
		window.open(url,"seminar","toolbar=no,scrollbars=no,location=no,status=no,width="+1014+",height="+635+",resizable=no") 
}
function seminarOpen2(url) { 
	window.open(url,"seminar","toolbar=no,scrollbars=no,location=no,status=no,width="+800+",height="+646+",resizable=no") 
}
