/*
	cmmon.js

	- 기본적으로 쓰는 함수정리
	- last edit : 2008-05-16
*/

//	문자열에서 테그 제거
String.prototype.notag		= function()
{
	return this.replace(/<.*?>/gi, '');
}

//	ltrim 함수 추가
String.prototype.ltrim	= function()
{
	return this.replace(/(\s*$)/g, '');
}

//	rtrim 함수 추가
String.prototype.rtrim		= function()
{
	return this.replace(/(^\s*)/g, '');
}

//	trim 함수 추가
String.prototype.trim		= function()
{
	return this.ltrim().rtrim();
}

//	string 함수 추가
String.prototype.string		= function(dwCount, strText)
{
	if(typeof(dwCount) != "number" && typeof(strText) != "string")
		return this;

	var strBuf	= "";
	for(var i=0; i<dwCount; i++)
		strBuf	+= strText;

	return this + strBuf;
}

//	주소 문자열에서 키값에 해당하는 값 추출
String.prototype.getQueryString		= function(strKey)
{
	var dwStartIndex	= this.indexOf('?');
	var dwEndIndex		= this.indexOf('#') < 0 ? this.length : this.indexOf('#');
	if(dwStartIndex < 0)
		return '';

	var strQueryString	= this.substring(dwStartIndex + 1, dwEndIndex);

	var arrQueryString	= new Array;

	strQueryString.replace(/([^=]+)=([^&]*)(&|#|$)/g, function(){ arrQueryString[arguments[1]] = arguments[2]; });

	var strReturnValue	= arrQueryString[strKey];
	if(typeof(strReturnValue) == 'undefined')
		strReturnValue	= '';

	return strReturnValue;
}

//	주소 문자열에서 키값에 해당하는 값 변경
String.prototype.setQueryString		= function(strKey, strValue)
{
	if(!strKey || strKey == '')
		return this;

	var dwStartIndex	 	= this.indexOf('?');
	var dwEndIndex		= this.indexOf('#') < 0 ? this.length : this.indexOf('#');

	if(dwStartIndex >= 0)
	{
		var strPath				= this.substring(0, dwStartIndex);
		var strQueryString	= this.substring(dwStartIndex + 1, dwEndIndex);

		var arrQueryString	= new Array;

		strQueryString.replace(/([^=]+)=([^&]*)(&|#|$)/g, function(){ arrQueryString[arguments[1]] = arguments[2]; });

		arrQueryString[strKey]	= strValue.trim();

		var arrJoinQueryString	= new Array;
		for(var i in arrQueryString)
		{
			if(!arrQueryString.hasOwnProperty(i))
				continue;

			arrJoinQueryString[arrJoinQueryString.length]	= i + '=' + arrQueryString[i].trim();
		}

		return strPath+ '?' + arrJoinQueryString.join('&');
	}
	else
	{
		var strPath			= this.substring(0, dwEndIndex);

		return strPath + '?' + strKey +'='+ strValue.trim();
	}
}

//	3자리마다 ,찍기 -- 문자형으로 바뀜, 소수점이하는 그냥 표기
Number.prototype.setPrintMoney	= function()
{
	return this.toString().setPrintMoney();
}

String.prototype.setPrintMoney	= function()
{
	var strValue			= this;
	var strValueBuf		= '';
	var dwLength			= strValue.length;
	var dwCount			= 0;
	var strReturnValue	= '';

	if(strValue.indexOf('.') >= 0)
	{
		strValueBuf	= strValue.substring(strValue.indexOf('.'), strValue.length);
		strValue			= strValue.substring(0, strValue.indexOf('.'));
		dwLength		= strValue.length;
	}

	if(dwLength > 0)
	{
		for(var i=dwLength; i>0; i--)
		{
			if(dwCount == 3)
			{
				dwCount	= 0;
				strReturnValue	= strValue.substring(i-1, i) + ',' + strReturnValue;
			}
			else
			{
				strReturnValue	= strValue.substring(i-1, i) + strReturnValue;
			}

			dwCount++;
		}

		strReturnValue	= strReturnValue + strValueBuf;
	}

	return strReturnValue;
}





// 빠른 innerHTML(cloneNode 이용)
function innerHTML(obj, html)
{
	return replaceHtml(obj, html);
}
function replaceHtml(obj, html)
{
	var objOld	= xGetElementById(obj);
	if(!objOld)
		return null;

	var objNew	 = objOld.cloneNode(false);
	objNew.innerHTML	= html;
	objOld.parentNode.replaceChild(objNew, objOld);

	return objNew;
}

// outerHTML(ie 이외 브라우저 처리시 사용)
function outerHTML(obj, html)
{
	if(typeof(html) == 'string')
	{
		if(obj.outerHTML)
		{
			obj.outerHTML	= html;
		}
		else
		{
			var objParent	= obj.parentNode;
			var objDiv		= xCreateElement('div');
			objDiv			= replaceHtml(objDiv, html);
			while(objDiv.firstChild)
			{
				objParent.insertBefore(objDiv.firstChild, obj);
			}
			objParent.removeChild(obj);
		}
	}
	else
	{
		if(obj.outerHTML)
		{
			html	= obj.outerHTML;
		}
		else
		{
			var objDiv		= xCreateElement('div');
			objDiv.appendChild(obj);

			html	= xInnerHtml(objDiv);
		}
	}

	return html;
}

// 새창 열기
function windowopen(strUrl, strTarget, strStatus, blsReplace)
{
	strUrl				= typeof(strUrl) != "undefined" ? strUrl : "";
	strTarget		= typeof(strTarget) != "undefined" ? strTarget : "_blank";
	strStatus		= typeof(strStatus) != "undefined" ? strStatus : "";
	blsReplace		= typeof(blsReplace) != "undefined" ? blsReplace : false;

	return window.open(strUrl, strTarget, strStatus, blsReplace);
}

//	팝업 열기
function popupopen(strUrl, strTarget, strStatus, blsReplace)
{
	strStatus		= typeof(strStatus) != "undefined" ? strStatus : "width=5, height=5, left=5, top=5, scrollbars=no, resizable=yes, status=no, toolbar=no, menubar=no, location=no";

	return windowopen(strUrl, strTarget, strStatus, blsReplace);
}

// 특정 개체의 숨기기, 표시 처리
function display(obj, opt)
{
	obj	= xGetElementById(obj);
	if(!obj)
		return;

	opt		= typeof(opt) == "undefined" ? "inline" : opt;
	opt		= (!obj.style.display || obj.style.display == "block") ? "none" : opt;

	obj.style.display	= opt;

	return opt;
}


//	플래쉬 파일 삽입
function flashclip(obj, src, width, height, flashvars, wmode, menu, explain)
{
	obj	= xGetElementById(obj);

	var html		= "";
	var classid		= "";
	var id			= obj.id ? obj.id : Date.parse(new Date()).toString();

	flashvars		= typeof(flashvars) == "undefined" ? "" : flashvars;
	wmode			= typeof(wmode) == "undefined" || wmode == true ? "transparent" : wmode;
	menu			= typeof(menu) == "undefined" ? false : menu;
	explain			= typeof(explain) == "undefined" ? "" : explain;

	if(/\.swf/i.test(src))
	{
		classid		= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
		codebase	= "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
		
		html	= "" +
			"<object id=\"object_"+ id +"\" classid=\""+ classid +"\" codebase=\""+codebase+"\" width=\""+ width +"\" height=\""+ height +"\">"+
			"<param name=\"movie\" value=\""+ src +"\" />"+
			"<param name=\"src\" value=\""+ src +"\" />"+
			"<param name=\"flashvars\" value=\""+ flashvars +"\" />"+
			"<param name=\"wmode\" value=\""+ wmode +"\" />"+
			"<param name=\"menu\" value=\""+ menu +"\" />"+
			"<param name=\"quality\" value=\"high\" />"+
			"<param name=\"allowfullscreen\" value=\"true\" />"+
			"<param name=\"allownetworking\" value=\"all\" />"+
			"<param name=\"allowscriptaccess\" value=\"always\" />"+
			"<embed id=\"embed_"+ id +"\" src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" flashvars=\""+ flashvars +"\" wmode=\""+ wmode +"\"></embed>"+
			"\n<!--[if !IE]>\n"+ 
			"<br />이 콘텐츠를 보실려면<a href=\"http://www.macromedia.com/go/getflashplayer\">Abode Flash Player</a>(무료)가 필요합니다."+
			(explain != "" ? "<br />"+ explain : "")+
			"\n<![endif]-->\n"+ 
			"<\/object>";

		if(obj)
			innerHTML(obj, html);
	}
	else if(/\.flv/i.test(src))
	{
		var arrSrc	= src.split(",");

		if(arrSrc[0])
			flashvars	= "file="+ arrSrc[0];

		if(arrSrc[1])
			flashvars	+= "&image="+ arrSrc[1];

		src			= "/_library/common/images/flv_player.swf";

		html	= flashclip(obj, src, width, height, flashvars, wmode, false, explain);
	}

	return html;
}


//	동영상파일 삽입
function movieclip(obj, src, width, height, autostart, loop, menu, explain)
{
	obj	= xGetElementById(obj);
	if(!obj)
		return;

	var html			= "";
	var classid		= "";
	var id			= obj.id ? obj.id : Date.parse(new Date()).toString();

	autostart		= typeof(autostart) == "undefined" ? false : autostart;
	loop			= typeof(loop) == "undefined" ? false : loop;
	menu			= typeof(menu) == "undefined" ? false : menu;

	classid		= "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
	codebase	= "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=6,4,5,715";
	
	html	= "" +
//			"<object id=\"object_"+ id +"\" style=\"width: "+ width +"px; height: "+ height +"px;\" classid=\""+ classid +"\" codebase=\""+codebase+"\" width=\""+ width +"\" height=\""+ height +"\">"+
			"<object id=\"object_"+ id +"\" classid=\""+ classid +"\" codebase=\""+codebase+"\" width=\""+ width +"\" height=\""+ height +"\">"+
			"<param name=\"movie\" value=\""+ src +"\" />"+
			"<param name=\"src\" value=\""+ src +"\" />"+
			"<param name=\"play\" value=\""+ autostart +"\" />"+
			"<param name=\"loop\" value=\""+ loop +"\" />"+
			"<param name=\"menu\" value=\""+ menu +"\" />"+
			"<param name=\"wmode\" value=\"transparent\" />"+
			"<param name=\"quality\" value=\"high\" />"+
			"<param name=\"allowfullscreen\" value=\"true\" />"+
			"<param name=\"allownetworking\" value=\"all\" />"+
			"<param name=\"allowscriptaccess\" value=\"always\" />"+
			"<embed id=\"embed_"+ id +"\" src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" autostart=\""+ autostart +"\" loop=\""+ loop +"\" wmode=\"transparent\"></embed>"+
			"\n<!--[if !IE]>\n"+ 
			"<br />이 콘텐츠를 보실려면 동영상 플레이어가 필요합니다."+
			(explain != "" ? "<br />"+ explain : "")+
			"\n<![endif]-->\n"+ 
			"<\/object>";

//	html	= "<embed id=\"embed_"+ id +"\" src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" autostart=\""+ autostart +"\" loop=\""+ loop +"\" wmode=\"transparent\"></embed>";
	if(obj)
		innerHTML(obj, html);

	return html;
}


//	플래쉬, 동영상 공통 처리 함수
function multimedia(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
{
	if(/\.swf|\.flv/i.test(arg2))
		return flashclip(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
	else
		return movieclip(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}




////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	form 함수
function FormSubmit(strId)
{
	var objForm	= xGetElementById(strId);
	if(objForm)
	{
		objForm.submit();
	}

	return false;
}

function FormReset(strId)
{
	var objForm	= xGetElementById(strId);
	if(objForm)
	{
		objForm.reset();
	}

	return false;
}



// xmlhttp get 전송 관련 함수
// xmlhttp 처리
function fnXmlHttp(strUrl, fnCallBackFn)
{
	var objXmlHttp			= null;

	if(typeof(fnCallBackFn) != "function")
		return null;

	if(window.XMLHttpRequest)
		objXmlHttp	= new XMLHttpRequest();
	else if (window.ActiveXObject)
	{
		try
		{
			objXmlHttp	= new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			objXmlHttp	= new ActiveXObject("Microsoft.xmlhttp");
		}
	}

	if(!objXmlHttp)
		return null;

	objXmlHttp.onreadystatechange = function () { fnCallBackFn(objXmlHttp) };
	objXmlHttp.open("get", strUrl, true);
	objXmlHttp.send(null);

	return objXmlHttp;
}

// xmlhttp callback 처리
function fnXmlHttp_callBack(objXmlHttp, strReceiveType)
{
	strReceiveType	= typeof(strReceiveType) != "string" ? "text" : strReceiveType.toLowerCase();

	if(!objXmlHttp)
		return null;

	var dwReadyStatus		= 0
	if(objXmlHttp.readyState)
		dwReadyStatus		= parseInt(objXmlHttp.readyState, 10);

	if(dwReadyStatus == 4)
	{
		var dwStatus		= parseInt(objXmlHttp.status, 10);

		if(dwStatus == 404)
		{
			//strReturnValue	= "status : 404";
			strReturnValue	= null;
		}
		else
		{
			if(strReceiveType == "text")
				strReturnValue		= objXmlHttp.responseText;
			else if(strReceiveType == "boby")
				strReturnValue		= objXmlHttp.responseBody;
			else if(strReceiveType == "xml")
				strReturnValue		= objXmlHttp.responseXML;
		}
	}
	else
	{
		//strReturnValue	= "readyState : "+ dwReadyStatus;
		strReturnValue	= null;
	}

	return strReturnValue;
}


// xmlhttp post 전송 관련 함수
function fnEscape(strValue)
{
	var strRet	= strValue;
	if(encodeURI)
		strRet	= encodeURI(strValue);
	else if(encodeURIComponent)
		strRet	= encodeURIComponent(strValue);
	else
		strRet	= escape(strValue);

	return strRet
}

function fnFormData2Querystring(objForm)
{
	objForm		= xGetElementById(objForm);
	if(!objForm)
		return;

	var strSubmitString					= "";
	var objFormElements				= null;
	var strFormElementName			= "";
	var strFormElementType			= "";
	var strFormElementValue			= "";
	var blsFormElementChecked		= false;
	var strFormElementNameLast	= "";

	for(var i=0; i<objForm.elements.length; i++)
	{
		objFormElements				= objForm.elements[i];
		strFormElementTagName	= objFormElements.tagName ? objFormElements.tagName.toLowerCase() : "";
		strFormElementName		= xGetAttribute(objFormElements, "name");

		if(strFormElementTagName == "select")
		{
			var blsMultiple				= objFormElements.multiple ? true : false;

			if(!blsMultiple)
			{
				strFormElementType		= "select-one";
				strFormElementValue		= objFormElements.options[objFormElements.options.selectedIndex].value;
			}
			else
			{
				strFormElementType		= "select-multiple";
				strFormElementValue		= "";
				for(var j=0; j<objFormElements.options.length; j++)
				{
					if(objFormElements.options[j].selected)
						strFormElementValue	+= (strFormElementValue != "" ? "," : "") + objFormElements.options[j].value;
				}
			}
		}
		else if(strFormElementTagName == "textarea")
		{
			strFormElementType		= "textarea";
			strFormElementValue		= objFormElements.value;
		}
		else
		{
			strFormElementType		= xGetAttribute(objFormElements, "type");
			//strFormElementValue		= xGetAttribute(objFormElements, "value");
			strFormElementValue		= objFormElements.value;
		}

		switch(strFormElementType.toLowerCase())
		{
			case "text":
			case "select-one":
			case "select-multiple":
			case "hidden":
			case "password":
			case "textarea":
				strSubmitString	+= strFormElementName +"="+ fnEscape(strFormElementValue) +"&";
				break;

			case "radio":
				//blsFormElementChecked	= xGetAttribute(objFormElements, "checked");
				blsFormElementChecked	= objFormElements.checked ? true : false;

				if(blsFormElementChecked)
				{
					strSubmitString	+= strFormElementName +"="+ fnEscape(strFormElementValue) +"&";
				}
				break;

			case "checkbox":
				//blsFormElementChecked	= xGetAttribute(objFormElements, "checked");
				blsFormElementChecked	= objFormElements.checked ? true : false;

				if(blsFormElementChecked)
				{
					if(strFormElementName == strFormElementNameLast)
					{
						if(strFormElementNameLast.lastIndexOf("&") == strFormElementNameLast.length - 1)
						{
							strSubmitString	= strSubmitString.substring(0, strSubmitString.length - 1);
						}
						strSubmitString	+= ","+ fnEscape(strFormElementValue);
					}
					else
					{
						strSubmitString	+= strFormElementName +"="+ fnEscape(strFormElementValue);
					}
					strSubmitString					+= "&";
					strFormElementNameLast		= strFormElementName;
				}
				break;
		}
	}

	strSubmitString	= strSubmitString.substring(0, strSubmitString.length - 1);

	return strSubmitString;
}


function fnXmlHttpPost(strUrl, fnCallBackFn, strSubmitString)
{
	var objXmlHttp			= null;

	if(typeof(fnCallBackFn) != "function")
		return false;

	if(window.XMLHttpRequest)
		objXmlHttp	= new XMLHttpRequest();
	else if (window.ActiveXObject)
	{
		try
		{
			objXmlHttp	= new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			objXmlHttp	= new ActiveXObject("Microsoft.xmlhttp");
		}
	}

	if(!objXmlHttp)
		return false;

	objXmlHttp.onreadystatechange = function () { fnCallBackFn(objXmlHttp) };
	objXmlHttp.open("post", strUrl, true);
	objXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objXmlHttp.send(strSubmitString);

	return false;
}


function fnXmlHttpPost_callBack(objXmlHttp, strReceiveType)
{
	return fnXmlHttp_callBack(objXmlHttp, strReceiveType);
}



// 폼체크 함수
function fnCheckForm(objForm, strName, strAlertName, strType, nMinsize, nMaxSize, blsNotEmpty, blsNo, blsEng, blsKr, blsSp, strExample)
{
	objForm		= xGetElementById(objForm);
	strType		= strType ? strType : "";
	nMinsize	= nMinsize ? nMinsize : 0;
	nMaxSize	= nMaxSize ? nMaxSize : 0;
	strExample	 = strExample ? strExample : "";

	var blsRet	= false;
	var strRet	= "";

	var objThis		= null;
	var objThis2	= null;
	var strValue	= "";
	var strValue2	= "";

	var strThisType	= "";
	var strThisType2	= "";

	if(!objForm) return false;
	if(strName == "") return false;
	if(strAlertName == "") return false;

	if(strType.toLowerCase() == "repassword")
	{
		arrBuf		= strName.split(",");

		if(!objForm[arrBuf[0]]) return false;
		if(!objForm[arrBuf[1]]) return false;
		
		objThis		= objForm[arrBuf[0]];
		objThis2		= objForm[arrBuf[1]];
		strValue		= objThis.value ? objThis.value : "";
		strValue2	= objThis2.value ? objThis2.value : "";

		strThisType	= objThis.type ? objThis.type : "";
		strThisType2	= objThis2.type ? objThis2.type : "";

		if(!objThis.length)
		{
			if(objThis.tagName)
			{
				if(objThis.tagName.toLowerCase() == "select")
					strThisType	= "select";
			}
		}
		else
		{

			if(objThis[0].tagName)
			{
				if(objThis[0].tagName.toLowerCase() == "select")
					strThisType	= "select";
			}
		}

		if(!objThis2.length)
		{
			if(objThis2.tagName)
			{
				if(objThis2.tagName.toLowerCase() == "select")
					strThisType2	= "select";
			}
		}
		else
		{
			if(objThis2[0].tagName)
			{
				if(objThis2[0].tagName.toLowerCase() == "select")
					strThisType2	= "select";
			}
		}
	}
	else
	{
		if(!objForm[strName]) return false;

		objThis		= objForm[strName];
		strValue		= objThis.value ? objThis.value : "";

		if(!objThis.length)
		{
			strThisType	= objThis.type ? objThis.type : "";

			if(objThis.tagName)
			{
				if(objThis.tagName.toLowerCase() == "select")
					strThisType	= "select";
			}
		}
		else
		{
			strThisType	= objThis[0].type ? objThis[0].type : "";

			if(objThis[0].tagName)
			{
				if(objThis[0].tagName.toLowerCase() == "select")
					strThisType	= "select";
			}
		}
	}
	
	if(strThisType == "select")
	{
		if(objThis.options.selectedIndex >= 0)
			strValue	 = objThis.options[objThis.options.selectedIndex].value;
		else
			strValue	 = "";
	}
	else if(strThisType == "checkbox" || strThisType == "radio")
	{
		strValue	 = "";
		for(var i=0; i<objThis.length; i++)
		{
			if(objThis[i].checked)
				strValue	 = objThis[i].value;
		}
	}


	if(strType == "")
	{
		if(!blsRet && nMinsize > 0 && nMaxSize <= 0)
		{
			if(strValue.length < nMinsize)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 최소 입력 값은 "+ nMinsize +"글자입니다.";
			}
		}
		else if(!blsRet && nMinsize <= 0 && nMaxSize > 0)
		{
			if(strValue.length > nMaxSize)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 최대 입력 값은 "+ nMaxSize +"글자입니다.";
			}
		}
		else if(!blsRet && nMinsize > 0 && nMaxSize > 0)
		{
			if(strValue.length < nMinsize || strValue.length > nMaxSize)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 최소~최대 입력 값은 "+ nMinsize +"~"+ nMaxSize +" 글자입니다.";
			}
		}

		if(!blsRet && blsNotEmpty == true)
		{
			if(strValue.length == 0)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 값을 입력해 주세요.";
			}
		}

		if(!blsRet && blsNo == true)
		{
			if(strValue.search(/\D/) != -1)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 값은 숫자만 입력할수 있습니다.";
			}
		}

		if(!blsRet && blsEng == true)
		{
			if(strValue.search(/\C/) != -1)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 값은 알파벳만 입력할수 있습니다.";
			}
		}

		if(!blsRet && blsKr == true)
		{
			if(strValue.search(/\K/) != -1)
			{
				blsRet	= true;
				strRet	= strAlertName + "의 값은 한글만 입력할수 있습니다.";
			}
		}

		if(!blsRet && blsSp == true)
		{
			var regSp	= /[~!@\#$%^&*\()\-=+_'\"]/gi; 
			if(!regSp.test(strValue))
			{
				blsRet	= true;
				strRet	= strAlertName + "의 값은 특수문자만 입력할수 있습니다.";
			}
		}
	}
	else
	{
		switch(strType.toLowerCase())
		{
			case "id":
				nMinsize	= nMinsize == 0 ? 3 : nMinsize;
				nMaxSize	= nMaxSize == 0 ? 20 : nMaxSize;
				blsRet		= fnCheckForm(objForm, strName, strAlertName, "", nMinsize, nMaxSize, true);

				if(!blsRet && strValue.search(/[^a-zA-Z]/) == 0)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 입력값은 영문으로 시작해야 합니다.";
				}
				else if(!blsRet && strValue.search(/[^a-zA-Z0-9_-]/) != -1)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 입력값은 영문과 숫자로만 입력해야합니다.";
				}

				break;
			
			case "password":
				nMinsize	= nMinsize == 0 ? 5 : nMinsize;
				nMaxSize	= nMaxSize == 0 ? 20 : nMaxSize;
				blsRet		= fnCheckForm(objForm, strName, strAlertName, "", nMinsize, nMaxSize, true);

				break;

			case "repassword":
				if(!blsRet && strValue != strValue2)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 값이 잘못되었습니다.";
				}

				break;

			case "url":
				blsRet		= fnCheckForm(objForm, strName, strAlertName, "", 0, 0, blsNotEmpty);

				var regUrl	= new RegExp("(http|https|ftp|telnet|news|irc)://([-/.a-zA-Z0-9_~#%$?&=:200-377()]+)","gi");
				if(!blsRet && strValue != "" && strValue.search(regUrl) == -1)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 입력값은 홈페이지 주소형식으로 작성하셔야 합니다.\n예) http://aaaa.co.kr";
				}

				break;
			
			case "email":
				blsRet		= fnCheckForm(objForm, strName, strAlertName, "", 0, 0, blsNotEmpty);

				var regEmail	= new RegExp("([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)","");
				if(!blsRet && strValue != "" && strValue.search(regEmail) == -1)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 입력값은 이메일 주소 형식으로 작성하셔야 합니다.\n예) bbbb@aaaa.co.kr";
				}

				break;

			case "tel":
				blsRet		= fnCheckForm(objForm, strName, strAlertName, "", 0, 0, blsNotEmpty);

				var regTel	= new RegExp("([0-9]{2,4})\-([0-9]{3,4})\-([0-9]{3,4})");
				if(!blsRet && strValue != "" && strValue.search(regTel) == -1)
				{
					blsRet	= true;
					strRet	= strAlertName + "의 입력값은 전화번호 형식으로 작성하셔야 합니다.\n예) 010-1234-5678";
				}
				break;

			default:
				
				break;
		}
	}

	if(blsRet && strRet != "")
	{
		if(strThisType == "select" || strThisType == "radio" || strThisType == "checkbox")
			strRet	= strRet.replace(/입력/gi, "선택");

		if(strExample != "")
			strRet	= strRet +"\n"+ strExample;

		alert(strRet);
		try
		{
			objThis.focus();
		}
		catch(e){}
	}

	return blsRet;
}





