//==============================================================================
//  °³¿ä        :  °£´ÜÇÑ AJAX ±¸µ¿ ¶óÀÌºê·¯¸®
//  Á¦ÀÛÀÚ      :  À±È£
//  URL         :  http://ho.dunggy.net/js/jslib_ho.js
//  ¹öÀüÁ¤º¸    :  2006.11.17 10:23
//  »ç¿ëÈ¯°æ    :  IE 6.0, Firefox 2.0 (charset=EUC-KR)
//  Âü°í»çÇ×    :  Toshirou TakahashiÀÇ jslb_ajax050_c.js°¡ Æ÷ÇÔµÇ¾î ÀÖÀ½
//------------------------------------------------------------------------------
//
// ***** ÀÚµ¿°Ë»ö *****
// ajaxInitSearch(keyObj, varURL, [strOptions (option1=100; option2=200; ...)], [callback]);
// **** ÆÄ¾÷Ã¢ ****
// ajaxInitPopup(keyObj, varURL, [strOptions (option1=100; option2=200; ...)], [callback]);
// **** iframe ÆÄ¾÷Ã¢ ****
// iframeInitPopup (keyObj, varURL, [strOptions (option1=100; option2=200; ...)]);
//
//		keyObj     : ajax ¼­ºñ½º È£Ãâ objectÀÇ id 
//                ('Data'¶ó´Â ´Ü¾î°¡ Æ÷ÇÔµÇ¸é ¾ÈµÊ, iframeInitPopup()ÀÇ °æ¿ì 'iframe'À¸·Î ½ÃÀÛµÇ´Â ´Ü¾î¿©¾ß ÇÔ)
//		url        : ajax ¼­ºñ½º¸¦ ½ÇÇàÇÒ script file name
//		X, Y       : ajax µ¥ÀÌÅÍ°¡ µé¾î°¥ divÀÇ ÁÂÇ¥ (integer)
//		W, H       : ajax µ¥ÀÌÅÍ°¡ µé¾î°¥ divÀÇ Å©±â (integer)
//		dX, dY     : IE¿Í mozillaÀÇ ÁÂÇ¥ º¸Á¤Ä¡ (mozilla¿ë µ¥ÀÌÅÍ) (integer)
//		dW, dH     : IE¿Í mozillaÀÇ Å©±â º¸Á¤Ä¡ (mozilla¿ë µ¥ÀÌÅÍ) (integer)
//		maxW, maxH : ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ÃÖ´ë Å©±â 																		[ajaxInitPopup, iframeInitPopup]
//		maxP       : ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ Å©±â º¯È­½Ã ±âÁØ¹æ½Ä (C, LT, LB, RT, RB)			[ajaxInitPopup, iframeInitPopup]
//		layer      : ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ zIndex (integer)
//		border     : ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ border (integer)
//		bordercolor: ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ borderColor
//		borderstyle: (dotted, dashed, solid, double, groove, ridge, inset, outset)
//		titlebar   : ajax µ¥ÀÌÅÍÃ¢(div)¿¡ titlebar Ç¥½Ã ¿©ºÎ(0, 1)											[ajaxInitPopup, iframeInitPopup]
//		titlecolor : ajax µ¥ÀÌÅÍÃ¢(div) titlebarÀÇ »ö																		[ajaxInitPopup, iframeInitPopup]
//		background : ajax µ¥ÀÌÅÍ°¡ µé¾î°¥ divÀÇ background color
//		foreground    : ajax µ¥ÀÌÅÍÀÇ highligh color -- anaxInitSearch only
//		hide       : ajax µ¥ÀÌÅÍ°¡ ¾øÀ» ¶§, div¸¦ ´ÝÀ»Áö ¿©ºÎ (0, 1)										[anaxInitSearch]
//		force      : ajax µ¥ÀÌÅÍ°¡ ÇÏ³ªÀÏ ¶§, È£Ãâ objectÀÇ °ªÀ» °­Á¦µ¿±âÈ­ÇÒÁö ¿©ºÎ (0, 1)
//		             (keyObjÀÇ °ªÀÌ ÇÑ±Û»ÓÀÏ ¶§¿¡´Â ¿Àµ¿ÀÛ)															[anaxInitSearch]
//		trigger    : ajax ¼­ºñ½º¸¦ È£ÃâÇÒ event ('click', 'mouseover', 'focus')					[ajaxInitPopup, iframeInitPopup]
//		scrollbar  : ajax µ¥ÀÌÅÍ°¡ µé¾î°¥ divÀÇ scrollbar ('auto', 'scroll', 'hidden')	[ajaxInitPopup, iframeInitPopup]
//		mspopup    : IEÀÇ createPopup method¸¦ »ç¿ëÇÒÁö ¿©ºÎ (0, 1)  										[ajaxInitPopup]
//		clear      : ¿­·Á ÀÖ´Â µ¥ÀÌÅÍÃ¢µéÀ» ´ÝÀ»Áö ¿©ºÎ (1, 0)	  											[ajaxInitPopup, iframeInitPopup]
//		keep       : clear½Ã µ¥ÀÌÅÍÃ¢À» ´ÝÁö ¾Ê°í ³²°ÜµÑÁö ¿©ºÎ (0, 1)									[ajaxInitPopup, iframeInitPopup]
//		interval   : ajax ¹Ýº¹ È£Ãâ½Ã ½Ã°£ °£°Ý(ÃÊ) (integer) 													[ajaxInitPopup, iframeInitPopup]
//		callback   : anax µ¥ÀÌÅÍ ¼ö½Å½Ã ½ÇÇàÇÒ callback ÇÔ¼ö 														[ajaxInitSearch, ajaxInitPopup]
//                 (function objectÀÌ¹Ç·Î µû¿ÈÇ¥ ¾øÀÌ Ç¥±âÇØ¾ß ÇÔ)
//
// ***** ÀÚµ¿°Ë»ö µ¥ÀÌÅÍ Çü½Ä (charset=UTF-8, {}·Î °¨½Ñ ºÎºÐ¿¡ ÀûÀýÇÑ °ªÀ» ³ÖÀ» °Í) *****
// :::::{keyObj}:::::
// <DIV title='{µ¥ÀÌÅÍ°ª}' alt='{}'
//  STYLE="font:10pt Arial; padding-left:4px; padding-top:3px; padding-bottom:3px; cursor:hand;"
// >{µ¥ÀÌÅÍ°ª}</DIV>
// ***** ÆË¾÷Ã¢ÀÇ Çü½Ä (charset=UTF-8, {}·Î °¨½Ñ ºÎºÐ¿¡ ÀûÀýÇÑ °ªÀ» ³ÖÀ» °Í) *****
// :::::{keyObj}:::::
// <DIV>{HTML}</DIV>
//
// µ¥ÀÌÅÍ ¸»´Ü¿¡ '<@ javascript code @>' ¸¦ ³ÖÀ¸¸é javascript code°¡ ½ÇÇàµÊ
//
//jslb_ajax050 2.652k @see http://jsgt.org/mt/archives/01/000409.html

