

// Object °ªÀÌ nullÀÎÁö¸¦ °Ë»ç
// ÀÔ·Â °ª : Object ¶Ç´Â value
// ¸®ÅÍ °ª : boolean

function isNull ( ObjVal )
{
	var inValue = null;
	if ( isObject(ObjVal))
	{
		inValue = ObjVal.value;
	}
	else
		inValue = ObjVal;

   if (inValue == null || inValue == "")
      return true;

   return false;
}

// ObjectÀÎ°¡¸¦ °Ë»çÇÑ´Ù.
// ÀÔ·Â °ª : Object
// ¸®ÅÍ °ª : boolean
function isObject ( obj )
{
   if (obj)
      return true;
   else
      return false;
}

// select box¿¡ ÀÔ·ÂµÈ °ªÀÌ ÀÚµ¿À¸·Î ¼±ÅÃµÇ°Ô ÇÑ´Ù
// ÀÔ·Â °ª : select box Object,  selected value
// ¸®ÅÍ °ª : void
function SelectPreOption ( SelectFormName, SelectedValue )
{
   for ( var i=0; i < SelectFormName.options.length; ++i )
   {
      if ( SelectFormName.options[i].value == SelectedValue )
      {
         SelectFormName.options[i].selected = true;
         break;
      }
   }
}

// Radio Box¿¡ ¼±ÅÃµÈ °ªÀÌ ÀÚµ¿À¸·Î ¼±ÅÃµÇ°Ô ÇÑ´Ù.
// ÀÔ·Â°ª : radiobox Objcet, checked value
// ¸®ÅÏ°ª : void
function PreRadioCheck( RadioName, preValue)
{
	for(var i=0;i<RadioName.length;i++)
	{
		if(RadioName[i].value==preValue)
		{
			RadioName[i].click();
		}
	}
}

function CheckPre ( CheckboxName )
{
   CheckboxName.click();
   CheckboxName.disabled;
}


// ÀÔ·ÂµÈ ³¯Â¥ Çü½ÄÀÌ ¿Ã¹Ù¸¥Áö¸¦ °Ë»çÇÏ°í, Á¤È®ÇÑ ³¯Â¥ÀÎÁö °Ë»çÇÑ´Ù.
// ÀÔ·Â °ª : ³¯Â¥ Çü½ÄÀÇ String
// ¸®ÅÍ °ª : boolean

function checkDate(strDate)
{
   
   var arrDate;
   var chkDate
	var Del = "/-.";

	if (IsNumeric(strDate) == true || strDate.length == 8)
	{
		arrDate = new Array(3);
		arrDate[0] = strDate.substring(0,4);
		arrDate[1] = strDate.substring(4,6);
		arrDate[2] = strDate.substring(6,8);
	}
	else
	{
		for (var i=0; i<Del.length; ++i)
		{
			if (strDate.indexOf(Del.charAt(i)) >= 0)
			{
				arrDate = strDate.split(Del.charAt(i));
			}
		}
	}

/*
   if (strDate.indexOf("-") != -1) {
      arrDate = strDate.split("-");
   }
   else {
      arrDate = strDate.split("/");
   }
*/   

   if (arrDate.length != 3) {
      return false;
   }
   chkDate = new Date(arrDate[0] + "/" + arrDate[1] + "/" + arrDate[2]);
   
   if (isNaN(chkDate) == true ||
      (arrDate[1] != chkDate.getMonth() + 1 || arrDate[2] != chkDate.getDate())) {
      return false;
   }
   
   return true;
}


// ¹®ÀÚ¿­¿¡¼­ Æ¯Á¤ ¹®ÀÚ¿­¸¦ Ã£¾Æ¼­ ´Ù¸¥ ¹®ÀÚ¿­·Î º¯°æÇÑ´Ù..
// ÀÔ·Â °ª : OrgStr-ÀÔ·Â ¹®ÀÚ¿­, Target-º¯°æ´ë»ó¹®ÀÚ¿­, Change-º¯°æ¹®ÀÚ¿­
// ¸®ÅÍ °ª : String-º¯°æµÈ ¹®ÀÚ¿­

function replaceText ( OrgStr, Target, Change )
{
	var index, len=0;
	var fullStr = '';

	while ( (index=OrgStr.indexOf(Target)) >= 0) 
	{
		fullStr = fullStr + ''+ OrgStr.substring(0,index) + ''+Change ;

		OrgStr = OrgStr.substring(index+Target.length);
	}
	return fullStr+''+OrgStr;
}


// ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¿Ã¹Ù¸¥Áö °Ë»ç
// ÀÔ·Â °ª : ÀÌ¸ÞÀÏ ÁÖ¼Ò
// ¸®ÅÍ °ª : boolean
function checkEmail(strEmail) {   
   var arrMatch = strEmail.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
   if (arrMatch == null) {
      return false;
   }

   var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
   if (arrIP != null) {
      for (var i = 1; i <= 4; i++) {
         if (arrIP[i] > 255) {
            return false;
            }
         }
   }
   return true;
}