// 기본 input형에 타입별 스타일 시트 주기
function fnFormInputClassName()
{
	var strType;
	var blsReadonly;
	var strClassName;
	var strBuf		= "";
	var arrInput		= xGetElementsByTagName("input");
	for(var i=0; i<arrInput.length; i++)
	{
		strClassName		= xGetAttribute(arrInput[i], "className");
		strType				= xGetAttribute(arrInput[i], "type");
		blsReadonly		= xGetAttribute(arrInput[i], "readonly");

		strClassName		= strClassName ? strClassName : "";
		if(strType != "")
		{
			strType				= "input_"+ strType;
			if(strClassName.search(strType) < 0)
			{
				strClassName	 = strClassName.length > 0 ? strClassName + ' ' + strType : strType;
			}
		}

		if(blsReadonly)
		{
			strBuf				= "input_readonly";
			if(strClassName.search(strBuf) < 0)
			{
				strClassName	 = strClassName.length > 0 ? strClassName + ' ' + strBuf : strBuf;
			}
		}

		if(strClassName != "")
		{
			xSetAttribute(arrInput[i], "className", strClassName);
		}
	}
}
/*xAddEventListener(window, "load", fnFormInputClassName);*/



// 체크박스 입력된 이름들 선택
// 입력값 순서대로 계속 입력 : 이름, 값(선택할values | true<전체선택> | false<전체해제>), 선택할values의구분자
function fnCheckboxCheckAll()
{
	if(!fnCheckboxCheck)
		return;

	if(arguments.length > 0)
	{
		for(var i=0; i<arguments.length; i+=3)
		{
			fnCheckboxCheck(arguments[i], arguments[i+1], arguments[i+2]);
		}
	}
}


