function GetTextByte(text) {
   str = new String(text);
   var strLen = str.length;
   var strByte = 0;
   for (var i=0; i<strLen; i++) {
       tmp = new String(str.charCodeAt(i));
       strByte++;
       if (tmp.length > 3) {
           strByte++;
       }
   }
   return strByte;
}

function IsNull(oFrm) {
   for (var i = 0 ; i < oFrm.length ; i++){
       tst = oFrm.substring(i,i+1)
       if ((tst != ' ')&&(tst != '\r')&&(tst != '\n')&&(tst != '\t')&&(tst != '\b')&&(tst != '\v')&&(tst != '\f')) {
          return false;
       }
   }
   return true;
}

function IsNumeric(oFrm){
	for(var i=0; i<oFrm.length;i++){
		if(oFrm.substring(i,i+1) < "0" || oFrm.substring(i,i+1) > "9"){
			return false;
		}
	 }
	return true;
}

function chkNum(chk) {
   var comp="0123456789";
   var string = chk.value;
   var len = string.length;

   for (i=0;i<len;i++) {
      if (comp.indexOf(string.substring(i,i+1))<0) {
           alert("¼ýÀÚ·Î¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À");
           chk.value = "";
           chk.focus();
           return;
      }
   }
}

function isAllowStr(str, allowStr) {
   var i;
   var ch;

   for (i=0;i<str.length;i++) {
       ch = str.charAt(i);

       if (allowStr.indexOf(ch) < 0) {
          return false;
       }
   }

   return true;
}