function chkAjaBrowser(){var a,ua=navigator.userAgent;this.bw={safari:((a=ua.split('AppleWebKit/')[1])?a.split('(')[0]:0)>=124,konqueror:((a=ua.split('Konqueror/')[1])?a.split(';')[0]:0)>=3.3,mozes:((a=ua.split('Gecko/')[1])?a.split(" ")[0]:0)>=20011128,opera:(!!window.opera)&&((typeof XMLHttpRequest)=='function'),msie:(!!window.ActiveXObject)?(!!createHttpRequest()):false};return(this.bw.safari||this.bw.konqueror||this.bw.mozes||this.bw.opera||this.bw.msie)};function createHttpRequest(){if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e2){return null;}}}else{return null;}};function sendRequest(callback,data,method,url,async,sload,user,password){sendRequest.prototype.README={url:"http://jsgt.org/mt/archives/01/000409.html",name:"sendRequest",version:0.50,license:"Public Domain",author:"Toshiro Takahashi http://jsgt.org/mt/01/",memo:""};var oj=createHttpRequest();if(oj==null)return null;var sload=(!!sendRequest.arguments[5])?sload:false;if(sload||method.toUpperCase()=='GET')url+="?";if(sload)url=url+"t="+(new Date()).getTime();var bwoj=new chkAjaBrowser();var opera=bwoj.bw.opera;var safari=bwoj.bw.safari;var konqueror=bwoj.bw.konqueror;var mozes=bwoj.bw.mozes;if(typeof callback=='object'){var callback_onload=callback.onload;var callback_onbeforsetheader=callback.onbeforsetheader}else{var callback_onload=callback;var callback_onbeforsetheader=null;};if(opera||safari||mozes){oj.onload=function(){callback_onload(oj);}}else{oj.onreadystatechange=function(){if(oj.readyState==4){callback_onload(oj);}}};data=uriEncode(data,url);if(method.toUpperCase()=='GET'){url+=data};oj.open(method,url,async,user,password);if(!!callback_onbeforsetheader)callback_onbeforsetheader(oj);setEncHeader(oj);oj.send(data);function setEncHeader(oj){var contentTypeUrlenc='application/x-www-form-urlencoded; charset=UTF-8';if(!window.opera){oj.setRequestHeader('Content-Type',contentTypeUrlenc);}else{if((typeof oj.setRequestHeader)=='function')oj.setRequestHeader('Content-Type',contentTypeUrlenc);};return oj};function uriEncode(data,url){var encdata=(url.indexOf('?')==-1)?'?dmy':'';if(typeof data=='object'){for(var i in data)encdata+='&'+encodeURIComponent(i)+'='+encodeURIComponent(data[i]);}else if(typeof data=='string'){if(data=="")return"";var encdata='';var datas=data.split('&');for(i=1;i<datas.length;i++){var dataq=datas[i].split('=');encdata+='&'+encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[1]);}};return encdata;};return oj}

	var divIndex = new Array(); //ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ÀÌ¸§(id)¸¸ ÀúÀå (ÀüÃ¼ Ã¢ ¸ñ·ÏÀ» ¾ò±â À§ÇØ »ç¿ë)
	var divData = new Array(); //ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ÀÌ¸§(id)°ú ¸î¸î º¯¼ö°ªÀ» ÀúÀå (object ÀÚÃ¼´Â oDiv)
	var divStyle = new Array();	//ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ½ºÅ¸ÀÏ º¯¼ö°ªÀ» ÀúÀå
	var resURL = new Array(); //È£ÃâÇÒ server side script(php, asp µî)
	var oDiv = new Array(); //ajax µ¥ÀÌÅÍÃ¢(divData) object¸¦ ÇÒ´çÇÒ ¹è¿­º¯¼ö
	var oPopup = null; //explorer¿ë popupÃ¢
	var t = null; //setInterval()ÀÇ ¸®ÅÏ°ª
	var dragApproved = 0;
	var dragObj = null;

	if (document.all) {
		var isIE = 1;
		oPopup = window.createPopup();
	} else {
		var isIE = 0;
	}

	function ajaxMakeDiv(keyObj, X, Y, W, H, dX, dY, dW, dH, layer, border, borderstyle, bordercolor, background, scrollbar, mspopup) {
		if (!isIE) {X+=dX; Y+=dY;}
		if (!isIE) mspopup = 0; //mozilla¿¡¼­´Â createPopup method¸¦ »ç¿ëÇÒ ¼ö ¾øÀ½

		divStyle[keyObj+'X'] = X;
		divStyle[keyObj+'Y'] = Y;
		divStyle[keyObj+'W'] = W;
		divStyle[keyObj+'H'] = H;
		divStyle[keyObj+'eX'] = 0;
		divStyle[keyObj+'eY'] = 0;
		divStyle[keyObj+'MS'] = mspopup;
		
		if (!document.getElementById(divData[keyObj])) {
			oDiv[divData[keyObj]]=document.createElement('DIV');
			oD = oDiv[divData[keyObj]];
			document.body.appendChild(oD);
			oD.setAttribute('id', divData[keyObj]);
			oD.setAttribute('autocomplete','off');
			divIndex[divIndex.length] = divData[keyObj];
			
			oD.style.display = 'none';
			oD.style.position = 'absolute';
			oD.style.border = border+'px '+bordercolor+' '+borderstyle;
			oD.style.zIndex = layer;
			if (scrollbar == 'scroll') {
				oD.style.overflow = 'scroll'; 
				oD.style.overflowX = 'hidden'; 
			} else if (scrollbar == 'hidden') {
				oD.style.overflow = 'hidden';
			} else {
				oD.style.overflow = 'auto';
			} 
			oD.style.background = background; 

			if (isIE) {
				if (mspopup) {
					oD.style.top = 0;
					oD.style.left = 0;
				} else {
					oD.style.top = Y;
					oD.style.left = X;
				}
				oD.style.width = W;
				oD.style.height = H;
				oD.style.scrollbarFaceColor = '#efefef';
				oD.style.scrollbarShadowColor = '#999999';
				oD.style.scrollbarHighlightColor = '#999999';
				oD.style.scrollbar3dLightColor = '#ffffff';
				oD.style.scrollbarDarkshadowColor = '#ffffff';
				oD.style.scrollbarTrackColor = '#ffffff';
				oD.style.scrollbarArrowColor = '#ffffff';
			} else if (navigator.product == 'Gecko') {
				oD.style.top = Y;
				oD.style.left = X;
				oD.style.width = W + dW;
				oD.style.height = H + dH;
			}
		}
	}

	function ajaxInitSearch(keyObj, url, strOptions, callback) {
		X=0; Y=0; W=200; H=150; dX=0; dY=0; dW=0; dH=0; layer=5; 
		border=0; borderstyle='solid'; bordercolor='gray'; background='#FFFFFF'; foreground='#EEEEEE'; 
		hide=0; force=0; clear=0; mspopup=1; test=0;
		eval(strOptions);

		resURL[keyObj] = url;
		divData[keyObj] = keyObj + 'Data'; //ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ÀÌ¸§(id)
		divData[keyObj+'T'] = null; //setInterval()ÀÇ ¸®ÅÏ°ª
		divStyle[keyObj+'ColorHL'] = foreground;
		if (force) divStyle[keyObj+'Force'] = force;
		if (!hide) hide = 0;
		divStyle[keyObj+'Hide'] = hide;
		divStyle[keyObj+'Close'] = 1;
		divStyle[keyObj+'Clear'] = clear;
		if (callback) divData[keyObj+'Call'] = callback;
		if (test) divData[keyObj+'Test'] = test;

		ajaxMakeDiv(keyObj, X, Y, W, H, dX, dY, dW, dH, layer, border, borderstyle, bordercolor, background, 'scroll', 1);
		oD = oDiv[divData[keyObj]];           //ajax µ¥ÀÌÅÍ object
		oS = document.getElementById(keyObj); //ajax È£Ãâ object
		if (isIE) {
			oS.attachEvent('onkeydown',myKeyPress);
		} else if (navigator.product == 'Gecko') {
			oD.addEventListener('click',mySearchEvent,false);
			oD.addEventListener('mouseover',mySearchEvent,false);
			oD.addEventListener('mouseout',mySearchEvent,false);
			oS.addEventListener('keydown',myKeyPress,false);
			oS.addEventListener('blur',mySearchEvent,false);
		}
	}

	function ajaxInitPopup(keyObj, url, strOptions, callback) {
		X=0; Y=0; W=200; H=100; dX=0; dY=0; dW=0; dH=0; maxW='800'; maxH='600'; maxP='C'; layer=5; 
		border=0; borderstyle='solid'; bordercolor='gray'; titlebar=0; titlebarcolor='silver';
		background='#f8f8ef'; foreground='#ffffff'; scrollbar='auto'; 
		trigger='click'; clear=0; keep=0; interval=0; mspopup=0; test=0;
		eval(strOptions);

		resURL[keyObj] = url;
		divData[keyObj] = keyObj + 'Data'; //ajax µ¥ÀÌÅÍÃ¢(div)ÀÇ ÀÌ¸§(id)
		divData[keyObj+'T'] = null; //setInterval()ÀÇ ¸®ÅÏ°ª
		divData[keyObj+'Interval'] = interval * 1000;
		if (trigger) {divData[keyObj+'Event'] = trigger;} else {divData[keyObj+'Event'] = 'click';}
		divStyle[keyObj+'ColorHL'] = foreground;
		divStyle[keyObj] = 1;
		divStyle[keyObj+'Close'] = 1;
		divStyle[keyObj+'Clear'] = clear;
		divStyle[keyObj+'Keep'] = keep;
		divStyle[keyObj+'BorderColor'] = bordercolor;
		divStyle[keyObj+'TitleBar'] = titlebar;
		divStyle[keyObj+'TitleBarColor'] = titlebarcolor;
		divStyle[keyObj+'Max'] = 0;
		divStyle[keyObj+'MaxW'] = maxW;
		divStyle[keyObj+'MaxH'] = maxH;
		divStyle[keyObj+'MaxP'] = maxP;
		if (callback) divData[keyObj+'Call'] = callback;
		if (test) divData[keyObj+'Test'] = test;
				
		ajaxMakeDiv(keyObj, X, Y, W, H, dX, dY, dW, dH, layer, border, borderstyle, bordercolor, background, scrollbar, mspopup);
		oD = oDiv[divData[keyObj]];           //ajax µ¥ÀÌÅÍ object
		oS = document.getElementById(keyObj); //ajax È£Ãâ object
		if (isIE) {
			oS.attachEvent('on'+divData[keyObj+'Event'],myPopupEvent);
			if (!divStyle[keyObj+'MS']) 
				oS.attachEvent('onblur',myPopupEvent);
			if (divData[keyObj+'Event'] == 'mouseover') {
				oS.attachEvent('onmouseout',myPopupEvent);
				oD.attachEvent('onmouseover',myPopupEvent);
				oD.attachEvent('onmouseout',myPopupEvent);
			}
			if (divData[keyObj+'Event'] == 'focus') {
				oS.attachEvent('onkeydown',myKeyPress);
				if (!divStyle[keyObj+'MS']) {
					oD.attachEvent('onclick',mySearchEvent);
					oD.attachEvent('onmouseover',mySearchEvent);
					oD.attachEvent('onmouseout',mySearchEvent);
				}
			}
		} else if (navigator.product == 'Gecko') {
			oS.addEventListener(divData[keyObj+'Event'],myPopupEvent,false);
			oS.addEventListener('blur',myPopupEvent,false);
			if (divData[keyObj+'Event'] == 'mouseover') {
				oS.addEventListener('mouseout',myPopupEvent,false);
				oD.addEventListener('mouseover',myPopupEvent,false);
				oD.addEventListener('mouseout',myPopupEvent,false);
			}
			if (divData[keyObj+'Event'] == 'focus') {
				oS.addEventListener('keydown',myKeyPress,false);
				oD.addEventListener('click',mySearchEvent,false);
				oD.addEventListener('mouseover',mySearchEvent,false);
				oD.addEventListener('mouseout',mySearchEvent,false);
			}
		}
	}

	function myPopupEvent(event) {
		if (isIE) {
			srcObj = event.srcElement; //event¸¦ ¹ß»ý½ÃÅ² object
		} else {
			srcObj = event.target; //event¸¦ ¹ß»ý½ÃÅ² object
		}
		srcObjName = srcObj.getAttribute('id');
		//µ¥ÀÌÅÍÃ¢¿¡ mouseover½Ã ajax È£Ãâ objectÀÇ ÀÌ¸§(triggerObjName)ÀÌ ÇÊ¿äÇÔ
		//ajax È£Ãâ object¿¡ mouseover½Ã¿¡´Â triggerObjName°ú srcObjNameÀÌ °°À½
		triggerObjName = srcObjName.replace(/Data|Selected/g, ''); 

		if (event.type == 'click' || event.type == 'mouseover') {
			divStyle[triggerObjName+'eX'] = event.clientX;
			divStyle[triggerObjName+'eY'] = event.clientY;
			if (event.type == 'click') {
				if (oDiv[divData[triggerObjName]].style.display=='none') { //µ¥ÀÌÅÍÃ¢ÀÌ ¿­·Á ÀÖÁö ¾ÊÀ» °æ¿ì
					if (!divStyle[triggerObjName+'MS']) divStyle[triggerObjName+'Close'] = 0;
					runPopup(triggerObjName);
				} else {
					divStyle[triggerObjName+'Close'] = 1;
					ajaxClose(triggerObjName);
				}
			}
			if (event.type == 'mouseover') {
				if (srcObjName == triggerObjName) { //È£Ãâ object¿¡ mouseover½Ã
					srcObj.focus();
				} else if (srcObjName.match(/Data$/)) {
					divStyle[triggerObjName+'Close'] = 0; 
				}
				runPopup(triggerObjName);
			}
		}
		if (event.type == 'focus') runPopup(triggerObjName);
		if ((event.type == 'blur' || event.type == 'mouseout')) {
			if (divStyle[triggerObjName+'Close']) {
				ajaxClose(triggerObjName);
			} else if (srcObjName.match(/Data$/)) {
				if (divData[triggerObjName+'Event'] == 'mouseover') {
					divStyle[triggerObjName+'Close'] = 1;
					ajaxClose(triggerObjName);
				}
			}
		}
	}
	
	function runPopup(objName) {
		interval = divData[objName+'Interval'];
		if (objName.substr(0,6)=='iframe') { //iframeInitPopup function¿¡ ÀÇÇØ È£ÃâµÇ¾úÀ» °æ¿ì
			iframeRequestPopup(objName);
			if (interval) divData[objName+'T'] = setInterval("iframeRequestPopup('"+objName+"')", interval);
		} else {
			ajaxRequestPopup(objName);
			if (interval) divData[objName+'T'] = setInterval("ajaxRequestPopup('"+objName+"')", interval);
		}
	}
	
	function mySearchEvent(event) {
		//srcObj, srcObjNameÀº myKeyPress function¿¡¼­ Á¤ÀÇµÇ¾úÀ½ (input object¿Í id)

		if (event.type == 'mouseover') divStyle[srcObjName+'Close']=0; //Ã¢ÀÌ ´ÝÈ÷Áö ¾Ê°Ô ¼³Á¤ (ÀÌ·¸°Ô ÇØ¾ß Å¬¸¯°¡´É)
		if (event.type == 'click') {
			if (divData[srcObjName+'T']) clearInterval(divData[srcObjName+'T']);
			if (divStyle[srcObjName+'MS'] && oPopup.isOpen) {
				oPopup.hide();
			} else {
				ajaxClose(srcObjName);
				document.getElementById(srcObjName).focus();
			}
		}
		if (event.type == 'mouseout') divStyle[srcObjName+'Close']=1; //Ã¢ÀÌ ´ÝÈ÷°Ô ¼³Á¤

		if (event.type == 'blur' && divStyle[srcObjName+'Close']) {
	 		if (divData[srcObjName+'T']) clearInterval(divData[srcObjName+'T']);
			ajaxClose(srcObjName);
		}
	}

	function myKeyPress(event) {
		if (isIE) {
			srcObj = event.srcElement; //event¸¦ ¹ß»ý½ÃÅ² object
		} else {
			srcObj = event.target; //event¸¦ ¹ß»ý½ÃÅ² object
		}
		srcObjName = srcObj.getAttribute('id');
 		if (divData[srcObjName+'T']) clearInterval(divData[srcObjName+'T']);

		if (divStyle[srcObjName+'MS']) {
			//objRoot = oPopup.document;
			oD = oPopup.document.getElementById(divData[srcObjName]);
			oH = oPopup.document.getElementById(srcObjName+'HL');
		} else {
			//objRoot = document;
			oD = document.getElementById(divData[srcObjName]);
			oH = document.getElementById(srcObjName+'HL');
		}

		if (event.keyCode == 40)	{ //down Å°
			if (divStyle[srcObjName+'MS'] && !oPopup.isOpen) return;
			highlight = oH;
			if (!highlight) {
				highlight = oD.firstChild;
			}	else if (highlight != oD.lastChild) {
				highlight.removeAttribute('id');
				highlight.style.background = '';
				highlight = highlight.nextSibling;
				if (!isIE) highlight = highlight.nextSibling;

				/*2011-07-07 Ãß°¡*/
				highlight.removeAttribute('id');
				if (srcObj.type.match(/text/)) srcObj.value = highlight.getAttribute('title');
				if (document.getElementById(srcObjName+'Alt'))
					document.getElementById(srcObjName+'Alt').value = highlight.getAttribute('alt');
				/*Ãß°¡ ³¡*/
			}
			if (highlight) {
				highlight.setAttribute('id',srcObjName+'HL');
				highlight.style.background = divStyle[srcObjName+'ColorHL'];
				highlight.scrollIntoView(false);
			}
			if (!isIE) event.preventDefault();
		}	else if (event.keyCode == 38 ) { //up Å°
			if (divStyle[srcObjName+'MS'] && !oPopup.isOpen) return;
			highlight = oH;
			if (!highlight) {
				highlight = oD.lastChild;
			}	else if (highlight != oD.firstChild) {
				highlight.removeAttribute('id');
				highlight.style.background = '';
				highlight = highlight.previousSibling;
				if (!isIE) highlight = highlight.previousSibling;

				/*2011-07-07 Ãß°¡*/
				highlight.removeAttribute('id');
				if (srcObj.type.match(/text/)) srcObj.value = highlight.getAttribute('title');
				if (document.getElementById(srcObjName+'Alt'))
					document.getElementById(srcObjName+'Alt').value = highlight.getAttribute('alt');
				/*Ãß°¡ ³¡*/
			} if (highlight) {
				highlight.setAttribute('id',srcObjName+'HL');
				highlight.style.background = divStyle[srcObjName+'ColorHL'];
				highlight.scrollIntoView(false);
			}	
			if (!isIE) event.preventDefault();
		} else if (event.keyCode == 27) { //ESC Å°
			highlight = oH;
			if (highlight) highlight.removeAttribute('id');
			ajaxClose(srcObjName);
		} else if (event.keyCode == 13 || event.keyCode == 9) { //Enter, Tab Å°
			highlight = oH;
			if (highlight) {
				highlight.removeAttribute('id');
				if (srcObj.type.match(/text/)) srcObj.value = highlight.getAttribute('title');
				if (document.getElementById(srcObjName+'Alt'))
					document.getElementById(srcObjName+'Alt').value = highlight.getAttribute('alt');
			}
			ajaxClose(srcObjName);
		} else if (!srcObj.readOnly) {
			divData[srcObjName+'T'] = setInterval("runSearch('"+srcObjName+"')", 100);
		} else {
			//alert(event.keyCode);
		}
	}

	function runSearch(objName) {
		if (divData[objName+'LastQ'] != document.getElementById(objName).value) {
			ajaxRequestSearch(objName);
			if (isIE && divData[srcObjName+'T']) clearInterval(divData[srcObjName+'T']); //IE´Â ÇÑ¹ø¸¸, mozilla´Â °è¼Ó ¹Ýº¹
		}
		divData[objName+'LastQ'] = document.getElementById(objName).value;
	}

	function ajaxRequestSearch(objName) {
		if (divStyle[objName+'Clear']) {
			if (divStyle[objName+'Hide']) {
				ajaxClose();
			} else {
				ajaxClose('^'+objName);
			}
		}				
		var val = document.getElementById(objName).value;
		if (val) {
			if (document.getElementById(objName+'Alt')) 
				document.getElementById(objName+'Alt').value=document.getElementById(objName+'Alt').value;	//	document.getElementById(objName+'Alt').value='';
			if (objName.substr(objName.length-3)=='Alt' && document.getElementById(objName.substr(0,objName.length-3))) 
				document.getElementById(objName.substr(0,objName.length-3)).value='';
			if (divData[objName+'Call']) {
				callback = divData[objName+'Call'];
			} else {
				callback = onLoaded;
			}
			sendRequest(callback,'&ajax='+objName+'&sc='+document.getElementById(objName+'Alt').value+'&q='+val,'GET',resURL[objName],true,true);
		} else if (divData[objName+'Event'] != 'focus') {
			ajaxClose(objName);
		}
	}

	function ajaxRequestPopup(objName, url) {
		if (divStyle[objName+'Clear']) ajaxClose();
		if (!url) {
			resScriptName = resURL[objName].split('?');
		} else {
			resScriptName = url.split('?');
		}
		resVars = '';
		if (resScriptName[1]) {
			resQueryString = resScriptName[1].split('&');
			resVarCount = resQueryString.length;
			resVars = '';
			for (i=0;i<resVarCount;i++) {
				var temp = resQueryString[i].split('=');
				if (temp[1].substr(0,1) == '{') {
					temp[1] = eval(temp[1]);
					resVars += '&'+temp[0]+'='+temp[1];
				} else {
					resVars += '&'+resQueryString[i];
				}
			}
		}
		resVars += '&ajax='+objName;
		if (divData[objName+'Call']) {
			callback = divData[objName+'Call'];
		} else {
			callback = onLoaded;
		}
		sendRequest(callback,resVars,'GET',resScriptName[0],true,true);
	}

	function ajaxClose(objName) {
		if (!objName || objName.substr(0,1) == '^') {
			if (!objName) objName = '';
			divCount = divIndex.length;
			for (i=0; i<divCount; i++) {
				if (divIndex[i] != objName.substr(1)+'Data') {
					if (!divStyle[divIndex[i].replace('Data','')+'Keep']) document.getElementById(divIndex[i]).style.display='none';
				}
			}
		} else {
			oDiv[divData[objName]].style.display='none';
			if (divStyle[objName+'Max']) maximizeDiv(objName);
			if (divData[objName+'Interval'] && divData[objName+'Event']!='focus') clearInterval(divData[objName+'T']);
		}
		if (isIE && oPopup.isOpen) {
			oPopup.hide();
		}
	}
	
  function onLoaded(oj) { //ÄÝ¹é ÇÔ¼ö (ajax µ¥ÀÌÅÍ ¼ö½Å½Ã ½ÇÇàµÊ)
	 	//ÀÀ´äÀ» ÃëµæÇÏ¿© µðÄÚµù
    //eval("var res = " + oj.responseText); //JSONÀÇ °æ¿ì
    var res = oj.responseText.split(':::::'); //TEXTÀÇ °æ¿ì
		if (typeof(res[2])!='undefined') {
			res[2] = res[2].replace(/^\s+|\s+$/g,''); //ltrim
			//ajax µ¥ÀÌÅÍ ¸»´ÜÀÇ <@ @>·Î µÑ·¯½ÎÀÎ ¹®ÀÚ¿­À» ÃßÃâÇØ ³½´Ù.
   		resScript = res[2].split('<@');
			if (typeof(resScript[1])!='undefined') {
				resScript[1] = resScript[1].replace('@>','');
				res[2] = resScript[0]; //<@ @>º¸´Ù ¾ÕºÎºÐÀÇ ¹®ÀÚ¿­
			}
		}
   	oj.abort();

    if (divData[res[1]+'Test']) {alert(res[1]+'\n'+res[2]); return;}

    //ÀÀ´äµÈ ¹®ÀÚ¿­À» ´ëÈ­Ã¢¿¡ Ç¥½Ã
   	if (res[1] && (res[2] || typeof(resScript[1])!='undefined')) {
	   	if (res[2]) { // ajax µ¥ÀÌÅÍ¸¦ Ãâ·Â
				var isOne = 1;
	 			oD = oDiv[divData[res[1]]];
	 			if (oD.style.display=='none') {
		 			pX = divStyle[res[1]+'X'] + divStyle[res[1]+'eX'];
			 		pY = divStyle[res[1]+'Y'] + divStyle[res[1]+'eY'];
			 		pW = divStyle[res[1]+'W']; pH = divStyle[res[1]+'H'];
			 	} else {
		 			pX = oD.style.left; pY = oD.style.top;
			 		pW = oD.style.width; pH = oD.style.height;
			 	}

				if (divStyle[res[1]+'TitleBar'] && !divStyle[res[1]+'MS']) {
					printTitleBar(oD, res[1]);
				} else {
					oD.innerHTML = "";
				}
				oD.innerHTML += res[2];
		 		count = oD.childNodes.length;

  	 		if (divStyle[res[1]+'Force'] && oD.childNodes.length == isOne) {
					if (divData[res[1]+'T']) clearInterval(divData[res[1]+'T']);
					document.getElementById(res[1]).value = oD.firstChild.getAttribute('title');
					isOne--; 
					if (!isIE) isOne--;
					ajaxClose(res[1]);
				  //ÃßÃâÇØ³½ ½ºÅ©¸³Æ®¸¦ ½ÇÇà½ÃÅ´
 					if (typeof(resScript[1])!='undefined') eval(resScript[1]);
					return;
				}
				if (isOne && divStyle[res[1]+'MS']) {
					oPopup.document.body.innerHTML = oD.outerHTML;
					oPopup.document.getElementById(divData[res[1]]).attachEvent('onclick',mySearchEvent);
					oPopup.document.getElementById(divData[res[1]]).style.display = 'block';
					oPopup.show(pX, pY, pW, pH, document.body);
			 		oDD = oPopup.document.getElementById(divData[res[1]]).firstChild;
				} else if (isOne) {
					oD.style.left = pX;
					oD.style.top = pY;
					//oD.style.width = pW;
					//oD.style.height = pH;
		  	  oD.style.display = 'block';
			 		oDD = oD.firstChild;
			  }
			  if (typeof(oDD.title) != 'undefined') { //ajaxInitSearchÀÇ °æ¿ì
			  	if (oDD.title) {
				 		for (c=0; c<count; c++) {
							if (isIE) {
					 			oDD.attachEvent('onmouseover', makeMouseFunctions);
					 			oDD.attachEvent('onmouseout', makeMouseFunctions);
			 					oDD.attachEvent('onclick', makeMouseFunctions);
			 				} else {
			 					oDD.addEventListener('mouseover', makeMouseFunctions, false);
				 				oDD.addEventListener('mouseout', makeMouseFunctions, false);
					 			oDD.addEventListener('click', makeMouseFunctions, false);
					 		}
	 						oDD = oDD.nextSibling;
	 					}
	 				}
	 			}
			}
		  //ÃßÃâÇØ³½ ½ºÅ©¸³Æ®¸¦ ½ÇÇà½ÃÅ´
 			if (typeof(resScript[1])!='undefined') eval(resScript[1]);
   	} else if (divStyle[res[1]+'Hide']) {
   		ajaxClose(res[1]);
   	}
  }

	function makeMouseFunctions(event) {
		if (isIE) {
			thisObj = event.srcElement;
		} else {
			thisObj = event.target;
		}
		triggerObjName = thisObj.parentNode.id.replace('Data','');
		if (!typeof(parent.document.getElementById(triggerObjName)) == 'undefined') {
			triggerObj = parent.document.getElementById(triggerObjName);
			altObj = parent.document.getElementById(triggerObjName+'Alt');
		} else {
			triggerObj = document.getElementById(triggerObjName);
			altObj = document.getElementById(triggerObjName+'Alt');
		}
		if (!thisObj.id.match(/TitleBar/)) {
			if (triggerObjName) {
				if (event.type == 'mouseover') {
					thisObj.setAttribute('id', triggerObjName+'HL');
					thisObj.style.background = divStyle[triggerObjName+'ColorHL'];
				}
				if (event.type == 'mouseout') {
					thisObj.removeAttribute('id');
					thisObj.style.background = '';
				}
				if (event.type == 'click') {
					if (triggerObj.type.match(/text/)) triggerObj.value = thisObj.getAttribute('title');
					if (document.getElementById(triggerObjName+'Alt')) altObj.value = thisObj.getAttribute('alt');
				}
			}
		}
	}

	function printTitleBar(oD, nS) {
		barW = pixel(oD.style.width);
		barW -= (oD.style.overflow=='hidden'?45:65);
		barW -= pixel(oD.style.borderLeftWidth) * 2;
		oD.innerHTML = "<div id='"+nS+"TitleBar' style='background:"+divStyle[nS+'TitleBarColor']+"; width:100%; height:15px' \
			ondblclick={maximizeDiv('"+nS+"');} > \
			<table height='15px' border='0' cellspacing='0' cellpadding='0'><tr><td width='30'> \
			<a title='À§·Î' href='#' onclick={document.getElementById('"+nS+"Data').style.zIndex++;}> \
			<font style='font:10pt;color:"+divStyle[nS+'BorderColor']+"'>¡ã</a> \
			<a title='¾Æ·¡·Î' href='#' onclick={document.getElementById('"+nS+"Data').style.zIndex--;}> \
			<font style='font:10pt;color:"+divStyle[nS+'BorderColor']+"'>¡å</font></a></td> \
			<td id='"+nS+"TitleBarCenter' width='" + barW + "' \
			onmouseover={document.getElementById('"+oD.id+"').style.zIndex++;} \
			onmouseout={document.getElementById('"+oD.id+"').style.zIndex--;} \
			onmousedown={initializedrag('"+oD.id+"',event.clientX,event.clientY);} ></td> \
			<td width='15' align='right'> \
			<a title='´Ý±â' name='escTag' href='#' onclick={ajaxClose('"+nS+"');}> \
			<font style='font:10pt;color:"+divStyle[nS+'BorderColor']+"' style='text-align:right'><b>¡¿</b></font></a>&nbsp;\
			</td></tr></table> \
			</div>";
	}	

	function initializedrag(objName, eX, eY) {
		dragObj = document.getElementById(objName);
		sX = eX;
		sY = eY;
		tempX = pixel(dragObj.style.left);
		tempY = pixel(dragObj.style.top);
		dragApproved = (dragApproved+1)%2; //Åä±Û
	}
	
	function drag_drop(event) {
		if (dragApproved){
			dragObj.style.left = tempX + (event.clientX - sX);
			dragObj.style.top = tempY + (event.clientY - sY);
			return false;
		}
	}

	function maximizeDiv(objName) {
		oD = document.getElementById(objName+'Data');
		dragApproved = 0; //drag&drop ¹æÁö
		if (!divStyle[objName+'Max']) {
			oD.style.zIndex++; 
			divStyle[objName+'TempY'] = oD.style.top; 
			divStyle[objName+'TempX'] = oD.style.left;
			divStyle[objName+'TempH'] = oD.style.height; 
			divStyle[objName+'TempW'] = oD.style.width; 
			if (divStyle[objName+'H'] != divStyle[objName+'MaxH']) {
				if (divStyle[objName+'MaxP'].match(/T/)) {
				} else if (divStyle[objName+'MaxP'].match(/B/)) {
					oD.style.top = pixel(oD.style.top) - (divStyle[objName+'MaxH'] - pixel(oD.style.height)); 
				} else {
					oD.style.top = pixel(oD.style.top) - (divStyle[objName+'MaxH'] - pixel(oD.style.height))/2; 
				}
			}
			if (divStyle[objName+'W'] != divStyle[objName+'MaxW']) {
				if (divStyle[objName+'MaxP'].match(/L/)) {
				} else if (divStyle[objName+'MaxP'].match(/R/)) {
					oD.style.left = pixel(oD.style.left) - (divStyle[objName+'MaxW'] - pixel(oD.style.width));
				} else {
					oD.style.left = pixel(oD.style.left) - (divStyle[objName+'MaxW'] - pixel(oD.style.width))/2;
				}
			}
			oD.style.height = divStyle[objName+'MaxH'];
			oD.style.width = divStyle[objName+'MaxW'];
			divStyle[objName+'Max'] = 1;
		} else {
			oD.style.zIndex--;
			if (divStyle[objName+'H'] != divStyle[objName+'MaxH'] || 
					divStyle[objName+'W'] != divStyle[objName+'MaxW']) {
				oD.style.top = divStyle[objName+'TempY'];
				oD.style.left = divStyle[objName+'TempX'];
				oD.style.height = divStyle[objName+'TempH'];
				oD.style.width = divStyle[objName+'TempW'];
			}
			divStyle[objName+'Max'] = 0;
		}
		barW = (oD.style.overflow=='hidden'?45:65);
		barW += pixel(oD.style.borderLeftWidth) * 2;
		document.getElementById(objName+'TitleBarCenter').style.width = pixel(oD.style.width)-barW;
	}
	
	function pixel(v1) {return Number(v1.replace('px',''));}
	
  ///////////////////////////////// ÀÌ°ÍÀº AJAX¿Í´Â »ó°ü¾øÀ½ //////////////////////////////////
	
	function iframeInitPopup (keyObj, url, strOptions) {
		X=0; Y=0; W=0; H=0; dX=0; dY=0; dW=0; dH=0; maxW='800'; maxH='600'; maxP='C'; layer=5; 
		border=0; borderstyle='solid'; bordercolor='gray'; clear=0; keep=0; interval=0;
		background='#ffffff'; trigger='click'; scrollbar='hidden'; titlebar=0; titlebarcolor='silver';
		eval(strOptions);

		if (!scrollbar) scrollbar = 'hidden';
		
		resURL[keyObj] = url + (url.match(/\?/)?'&':'?') + "div=" + keyObj + "Data";
		divData[keyObj] = keyObj + 'Data';
		divData[keyObj+'Interval'] = interval * 1000;
		if (trigger) {divData[keyObj+'Event'] = trigger;} else {divData[keyObj+'Event'] = 'click';}
		divStyle[keyObj] = 1;
		divStyle[keyObj+'MS'] = 0;
		divStyle[keyObj+'Close'] = 1;
		divStyle[keyObj+'Clear'] = clear;
		divStyle[keyObj+'Keep'] = keep;
		divStyle[keyObj+'BorderColor'] = bordercolor;
		divStyle[keyObj+'TitleBar'] = titlebar;
		divStyle[keyObj+'TitleBarColor'] = titlebarcolor;
		divStyle[keyObj+'Max'] = 0;
		divStyle[keyObj+'MaxW'] = maxW;
		divStyle[keyObj+'MaxH'] = maxH;
		divStyle[keyObj+'MaxP'] = maxP;

		ajaxMakeDiv(keyObj, X, Y, W, H, dX, dY, dW, dH, layer, border, borderstyle, bordercolor, background, scrollbar, divStyle[keyObj+'MS']);
		oD = oDiv[divData[keyObj]];
		oS = document.getElementById(keyObj);
		if (isIE) { 
			oS.attachEvent('on'+divData[keyObj+'Event'],myPopupEvent);
			if (divData[keyObj+'Event'] == 'mouseover') {
				oS.attachEvent('onmouseout',myPopupEvent);
			} else if (divData[keyObj+'Event'] != 'click') {
				oS.attachEvent('onkeydown',myKeyPress);
			}
			if (divData[keyObj+'Event'] == 'focus')
				oS.setAttribute('readOnly','true');
		} else if (navigator.product == 'Gecko') {
			oS.addEventListener(divData[keyObj+'Event'],myPopupEvent,false);
			if (divData[keyObj+'Event'] == 'mouseover') {
				oS.addEventListener('mouseout',myPopupEvent,false);
			} else if (divData[keyObj+'Event'] != 'click'){
				oS.addEventListener('keydown',myKeyPress,false);
			}
			if (divData[keyObj+'Event'] == 'focus') {
				oD.addEventListener('click',mySearchEvent,false);
				oD.addEventListener('mouseover',mySearchEvent,false);
				oD.addEventListener('mouseout',mySearchEvent,false);
				oS.setAttribute('readOnly','true');
			}
		}
	}

	function iframeRequestPopup(objName, url) {
		if (url) url += "&div="+divData[objName];
		if (divStyle[objName+'Clear']) ajaxClose();

 		pX = divStyle[objName+'X'] + divStyle[objName+'eX'];
 		pY = divStyle[objName+'Y'] + divStyle[objName+'eY'];
 		s1 = 'px'; s2 = ''; s3 = 'none'; s4 = 'block';
 		
		oD = oDiv[divData[objName]];
		if (divStyle[objName+'TitleBar'] && !divStyle[objName+'MS']) {
			printTitleBar(oD, objName);
		} else {
			oD.innerHTML = "";
		}
		oD.innerHTML += "<iframe id='" + objName + "Frame' \
			width='100%' height='100%' frameborder='0' src='" + (url?url:resURL[objName]) + "'></iframe>";
		oD.style.left = pX;
		oD.style.top = pY;
		oD.style.display = 'block';
		oD.focus();
	}
	
	function iframeResizeTo(W, H) { //iframe ¾È¿¡¼­ div Å©±â Á¶Àý
		curWindow = frameElement.parentNode;
		curBar = parent.document.getElementById(frameElement.parentNode.id.replace('Data','TitleBarCenter'));
		curWindow.style.left = pixel(curWindow.style.left) + (pixel(curWindow.style.width) - W)/2;
		curWindow.style.top = pixel(curWindow.style.top) + (pixel(curWindow.style.height) - H)/2;
		curWindow.style.width = W;
		curWindow.style.height = H;
		barW = (curWindow.style.overflow=='hidden'?45:65);
		barW += pixel(curWindow.style.borderLeftWidth) * 2;
		curBar.style.width = pixel(curWindow.style.width) - barW;
	}
	