// 체크박스 전체선택, 전체해제 처리
function fnCheckboxCheck(strName, blsChecked, strSplitString)
{
	strSplitString	= strSplitString ? strSplitString : "";

	var arrList	= xGetElementsByName(strName);
	for(var i=0; i<arrList.length; i++)
	{
		if(arrList[i])
		{
			if((arrList[i].tagName.toLowerCase() || "") == "input" && (arrList[i].type.toLowerCase() || "") == "checkbox")
			{
				if(typeof(blsChecked) == "boolean")
				{
					arrList[i].checked	= blsChecked;
				}
				else if(typeof(blsChecked) == "string" && strSplitString == "")
				{
					if(arrList[i].value.trim() == blsChecked.trim())
						arrList[i].checked	= true;
					else
						arrList[i].checked	= false;
				}
				else if(typeof(blsChecked) == "string" && strSplitString != "")
				{
					var arrValue	= blsChecked.split(strSplitString);
					var blsResult	= false;
					for(var j=0; j<arrValue.length; j++)
					{
						if(arrList[i].value.trim() == arrValue[j].trim())
							blsResult	= true;
					}
					
					arrList[i].checked	= blsResult;
				}
				else if(typeof(blsChecked) == "number")
				{
					if(arrList[i].value == blsChecked)
						arrList[i].checked	= true;
					else
						arrList[i].checked	= false;
				}
			}
		}
	}
}