function checkEmail(ctrl) {
   str = ctrl.value;

   if (isAllowStr(str, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@.-_") == false) {
       alert("À¯È¿ÇÑ EmailÀÌ ¾Æ´Õ´Ï´Ù!");
       ctrl.value="";
       ctrl.focus();
       ctrl.select();
       return false;
   }

   var atCnt = 0;
   var dotCnt = 0;

   for (i = 0; i < str.length ; i++) { 
       ch = str.charAt(i);

       if (ch == "@") {
          atCnt++;
       }

       if (ch == ".") {
          dotCnt++;
       }
   }

   if (atCnt != 1 || dotCnt < 1) {
      alert("À¯È¿ÇÑ EmailÀÌ ¾Æ´Õ´Ï´Ù.");
      ctrl.value="";
      ctrl.focus();
      ctrl.select();
      return false;
   }

   var atIndex = 0;
   atIndex = str.indexOf("@");

   if (atIndex <= 0) {
      alert("À¯È¿ÇÑ EmailÀÌ ¾Æ´Õ´Ï´Ù.");
      ctrl.value="";
      ctrl.focus();
      ctrl.select();
      return false;
   }

   return true;
}

function CheckID(ctrl) {
	str = ctrl.value;	

    if (isAllowStr(str, "1234567890abcdefghijklmnopqrstuvwxyz") == false) {
        alert ("Çã°¡µÇÁö ¾ÊÀº ¹®ÀÚ¿­ÀÌ Æ÷ÇÔµÇ¾î ÀÖ½À´Ï´Ù!");
        ctrl.focus();
        ctrl.select();
        return false;
    }
   
	// Æ¯¼öÇÑ ÀÌ¸§Àº id·Î »ç¿ëÇÒ ¼ö ¾ø´Ù
	if (!checkSpecialID(str,"admin")) {
	    return false;
	} else if (!checkSpecialID(str,"admins")) {
	    return false;	
	} else if (!checkSpecialID(str,"master")) {
	    return false;	
	} else if (!checkSpecialID(str,"root")) {
	    return false;		
	} else if (!checkSpecialID(str,"webmaster")) {
	    return false;		
	} else {
        return true;
	}
}

function checkSpecialID(a,b) {	
	if (a.toUpperCase() == b.toUpperCase()) {
		alert("ID·Î " + b + "À»(¸¦) »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");
		return false;
	}
	return true;
}

function CheckString(ctrl) {
	str = ctrl.value;	

    if (isAllowStr(str, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") == false) {
        ctrl.value="";
        ctrl.focus();
        ctrl.select();
        return false;
    }
   
    return true;
}

//ÁÖ¹Îµî·Ï ¹øÈ£ Ã¼Å©
function CheckSSN(jumin1,jumin2) {
	var today = new Date();
	var chkYear1 = today.getYear();
	var chkYear2 = 0;

	if (chkYear1 < 2000) {
		chkYear1 += 1900;
	}

	var chk = 0;
	var chk2 = 0;
	var chk3 = 0;
	var yy = jumin1.substring(0,2);
	var mm = jumin1.substring(2,4);
	var dd = jumin1.substring(4,6);
    var chkSex = jumin2.substring(0,1);	

	if ((jumin1.length != 6) || (mm<1 || mm>12 || dd<1 || dd>31 )) {
		return false;
	}

	if ((chkSex != 1 && chkSex !=2 && chkSex !=3 && chkSex !=4) || (jumin2.length != 7)) {
		return false;
	}

	chkYear2 = parseInt(yy,10);

	if (chkSex <=2) {
		chkYear2 += 1900;
    } else {
		chkYear2 += 2000;
    }
	
	//if ((chkYear1 - chkYear2) < 12) { 
	//	return false;
	//} 

	// ÁÖ¹Îµî·Ï¹øÈ£ validation check
	for (var i = 0; i <=5 ; i++) { 
		chk = chk + ((i%8+2) * parseInt(jumin1.substring(i,i+1)))
	}

	for (var i = 6; i <=11 ; i++) { 
		chk = chk + ((i%8+2) * parseInt(jumin2.substring(i-6,i-5)))
	}

	chk = 11 - (chk %11)
	chk = chk % 10

	if (chk != jumin2.substring(6,7)) {
		return false;
	}  

	return true;
} 

function nextJumin(obj){
	if(obj.jumin1.value.length == 6){
		obj.jumin2.focus();
	}
}





//========================

//========================

	function layerClose(id) {
		document.getElementById(id).style.display = "none";
	}

	function Browser() {

		var ua, s, i;

		this.isIE    = false;
		this.isNS    = false;
		this.version = null;

		ua = navigator.userAgent;

		s = "MSIE";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isIE = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}

		s = "Netscape6/";
		if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = parseFloat(ua.substr(i + s.length));
			return;
		}

		// Treat any other "Gecko" browser as NS 6.1.

		s = "Gecko";
			if ((i = ua.indexOf(s)) >= 0) {
			this.isNS = true;
			this.version = 6.1;
			return;
		}
	}

	var browser = new Browser();

	// µå·¡±× ¾Øµå µå¶ø °ü·Ã Æã¼Ç ---------------------------------------------------------------------------------------------------------
	var dragObj = new Object();
	dragObj.zIndex = 0;

	function dragStart(event, id) {

		var el;
		var x, y;

		// If an element id was given, find it. Otherwise use the element being
		// clicked on.

		if (id)
			dragObj.elNode = document.getElementById(id);
		else {
		if (browser.isIE)
			dragObj.elNode = window.event.srcElement;
		if (browser.isNS)
			dragObj.elNode = event.target;

		// If this is a text node, use its parent element.

		if (dragObj.elNode.nodeType == 3)
			dragObj.elNode = dragObj.elNode.parentNode;
		}

		// Get cursor position with respect to the page.

		if (browser.isIE) {
			x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
		}
		if (browser.isNS) {
			x = event.clientX + window.scrollX;
			y = event.clientY + window.scrollY;
		}

		// Save starting positions of cursor and element.

		dragObj.cursorStartX = x;
		dragObj.cursorStartY = y;
		dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
		dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

		if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
		if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

		// Update element's z-index.

		dragObj.elNode.style.zIndex = ++dragObj.zIndex;

		// Capture mousemove and mouseup events on the page.

		if (browser.isIE) {
			document.attachEvent("onmousemove", dragGo);
			document.attachEvent("onmouseup",   dragStop);
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (browser.isNS) {
			document.addEventListener("mousemove", dragGo,   true);
			document.addEventListener("mouseup",   dragStop, true);
			event.preventDefault();
		}
	}

	function dragGo(event) {

		var x, y;

		// Get cursor position with respect to the page.

		if (browser.isIE) {
			x = window.event.clientX + document.documentElement.scrollLeft
			+ document.body.scrollLeft;
			y = window.event.clientY + document.documentElement.scrollTop
			+ document.body.scrollTop;
		}
		if (browser.isNS) {
			x = event.clientX + window.scrollX;
			y = event.clientY + window.scrollY;
		}

		// Move drag element by the same amount the cursor has moved.

		dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
		dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

		if (browser.isIE) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (browser.isNS)
			event.preventDefault();
		}

		function dragStop(event) {

		// Clear the drag element global.

		dragObj.elNode = null;

		// Stop capturing mousemove and mouseup events.

		if (browser.isIE) {
			document.detachEvent("onmousemove", dragGo);
			document.detachEvent("onmouseup",   dragStop);
		}
		if (browser.isNS) {
			document.removeEventListener("mousemove", dragGo,   true);
			document.removeEventListener("mouseup",   dragStop, true);
		}
	}



// ÀÌ¹ÌÁö Å©°Ôº¸±â
String.prototype.popupView = function () { 
	var img_view = this; 
	var x = x + 20 ; 
	var y = y + 30 ; 
	htmlz = "<html><head><title>±ÝÈ£°Ç¼³-ÀÌ¹ÌÁöÅ©°Ôº¸±â</title><style>body{margin:0;cursor:hand;}</style></head><body scroll=auto onload='width1=document.all.Timage.width;if(width1>1024)width1=1024;height1=document.all.Timage.height;if(height1>768)height1=768;top.window.resizeTo(width1+30,height1+54);' onclick='top.window.close();'><img src='"+img_view+"'  title='Å¬¸¯ÇÏ½Ã¸é ´ÝÈü´Ï´Ù.' name='Timage' id='Timage'></body></html>" 
	imagez = window.open('', "image", "width="+ 100 +", height="+ 100 +", top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1"); 
	imagez.document.open(); 
	imagez.document.write(htmlz) 
	imagez.document.close(); 
} 

//ActiveX ÇÃ·¡½Ã
function setFlash(src, w, h) {
	var Flash_html = "";
	Flash_html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="param" width="'+w+'" height="'+h+'">';
	Flash_html += '<param name="movie" value="'+src+'">';
	Flash_html += '<param name="quality" value="high">';
	Flash_html += '<param name="wmode" value="transparent">';
	Flash_html += '<param name="swliveconnect" value="true">';
	Flash_html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" width="'+w+'" height="'+h+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><\/embed>';
	Flash_html += '</object>';
	document.write(Flash_html);
}


//ActiveX µ¿¿µ»ó
function setMedia(src, Ow, Oh, Pw, Ph) { //object width, height, param width, height  //µ¿¿µ»óÆÄÀÏ
	var Media_html = "";
	Media_html += '<OBJECT id=MPlay1 codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 ';
    Media_html += '    type=application/x-oleobject height='+Oh+'';
    Media_html += '    standby="Loading Microsoft Windows Media Player components..." width='+Ow+' ';
    Media_html += '    classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95>';
    Media_html += '   <PARAM NAME="Width" VALUE="'+Pw+'">';
    Media_html += '   <PARAM NAME="Height" VALUE="'+Ph+'">';
    Media_html += '   <PARAM NAME="FileName" VALUE="'+src+'">';
    Media_html += '   <PARAM NAME="Volume" VALUE="10">';
    Media_html += '   <PARAM NAME="AnimationatStart" VALUE="1">';
    Media_html += '   <PARAM NAME="AutoSize" VALUE="0">';
	Media_html += '   <PARAM NAME="TransparentatStart" VALUE="1">';
    Media_html += '   <PARAM NAME="ControlType" VALUE="1">';
	Media_html += '   <PARAM NAME="EnableContextMenu" VALUE="0">';
    Media_html += '   <PARAM NAME="EnablePositionControls" VALUE="0">';
    Media_html += '   <PARAM NAME="ShowTracker" VALUE="1">';
    Media_html += '   <PARAM NAME="AutoStart" VALUE="1">';
    Media_html += '   <PARAM NAME="ShowControls" VALUE="1">';
    Media_html += '   <PARAM NAME="ClickToPlay" VALUE="1">';
    Media_html += '   </OBJECT>';
	document.write(Media_html);
}