//////////////////////////////////////// ´ÜÃàÅ° ¼³Á¤ //////////////////////////////////////////
	
if (isIE) {
	document.attachEvent('onkeydown',myUpDownEvent);
	document.attachEvent('onmousemove',drag_drop); //ajax µ¥ÀÌÅÍÃ¢ÀÇ drag & drop
	//document.attachEvent('onmouseup', new Function("dragApproved=false"));
} else {
	document.addEventListener('keydown',myUpDownEvent,false);
	document.addEventListener('mousemove',drag_drop,false);
}

function myUpDownEvent(event) {
	var today = new Date();
	
	if (isIE) {
		mySrcObj = event.srcElement;
	} else {
		mySrcObj = event.target;
	}
	mySrcObjName = mySrcObj.getAttribute('name');
	
	if (event.keyCode == 33 && document.getElementById('pgupTag')) 
		document.getElementById('pgupTag').click(); //PgUp
	if (event.keyCode == 34 && document.getElementById('pgdnTag')) 
		document.getElementById('pgdnTag').click(); //PgDn
	if (event.keyCode == 35 && document.getElementById('endTag')) 
		document.getElementById('endTag').focus(); //End
	if (event.keyCode == 36 && document.getElementById('homeTag')) 
		document.getElementById('homeTag').focus(); //Home
	if (event.keyCode == 27 && document.getElementsByName('escTag'))
		for (e=0; e<document.getElementsByName('escTag').length; e++) {
			document.getElementsByName('escTag')[e].click(); //Esc
		}
	if (event.ctrlKey && event.keyCode == 13 && document.getElementById('enterTag'))
		document.getElementById('enterTag').click(); //Ctrl+Enter

	if (mySrcObjName && mySrcObjName.match(/year|month|day|time|hour|minute|second/i)) {
		maxVal = today.getFullYear()+1;
		if (mySrcObjName.match(/month/i)) maxVal = 12; 
		if (mySrcObjName.match(/day/i)) maxVal = 31; 
		if (mySrcObjName.match(/time|hour/i)) maxVal = 23; 
		if (mySrcObjName.match(/minute|second/i)) maxVal = 59; 
		if (!mySrcObj.value) {
			if (event.keyCode == 40 || event.keyCode == 34) { //Down, PgDn
				mySrcObj.value = maxVal;
			} else {
				mySrcObj.value = 0;
			}
			mySrcObj.select();
		} else {
			if (event.keyCode == 40 && mySrcObj.value > 0) {mySrcObj.value--; mySrcObj.select();} //Down
			if (event.keyCode == 38 && mySrcObj.value < maxVal) {mySrcObj.value++; mySrcObj.select();} //Up
			if (event.keyCode == 33 && mySrcObj.value <= (maxVal-10)) {
				mySrcObj.value=Number(mySrcObj.value)+10; mySrcObj.select();} //PgUp
			if (event.keyCode == 34 && mySrcObj.value > 10) {
				mySrcObj.value=Number(mySrcObj.value)-10; mySrcObj.select();} //PgDn
		}
	}
}