// 셀렉트 박스 옵션 추가
function fnAddOption(objSelect, strText, strValue, blsSelected)
{
	if(typeof(objSelect) != 'object')
		return;

	blsSelected	= blsSelected ? blsSelected : false;

	var objOption	= xCreateElement("option");
	objOption.value		= strValue;
	objOption.text			= strText;
	objOption.selected	= blsSelected;
	xSelectboxAddOption(objSelect, objOption);

	return objOption;
}

// 셀렉트 박스 옵션 모두 삭제
function fnDeleteOption(objSelect)
{
	if(typeof(objSelect) != 'object')
		return;

	if(objSelect.tagName)
	{
		if(objSelect.tagName.toLowerCase() != "select")
			return;
	}

	var dwLength	= objSelect.options.length;
	if(dwLength > 0)
	{
		for(var i=(dwLength-1); i>= 0; i--)
		{
			objSelect.remove(i);
		}
	}
}



// 폼내부 자식에 값 삽입
function fnInsertFormValue(objForm, strInputname, strValue)
{
	objForm			= xGetElementById(objForm);
	if(!objForm) return;

	var objInput	= objForm[strInputname] ? objForm[strInputname] : null;
	if(!objInput) return;

	var dwLength	= objInput.length ? objInput.length : 1;
	if(dwLength == 1)
	{
		var strType	= objInput.type ? objInput.type.toLowerCase() : "";
		if(strType == "") return;

		if(strType == "text" || strType == "hidden")
			objInput.value		= strValue;
		else if(strType == "select-one" || strType == "select-multiple")
		{
			for(var i=0; i<objInput.options.length; i++)
			{
				if(objInput.options[i].value == strValue)
				{
					objInput.options[i].selected		= true;
					break;
				}
			}
		}
		else if(strType == "radio")
		{
			if(objInput.value.trim() == strValue.trim())
			{
				objInput.checked		= true;
			}
		}
		else if(strType == "checkbox")
		{
			var arrValue	= strValue.split(",");
			for(var i=0; i<arrValue.length; i++)
			{
				if(objInput.value.trim() == arrValue[i].trim())
				{
					objInput.checked		= true;
					break;
				}
			}
		}
	}
	else
	{
		var strType	= objInput[0].type ? objInput[0].type : "";
		if(strType == "") return;

		if(strType == "radio")
		{
			for(var i=0; i<objInput.length; i++)
			{
				if(objInput[i].value.trim() == strValue.trim())
				{
					objInput[i].checked		= true;
					break;
				}
			}
		}
		else if(strType == "checkbox")
		{
			var arrValue	= strValue.split(",");
			for(var i=0; i<objInput.length; i++)
			{
				for(var j=0; j<arrValue.length; j++)
				{
					if(objInput[i].value.trim() == arrValue[j].trim())
					{
						objInput[i].checked		= true;
						break;
					}
				}
			}
		}
	}
}