// String ÀÇ ±æÀÌ¸¦ °è»êÇÑ´Ù. ÇÑ±ÛÀÌ¸é 2°³.
// ÀÔ·Â °ª : Object(textarea, text ...), Çã¿ëÃÖ´ë±æÀÌ, ÇÊµå (Á¦¸ñ, ³»¿ë ...etc)
// ¸®ÅÍ °ª : boolean

function CheckStrLen(obj, MaxLen, FieldName) {
   var i, len=0;

   if (!obj) {
      alert('°´Ã¼°¡ Á¤ÀÇµÇÁö ¾Ê¾Ò½À´Ï´Ù.');
      return false;
   }

   var s = obj.value;
   
   // String ±æÀÌ¸¦ ±¸ÇÏ´Â ºÎºÐ..
   for(i=0;i < s.length; i++) 
      (s.charCodeAt(i) > 255)? len+=2:len++;
   
   // ±æÀÌ È®ÀÎ.   
//alert(len);
   if (MaxLen < len) {
      if (FieldName != "") alert("'"+FieldName + "' ÀÇ ÃÖ´ë ÀÔ·Â ±æÀÌ´Â " + MaxLen + "ÀÚ ÀÔ´Ï´Ù. (ÇÑ±ÛÀº ±ÛÀÚ´ç 2ÀÚ·Î °è»êµË´Ï´Ù.)\n      ÀÔ·ÂµÈ ±ÛÀº ["+len+"]ÀÚ ÀÔ´Ï´Ù.");
//      obj.focus();
      return false;
   }
   return true;
}


// StringÀÌ Á¦ÇÑ ±æÀÌ¸¦ ³Ñ¾î¼­¸é ±× ³ª¸ÓÁö¸¦ trimÇØ ¹ö¸°´Ù
// ÀÔ·Â °ª : String, ÃÖ´ë±æÀÌ
// ¸®ÅÍ °ª : String
function Trim(strSrc, intMaxLen) {
   var i;
   var intLen = 0;
   
   for (i = 0; i < strSrc.length; i++) {
      (strSrc.charCodeAt(i) > 255) ? intLen += 2 : intLen++;
      
      if (intLen > intMaxLen) {
         strSrc = strSrc.substring(0, i);
         break;
      }
   }
   
   return strSrc;
}

//ÀÔ·Â String ¼ýÀÚ check
function IsNumeric(checkStr)
{
   var checkOK = "0123456789";
     for (i = 0;  i < checkStr.length;  i++)
    {
          ch = checkStr.charAt(i);

          for (j = 0;  j < checkOK.length;  j++)
               if (ch == checkOK.charAt(j))
                  break;;

         if (j == checkOK.length)
         {
         return (false);
               break;
          }
     }
   return (true);
} 

// ¼ýÀÚ¿¡¼­ 09 Ã³·³ 0 ÀÌ ¾Õ¿¡ ³ª¿À´Â °æ¿ì ¾ÕÀÇ 0 À» »èÁ¦.
function trimZero(Digit)
{
   var i = 0;

   while ( i <= Digit.length )
   {
      ch = Digit.charAt(i);
      if ( ch == "0" )
      {
         Digit = Digit.substring(1,Digit.length);
         i = 0;
         continue;
      }
      else
         break;
      ++i;
   }

   return Digit;
}


