/*
	ÇÊ¼ö ÀÚ¹Ù ½ºÅ©¸³Æ® Á¤ÀÇ
	smsket.com
	Copyright(c) 2001-2006 Xonda.net Co,.Ltd. All Rights Reserved.
*/

// 2006.3.1 active-x ¹èÆ÷¹æ½Ä º¯°æ¿¡ µû¸¥ ¼öÁ¤, ÃÖ»óÈ£
function playflash(file,width,height,bgcolor,quality,name){
		var host = (("https:" == document.location.protocol) ? "https://" : "http://");

		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + host + 'fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+name+'">');  //ÇÃ·¡½¬ÇÃ·¹ÀÌ¾î ¹öÀüÀÌ ÀÌÀü¹öÀüÀÏ°æ¿ì ¹öÀü 8À» º¯°æ
        document.write('<param name="movie" value="'+file+'" />');
        document.write('<param name="quality" value="'+quality+'" />');
        document.write('<param name="wmode" value="transparent" />');  //Åõ¸íÇÃ·¡½¬°¡ ¾Æ´Ò°æ¿ì ÀÌ ¶óÀÎÀ» »èÁ¦
        document.write('<param name="bgcolor" value="'+bgcolor+'" />');
        document.write('<embed src="'+file+'" quality="'+quality+'" wmode="transparent" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
        document.write('</object>')
}

/*
	¹®ÀÚ¿­ Ã³¸®°ü·Ã
*/
function replaceString(srcTXT, orgTXT, repTXT)
{
	while(srcTXT.match(orgTXT) != null)
	{
		srcTXT = srcTXT.replace(orgTXT, repTXT);
	}

	return srcTXT;
}

function chkIntEx()
{
	if(event.keyCode == 8) return true;
	if(event.keyCode == 9) return true;
	if(event.keyCode == 45) return true;
	if(event.keyCode == 46) return true;
	if(event.keyCode == 35) return true;
	if(event.keyCode == 36) return true;
	if(event.keyCode == 36) return true;
	if(event.keyCode >= 37 && event.keyCode <= 40) return true;

	if(event.keyCode >= 48 && event.keyCode <= 57) return true;
	if(event.keyCode >= 96 && event.keyCode <= 105) return true;

	return false;
}

function chkNum(phonenum)
{
	for (var zz = 0; zz < phonenum.length; zz++)
        {
		var ch = phonenum.substring(zz, zz+1);

		if (ch >= "0" && ch <= "9")
                {

		}
                else if (ch == "-")
                {

                }
		else
                {
                    //alert (ch);
			return false;
                }
	}
        return true;
}

function chkMobileNum(phoneNum)
{
	if(!parseFloat(phoneNum) || (phoneNum.length != 10 && phoneNum.length != 11))
		return false;

	switch(phoneNum.substring(0, 3))
	{
		case "010" :
		case "011" :
		case "013" :
		case "016" :
		case "017" :
		case "018" :
		case "019" :
			var chkNum = "";

				chkNum = phoneNum.substring(3, phoneNum.length-4);

			//if(parseFloat(chkNum) == 0 || (parseFloat(chkNum) + "").length != chkNum.length)
			if(parseFloat(chkNum) == 0)
				return false;

			//	chkNum = phoneNum.substring(phoneNum.length-4, phoneNum.length);

			//if(parseFloat(chkNum) == 0)
			//	return false;

			break;
		default :
			return false;
	}

	return true;
}

function LimitTextSizeEx(orgText, limitSize)
{// ÅØ½ºÆ® ÀÔ·ÂÃ¢ÀÇ ±ÛÀÚ ¹ÙÀÌÆ®¼ö¸¦ Á¦ÇÑ ÇÑ´Ù.
	var prvByte = StrByteLengthEx(orgText);
	var evKey = event.keyCode;

	switch(evKey)
	{
		case 8 :
		case 9 :
		case 16 :
		case 17 :
		case 18 :
		case 20 :
		case 33 :
		case 34 :
		case 35 :
		case 36 :
		case 37 :
		case 38 :
		case 39 :
		case 40 :
		case 46 :

			break;
		case 229 :
			if(prvByte >= (limitSize-1))
				return false;

			break;
		default :
			if(prvByte >= limitSize)
				return false;

			break;
	}

	return true;

}

function StrByteLength(strVal)
{// ¸®ÅÏ ¹®ÀÚ°¡ 2Byte(13+10) °è»êµÊ...
	var strLen = 0;

	for(var i=0; i<strVal.length; i++)
	{
		var chrCode = strVal.charCodeAt(i);

		strLen++;

		if(chrCode > 255)
			strLen++;
	}

	return strLen;
}

function StrByteLengthEx(strVal)
{// 2Byte(13+10)ÀÇ ¸®ÅÏ ¹®ÀÚ¿¡¼­ 1¹ÙÀÌÆ®(10)´Â °è»ê¿¡¼­ Á¦¿Ü...
	var strLen = 0;

	for(var i=0; i<strVal.length; i++)
	{
		var chrCode = strVal.charCodeAt(i);

		//if(chrCode == 10) // ¹«½ÃÇÏ±â À§ÇÑ ¹ÙÀÌÆ®°ª
		//	continue;

		strLen++;

		if(chrCode > 255)
			strLen++;
	}

	return strLen;
}

function GetTextByteEx(strVal, limitByte)
{// ÇØ´ç ¹ÙÀÌÆ® ¸¸Å­¸¸ °¡Á®¿À±â
	var strLen = 0;

	var retVal = "";

	for(var i=0; i<strVal.length; i++)
	{
		var chrCode = strVal.charCodeAt(i);

		if(chrCode == 10) // ¹«½ÃÇÏ±â À§ÇÑ ¹ÙÀÌÆ®°ª
			continue;

		strLen++;

		if(chrCode > 255)
			strLen++;

		if(strLen > limitByte)
			break;

		retVal += strVal.charAt(i);
	}

	return retVal;
}

function checkInt(str) {

	var point_C = 0;

	if (!str) return 0;

	var ok = "";

	for (var zz = 0; zz < str.length; zz++) {

		var ch = str.substring(zz, zz+1);

		if(zz == 0 && ch == "-" && str.length > 1){

		}else if(ch == "." && point_C < 1){

			point_C++;
		}else if (ch < "0" || "9" < ch){
			return false;
		}
		else
			ok += ch;
	}

	return true;
}

/*
	ÀÔ·Â »óÀÚ Ã³¸®°ü·Ã
*/
function checkInputBox(fld, max_size, next_fld, typeBOOL)
{
	if(!parseFloat(max_size))
		max_size = 1048576;
	else if(parseFloat(max_size) < 1)
		max_size = 1048576;

	if(typeBOOL == 1 && !chkIntEx())
	{// ¼ýÀÚ¸¸ ÀÔ·Â...(Ctrl-C, V °¡´ÉÇÏ°Ô ÇÏ±â À§ÇØ comment Ã³¸®)
		//event.returnValue = false;
		//return;
	}
	else if(typeBOOL == 2 && event.keyCode == 229)
	{// ÇÑ±Û ÀÔ·Â Ãë¼Ò...
		event.returnValue = false;
		return;
	}

	if(!LimitTextSizeEx(fld.value, max_size))
	{
		//event.returnValue = false;

		fld.blur();

		if(typeof(next_fld) == "object")
		{
			next_fld.focus();
			//next_fld.select();
		}
	}
}