// 폼내부 자식에 값 추출
function fnGetFormValue(objForm, strInputname)
{
	var ReturnValue	= "";

	objForm				= xGetElementById(objForm);
	if(!objForm) return "";

	var objInput	= objForm[strInputname] ? objForm[strInputname] : null;
	if(!objInput) return "";

	var dwLength	= 1;
	if(objInput.tagName)
		dwLength	= 1;
	else
		dwLength	= objInput.length ? objInput.length : 1;

	if(dwLength == 1)
	{
		var strType	= objInput.type ? objInput.type.toLowerCase() : "";
		if(strType == "") return "";

		if(strType == "text" || strType == "hidden")
			ReturnValue	= objInput.value;
		else if(strType == "select-one" || strType == "select-multiple")
		{
			ReturnValue	= "";
			for(var i=0; i<objInput.options.length; i++)
			{
				if(objInput.options[i].selected)
				{
					ReturnValue	+= (ReturnValue != "" ? "," : "") + objInput.options[i].value;
				}
			}
		}
		else if(strType == "radio")
		{
			if(objInput.checked)
			{
				ReturnValue	= objInput.value;
			}
		}
		else if(strType == "checkbox")
		{
			if(objInput.checked)
			{
				ReturnValue	= objInput.value;
			}
		}
	}
	else
	{
		var strType	= objInput[0].type ? objInput[0].type : "";
		if(strType == "") return "";

		if(strType == "radio")
		{
			ReturnValue	= "";
			for(var i=0; i<objInput.length; i++)
			{
				if(objInput[i].checked)
				{
					ReturnValue	+= (ReturnValue != "" ? "," : "") + objInput[i].value;
				}
			}
		}
		else if(strType == "checkbox")
		{
			ReturnValue	= "";
			for(var i=0; i<objInput.length; i++)
			{
				if(objInput[i].checked)
				{
					ReturnValue	+= (ReturnValue != "" ? "," : "") + objInput[i].value;
				}
			}
		}
	}

	return ReturnValue;
}