function isAnyHtmlTag ( obj, name )
{
   if ( !isObject(obj) )
   {
      return (true);
   } 

   str=obj.value;

   HtmlTag=/<script|<object|<style|\bhref|\bonload|<applet|<meta|<iframe|\bonmouseover|\bonclick|\bonunload|<link|<span|<div|javascript:|<table|<\/table|<tr|<\/tr|<td|<\/td|<form|\bwidth|\bheight|<embed|<th|<\/th|<select|<option|<button|<xmp|\bonstart|<textarea|<font|<b>|<a href/gi;

   found=str.match(HtmlTag);

   if(found != null){
      alert("["+name+"] ÇÊµå¿¡ HTML ÅÂ±×¸¦ »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
      obj.focus();
      obj.select();
      return (true);
   }   
   return (false);
}

function isWebImage ( obj )
{
   if ( !isObject(obj) )
      return false;

   ImageFile = obj.value;
 
   idx = ImageFile.lastIndexOf(".")

   if ( idx > 0 )
   {
      extension = ImageFile.substring(idx+1, ImageFile.length);
      extension = extension.toUpperCase();

      if( extension == "BMP" || extension == "GIF" || extension == "JPG" || extension == "JEPG"  )
         return true;
      else
         return false;
   }
   else
      return false;
}

function open_win ( URL )
{
   var Opt = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=auto,width=250,height=150';
   win_name = window.open ( URL,"aa",Opt);
   if (win_name)
      win_name.focus();
}

function open_win ( URL, WIDTH, HEIGHT )
{
   var Opt = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width='+WIDTH+',height='+HEIGHT;
   win_name = window.open ( URL,"aa",Opt);
   if (win_name)
      win_name.focus();
}

// ÀÔ·ÂÇÑ ¹®ÀÚ°¡ ¼Ò¹®ÀÚÀÌ¸é ¹«Á¶°Ç ´ë¹®ÀÚ·Î º¯È¯ÇÑ´Ù.
// ÀÔ·Â °ª : obj -ÀÔ·Â°´Ã¼, even - ¹ß»ýÀÌº¥Æ®
// ¸®ÅÏ °ª : ¹®ÀÚ

// ½ÇÁ¦ »ç¿ë ¿¹½Ã : onKeyPress="return toUpperCase(this, event);" 
function toUpperCase(obj, e) {
	  var whichCode = (window.Event) ? e.which : e.keyCode;
	  whichChar = String.fromCharCode(whichCode).charAt(0);

	  if(whichChar.charAt(0) >= 'a' && whichChar.charAt(0) <= 'z')
		e.keyCode = e.keyCode-32;
}

// MoneyFormat ¿¡ ÇØ´çÇÏ´Â ¹®ÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. (1234567890,)
// ÀÔ·Â °ª : obj -ÀÔ·Â°´Ã¼, even - ¹ß»ýÀÌº¥Æ®
// ¸®ÅÏ °ª : ¹®ÀÚ

// ½ÇÁ¦ »ç¿ë ¿¹½Ã : onKeyPress="return MoneyFiler(this, event);" 
function MoneyFiler(obj, e) {
	  var whichCode = (window.Event) ? e.which : e.keyCode;
	  whichChar = String.fromCharCode(whichCode).charAt(0);

	  if( '0' <= whichChar.charAt(0) && whichChar.charAt(0) <= '9' || whichChar.charAt(0) == ',')
		  ;
	  else
		e.keyCode = null;
}

// »ç¾÷ÀÚ ¹øÈ£ Ã¼Å© ·ÎÁ÷
// ÀÔ·Â °ª : »ç¾÷ÀÚ ¹øÈ£ ÀÔ·ÂÇÊµå
// ¸®ÅÍ °ª : boolean 

function chkBizNo(sSerial) {
    var objstring=sSerial.replace(/D/g,"");
    
    if (objstring.length !=10) return false;
 
    var biz_value=new Array(10);
    var li_temp, li_lastid;
 
    //À¯È¿¼º °Ë»ç ·çÆ¾ Àû¿ë  ex)111-11-11111
    biz_value[0] = ( parseFloat(objstring.substring(0 ,1)) * 1 ) % 10; 
    biz_value[1] = ( parseFloat(objstring.substring(1 ,2)) * 3 ) % 10; 
    biz_value[2] = ( parseFloat(objstring.substring(2 ,3)) * 7 ) % 10; 
    biz_value[3] = ( parseFloat(objstring.substring(3 ,4)) * 1 ) % 10; 
    biz_value[4] = ( parseFloat(objstring.substring(4 ,5)) * 3 ) % 10; 
    biz_value[5] = ( parseFloat(objstring.substring(5 ,6)) * 7 ) % 10; 
    biz_value[6] = ( parseFloat(objstring.substring(6 ,7)) * 1 ) % 10; 
    biz_value[7] = ( parseFloat(objstring.substring(7 ,8)) * 3 ) % 10; 
    li_temp = parseFloat(objstring.substring(8,9)) * 5 + "0"; 
    biz_value[8] = parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2)); 
    biz_value[9] = parseFloat(objstring.substring(9,10)); 
 
    li_lastid = (10 - ( ( biz_value[0] + biz_value[1] + biz_value[2] 
    + biz_value[3] + biz_value[4] + biz_value[5] + biz_value[6] 
    + biz_value[7] + biz_value[8] ) % 10 ) ) % 10; 
   
    return biz_value[9]==li_lastid ? true : false;
}

function parseString ( OrgStr, Delimiter )
{
	param = new Array()
	if ( OrgStr == null || OrgStr == "")
	{
		return param;
	}
	var pos = 0;
	var i = 0;
	var Val = "";

	while ( (pos = OrgStr.indexOf(Delimiter)) > 0 )
	{
		Val = OrgStr.substring(0, pos);
		param[i] = Val;
		OrgStr = OrgStr.substring(pos+1, OrgStr.length);
		++i;
	}
	return param;
}

function resizeMe(obj)
{ 
	try
	{
		docHeight = adver.document.body.scrollHeight
		//alert (docHeight);
		obj.style.height = docHeight+10 + 'px'
	}
	catch( e )
	{
	}
} 