// 폼내부 자식에 포커스 이동
function fnFormFocus(objForm, strInputname)
{
	objForm			= xGetElementById(objForm);
	if(!objForm) return null;

	var objFormElement	= objForm[strInputname] ? objForm[strInputname] : null;
	if(!objFormElement) return null;
	
	try
	{
		objFormElement.focus();
	}
	catch (e){}

	return objFormElement;
}








/*
	주소찾기
*/
var g_arr_addresssearch_printid		= new Array;
var g_arr_addresssearch_xmlhttp		= new Array;
function addresssearch(strSearchword, strPrintAreaId, strFormId, strInput01, strInput02, strInput03)
{
//	var strUrl		= "/_library/modules/pro_util/?proc=address";
	var strUrl		= "/_library/modules/pro_util/proc.address.asp?proc=address";
	var strForms	= "input_address=";

	strSearchword	= strSearchword ? strSearchword : "";
	strPrintAreaId		= strPrintAreaId ? strPrintAreaId : "";
	strFormId			= strFormId ? strFormId : "";
	strInput01			= strInput01 ? strInput01 : "";
	strInput02			= strInput02 ? strInput02 : "";
	strInput03			= strInput03 ? strInput03 : "";

	if(strPrintAreaId == "" || strFormId == "" || (strInput01 == "" && strInput02 == "" && strInput03 == ""))
		return;

	strForms	+= fnEscape(strSearchword);

	strUrl		+= "&printtype=html_result";
	strUrl		+= "&printid="+ strPrintAreaId;
	strUrl		+= "&formid="+ strFormId;
	strUrl		+= "&zipname="+ strInput01;
	strUrl		+= "&addrname="+ strInput02;
	strUrl		+= "&addrnext="+ strInput03;

	g_arr_addresssearch_printid[g_arr_addresssearch_printid.length]	= strPrintAreaId;
	g_arr_addresssearch_xmlhttp[g_arr_addresssearch_xmlhttp.length]	= fnXmlHttpPost(strUrl, addresssearch_callback, strForms);
}

function addresssearch_callback(objXmlHttp)
{
	var strText	= fnXmlHttpPost_callBack(objXmlHttp);

	if(!strText || strText == "")
		return false;

	var dwIndex		= -1;
	for(var i=0; i<g_arr_addresssearch_xmlhttp.length; i++)
	{
		dwIndex		= i;
	}

	var strPrintArea	= g_arr_addresssearch_printid[dwIndex];
	var objPrintArea	= xGetElementById(strPrintArea);
	if(typeof(objPrintArea) != "object")
		return false;
	innerHTML(objPrintArea, strText);
}



// 폼안의 드롭다운 박스에서 사이트 선택 후 해당 사이트 열기 처리
function fnFormLinkSite_selectbox(objForm, blsNewWindow)
{
	blsNewWindow	= blsNewWindow ? false : true;

	if(!objForm)
		return false;

	var arrSite	= xGetElementsByTagName("select", objForm);

	if(arrSite.length > 0)
	{
		var objSite	= null;
		for(var i=0; i<arrSite.length; i++)
		{
			var strName	= arrSite[i].name ? arrSite[i].name : "";
			if(strName.toLowerCase() == "site")
			{
				objSite	= arrSite[i];
				break;
			}
		}

		if(objSite)
		{
			var strValue	= objSite.options[objSite.options.selectedIndex].value;
			if(strValue != "")
			{
				if(blsNewWindow)
					window.open(strValue);
				else
					location.href	= strValue;
			}
		}
	}
	return false;
}



// 해당 아이디 값에 포커스 주기
function fnFocus(objTarget)
{
	objTarget	= xGetElementById(objTarget);
	if(objTarget)
	{
		try
		{
			objTarget.focus();
		}
		catch (e){}
	}
}



//	이미지 자동 크기 조절
function fnImageAutoResize(objImage, dwMaxWidth, dwMaxHeight)
{
	objImage		= xGetElementById(objImage);
	if(objImage)
	{
		dwMaxWidth		= typeof(dwMaxWidth) == "number" ? dwMaxWidth : xGetAttribute(objImage, 'maxwidth');
		dwMaxHeight		= typeof(dwMaxHeight) == "number" ? dwMaxHeight : xGetAttribute(objImage, 'maxheight');

		if(!dwMaxWidth)
			dwMaxWidth	= 0;

		if(!dwMaxHeight)
			dwMaxHeight	= 0;

		var dwOrignWidth	= objImage.width;
		var dwOrignHeight	= objImage.height;
		var dwNewWidth		= dwOrignWidth;
		var dwNewHeight		= dwOrignHeight;
		var dwResizeRate	= 1;
		var blsCalcEnd		= false;

		if(!blsCalcEnd && dwMaxWidth > 0 && dwOrignWidth > 0)
		{
			dwResizeRate	= dwMaxWidth / dwOrignWidth;

			dwNewWidth		= dwOrignWidth * dwResizeRate;
			dwNewHeight		= dwOrignHeight * dwResizeRate;

			if(dwNewHeight <= dwMaxHeight)
				blsCalcEnd	= true;
		}

		if(!blsCalcEnd && dwMaxHeight > 0 && dwOrignHeight > 0)
		{
			dwResizeRate	= dwMaxHeight / dwOrignHeight;

			dwNewWidth		= dwOrignWidth * dwResizeRate;
			dwNewHeight		= dwOrignHeight * dwResizeRate;
		}

		objImage.width		= parseInt(dwNewWidth, 10);
		objImage.height		= parseInt(dwNewHeight, 10);
	}
}