var IE = (navigator.userAgent.indexOf('MSIE') != -1) ? true : false; 
/*
ÇÑ±ÛÃÊÁßÁ¾ºÐ¸®
*/
var arr_1st=new Array('¤¡','¤¢','¤¤','¤§','¤¨','¤©','¤±','¤²','¤³','¤µ','¤¶','¤·','¤¸','¤¹','¤º','¤»','¤¼','¤½','¤¾');//ÃÊ¼º 19°³ 
var arr_2nd=new Array('¤¿','¤À','¤Á','¤Â','¤Ã','¤Ä','¤Å','¤Æ','¤Ç','¤È','¤É','¤Ê','¤Ë','¤Ì','¤Í','¤Î','¤Ï','¤Ð','¤Ñ','¤Ò','¤Ó');//Áß¼º 21°³ 
var arr_3th=new Array('','¤¡','¤¢','¤£','¤¤','¤¥','¤¦','¤§','¤©','¤ª','¤«','¤¬','¤­','¤®','¤¯','¤°','¤±','¤²','¤´','¤µ','¤¶','¤·','¤¸','¤º','¤»','¤¼','¤½','¤¾');//Á¾¼º 28°³ 

function getJamoCodes(t) { 
//var arr_1st=new Array('¤¡','¤¢','¤¤','¤§','¤¨','¤©','¤±','¤²','¤³','¤µ','¤¶','¤·','¤¸','¤¹','¤º','¤»','¤¼','¤½','¤¾');//ÃÊ¼º 19°³ 
//var arr_2nd=new Array('¤¿','¤À','¤Á','¤Â','¤Ã','¤Ä','¤Å','¤Æ','¤Ç','¤È','¤É','¤Ê','¤Ë','¤Ì','¤Í','¤Î','¤Ï','¤Ð','¤Ñ','¤Ò','¤Ó');//Áß¼º 21°³ 
//var arr_3th=new Array('','¤¡','¤¢','¤£','¤¤','¤¥','¤¦','¤§','¤©','¤ª','¤«','¤¬','¤­','¤®','¤¯','¤°','¤±','¤²','¤´','¤µ','¤¶','¤·','¤¸','¤º','¤»','¤¼','¤½','¤¾')
//var arr = getJamoCodes("È²"); 
//document.write(arr_1st[arr[0]-1]+","+arr_2nd[arr[1]-1]+","+arr_3th[arr[2]]); 
	var c = t.charCodeAt(0), c = c<0x3130?0:c<0x3164?c-0x3130:c<0xac00?0:c<0xd7a5?c+68:0; 
    if (c>51) return Array((c-c%588)/588-74,((c-c%28)/28)%21+1,c%28); 
    return Array(c<3?c:c<4?0:c<5?c-1:c<7?0:c<10?c-3:c<17?0:c<20?c-10:c<21?0:c<31?c-11:0,c<31?0:c-30,0); 
} 

var oldvals = "";

function keyck() {
		if(event.ctrlKey==false && event.altKey==false && 46< event.keyCode && event.keyCode <91 ) return true;
		else return false;
}
	function layer_move(lid,lleft,ltop) {
		
		//alert(lleft);
		lid.style.left=lleft+'px';
		lid.style.top=ltop+'px';
	}


	function sel_switch(mode) {

		if(!mode) mode='none';
		var sel = document.getElementsByTagName("select");
		for(var i=0;i<sel.length;i++){
			sel[i].style.display=mode;
		}
	}

/*
ÇÑ±Û º¯¼ö ³Ñ±æ¶§
±âº»Á¶°Ç : html(uhc) xmlFile(utf8)

JavaScript --> PHP ÀÏ¶§: 
encodeURIComponent( string ) --> rawurldecode( iconv( "UTF-8", "CP949", $string ) ) 
PHP --> JavaScript ÀÏ¶§: 
rawurlencode( iconv( "CP949", "UTF-8", $string ) ) --> decodeURIComponent( string ) 



1. ±âº»ÀûÀÎ »ç¿ë¹ý 
function funcname(originalRequest){ 
    var xmlData = originalRequest.responseXML; 
................. 
} 

getAjaxData("È­ÀÏ","pars",funcname); 

2. ¹Ù·Î Àû¿ë 
getAjaxData("È­ÀÏ","pars",function(req) {  blahblah... }); 

3. ¸Þ¼Òµå 
var inst = new someClass; 
getAjaxData("È­ÀÏ","pars", inst.someFunc.bind(inst)); // someFuncÀº instÀÇ ¸Þ¼Òµå 
*/

function getAjaxData(url,pars,func){ 
	
    var myAjax = new Ajax.Request( 
            url, 
            { 
                method: 'get', 
                parameters: pars, 
                onComplete: eval(func) 

            }); 
} 


//asynchronous:false

/*
* »ç¿ë¹ý 
//simplXml reader
var edu_admin_id_xml = new simpleXml(originalRequest.responseXML);   
or
var edu_admin_id_xml = new simplexmlParser(originalRequest.responseXML); 

//rss ¸®´õ
var edu_admin_id_xml = new rssParser(originalRequest.responseXML); 

*/
var simplexmlParser = Class.create(); 
Object.extend(simplexmlParser.prototype, { 
     item: null,
	 rootXml:null,
	 nodeEntity:null,
	 initialize: function (xml){   
		this.rootXml = xml;
        var lists = xml.getElementsByTagName("lists")[0]; 
      // alert(lists);
        //----------------------------------------------------------------- 
        // + ITEM 
        var item_node = xml.getElementsByTagName("item"); 
        var item_list = new Array(); 
		var nodeNames = new Array(); 
        for(var i=0; i<item_node.length; i++){         
			
            var item_obj = new Object(); 
			
				if(i==0){
					
					for(var j=0;j<item_node[i].childNodes.length;j++){
						
						if(item_node[i].childNodes[j].nodeType==1) nodeNames.push(item_node[i].childNodes[j].nodeName);
					}

				}
			for(var z=0;z<nodeNames.length;z++){
					
					item_obj[nodeNames[z]] = item_node[i].getElementsByTagName(nodeNames[z])[0].firstChild.nodeValue;
			}

            item_list.push(item_obj); 
			
        } 
        this.item = item_list; 
		this.nodeEntity = nodeNames;
    }, 
    getNode: function (tag){ // ½Ì±Û³ëµå 
        return this.rootXml.getElementsByTagName(tag)[0]; 
    }, 
    getNodeAll: function (tag){ // ¸ÖÆ¼³ëµå 
        return this.rootXml.getElementsByTagName(tag); 
    }, 
    getValue: function (tag,idx){ // ³ëµå°ª °¡Á®¿À±â 
        try{ 
            return this.rootXml.getElementsByTagName(tag)[idx].firstChild.nodeValue; 
        } catch(e){ 
            return null; 
        } 
    } 
}); 

// XML Å¬·¡½º 
var xmlParser = Class.create(); 
Object.extend(xmlParser.prototype, { 
    initialize: null, 
    
	getNode: function (xml, tag){ // ½Ì±Û³ëµå 
        return xml.getElementsByTagName(tag)[0]; 
    }, 
    
	getNodeAll: function (xml, tag){ // ¸ÖÆ¼³ëµå 
        return xml.getElementsByTagName(tag); 
    }, 
    
	getValue: function (xml){ // ³ëµå°ª °¡Á®¿À±â 
        try{ 
            return xml.firstChild.nodeValue; 
        } catch(e){ 
            return null; 
        } 
    } 

}); 


// XML Å¬·¡½º¸¦ È®ÀåÇÑ RSS Å¬·¡½º 
var rssParser = Class.create(); 
Object.extend(rssParser.prototype, xmlParser.prototype); 
Object.extend(rssParser.prototype, { 
    title: null, 
    link: null, 
    description: null, 
    language: null, 
    pubDate: null, 
    generator: null, 
    image: null, 
    item: null, 

    initialize: function (xml){     
		alert(xml);
        // CHANNEL 
        var channel = this.getNode(xml, "channel"); 
        //----------------------------------------------------------------- 
        // + TITLE 
        this.title = this.getValue(this.getNode(channel, "title")); 
        // + LINK 
        this.link = this.getValue(this.getNode(channel, "link")); 
        // + DESCRIPTION 
        this.description = this.getValue(this.getNode(channel, "description")); 
        // + LANGUAGE 
        this.language = this.getValue(this.getNode(channel, "language")); 
        // + PUBDATE 
        this.pubDate = this.getValue(this.getNode(channel, "pubDate")); 
        // + GENERATOR 
        this.generator = this.getValue(this.getNode(channel, "generator")); 
        // + IMAGE 
        var img_node = this.getNode(channel, "image"); 
        var img_obj = new Object(); 
        img_obj.title = this.getValue(this.getNode(img_node, "title")); 
        img_obj.url = this.getValue(this.getNode(img_node, "url")); 
        img_obj.link = this.getValue(this.getNode(img_node, "link")); 
        img_obj.width = this.getValue(this.getNode(img_node, "width")); 
        img_obj.height = this.getValue(this.getNode(img_node, "height")); 
        img_obj.description = this.getValue(this.getNode(img_node, "description")); 
        this.image = img_obj; 
        //----------------------------------------------------------------- 
        // + ITEM 
        var item_node = this.getNodeAll(channel, "item"); 
        var item_list = new Array(); 
        for(var i=0; i<item_node.length; i++){   
			
            var item_obj = new Object(); 
            item_obj.title = this.getValue(this.getNode(item_node[i], "title")); 
            item_obj.link = this.getValue(this.getNode(item_node[i], "link")); 
            item_obj.description = this.getValue(this.getNode(item_node[i], "description")); 

            var category_node = this.getNodeAll(item_node[i], "category"); 
            var category_list = new Array(); 
            for(var j=0; j<category_node.length; j++){ 
                category_list.push(this.getValue(category_node[j])); 
            } 
            item_obj.category = category_list; 

            item_obj.author = this.getValue(this.getNode(item_node[i], "author")); 
            item_obj.guid = this.getValue(this.getNode(item_node[i], "guid")); 
            item_obj.comments = this.getValue(this.getNode(item_node[i], "comments")); 
            item_obj.pubDate = this.getValue(this.getNode(item_node[i], "pubDate")); 

            item_list.push(item_obj); 
        } 
        this.item = item_list; 
    } 
}); 



// XML Å¬·¡½º¸¦ È®ÀåÇÑ RSS Å¬·¡½º 
var simpleXml = Class.create(); 
Object.extend(simpleXml.prototype, xmlParser.prototype); 
Object.extend(simpleXml.prototype, { 
    item: null, 
	nodeEntity:null,

    initialize: function (xml){   
		//alert('xxx');
        // lists 
        var lists = this.getNode(xml, "lists"); 
      // alert(lists);
        //----------------------------------------------------------------- 
        // + ITEM 
        var item_node = this.getNodeAll(lists, "item"); 
        var item_list = new Array(); 
		var nodeNames = new Array(); 
        for(var i=0; i<item_node.length; i++){         
			//alert(i);
            var item_obj = new Object(); 
			
				if(i==0){
					
					for(var j=0;j<item_node[i].childNodes.length;j++){
						//alert(j);
						if(item_node[i].childNodes[j].nodeType==1) nodeNames.push(item_node[i].childNodes[j].nodeName);
					}

				}
			for(var z=0;z<nodeNames.length;z++){
					//alert(nodeNames[z] +"=>"+this.getValue(this.getNode(item_node[i], nodeNames[z])));
					
					item_obj[nodeNames[z]] = this.getValue(this.getNode(item_node[i], nodeNames[z])); 
			}

            item_list.push(item_obj); 
        } 
        this.item = item_list; 
		this.nodeEntity=nodeNames;
    } 
}); 



// ÀÚµ¿¿Ï¼º 
var autoText = Class.create(); 
Object.extend(autoText.prototype, { 
    fromF: null,
	divId: null,
	url: null,
	pars: null,
	vals: null,
	oldvals: null,
	clickFunc: null,
	XmlData : null,
	debug : null,
	report:null,
	
	initialize: function (fromF,url,pars,actFunc,debug){   
		
		this.debug=debug;
		if(this.debug) {
			arr = window.open('','autoText','toolbar=yes,scrollbars=yes,width=400,height=300');
			arr.document.open("text/html","replace");
			arr.document.write('init start <br>');
		}
		
		 
		this.fromF=fromF;
		if(this.debug) arr.document.write('this.fromF 1 <br>');
			
		if(IE) this.fromF.setAttribute("autocomplete","off");

		if(this.debug) arr.document.write('this.fromF 2 <br>');
		
		if(!$('autoTextDiv')) {
		
			this.divId = document.createElement('div');
			if(this.debug) arr.document.write('this.divId 1 <br>');
			this.divId.id = 'autoTextDiv';
			if(this.debug) arr.document.write('this.divId 2 <br>');
			
			with(this.divId.style){
				backgroundColor="#ffffff";
				position="absolute";
				border="1px solid ";
				left="0px";
				top="0px";
				display="none";
				
				}
			if(this.debug) arr.document.write('this.divId 3 <br>');
			
			this.divId.noWrap=true;
			document.body.appendChild(this.divId);
			if(this.debug) arr.document.write('this.divId 4 <br>');

		}else{
			
			this.divId= $('autoTextDiv');
		}
		if(this.debug) arr.document.write('this.divId end <br>');
		this.url=url;
		this.pars=pars;
		this.clickFunc=actFunc;
		
		//Event.observe(this.divId, 'click',this.echo_id.bindAsEventListener(this));
		//ÆûÇü½Ä¿¡ µû¶ó ÀÌº¥Æ® ¼³Á¤
			if(this.debug) arr.document.write('event 1  <br>');
			
		Event.observe(this.fromF, 'keyup',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event 2 <br>');
		
		Event.observe(this.fromF, 'mousedown',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event end <br>');


		if(this.debug) arr.document.write('init end <br>');
		//Aprint(this.fromF);
    },
	echo_id: function (){
		alert(event.srcElement.id);
	},
	getXml: function (e){
		if(this.debug)	arr.document.write('getXml start <br>');
		
		var event = window.event || e; 
		

		if(this.debug)	arr.document.write('getXml xx <br>');
		
		if(event.type=='keyup' && keyck()==false ){
			return false;
		}
		if(this.debug)	arr.document.write('getXml 1 <br>');
		var tfromF = this.fromF.value;
		
		this.vals="";

		if(this.debug)	arr.document.write('getXml 2 <br>');
		for(var i=0;i<tfromF.length;i++){
			var tmp = getJamoCodes(tfromF.charAt(i));
			if(escape(tfromF.charAt(i)).length<4 || tmp[1]!='0')  this.vals += tfromF.charAt(i);
		}

		if(this.debug)	arr.document.write('getXml 3 <br>');

		if((this.oldvals!=this.vals || mode=='1')){//this.vals.length>0 && 
			
			var tem_pars = this.pars.split("&vals=");
				//alert(tem_pars[1]);
			if(tem_pars[1]){//ival ÁöÁ¤ÀÏ°æ¿ì
				
				this.divId.innerHTML="";
				//this.divId.innerHTML=tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>';

				getAjaxData(this.url,'item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]),this.setData.bindAsEventListener(this));
				oldvals=tem_pars[1];
				
			}else{//ival ÁöÁ¤ÀÌ ¾Æ´Ò°æ¿ì
				
				this.divId.innerHTML="";
				//this.divId.innerHTML=this.pars+encodeURIComponent(this.vals);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>';

				getAjaxData(this.url,'item=xmlval&'+this.pars+encodeURIComponent(this.vals),this.setData.bindAsEventListener(this));
				oldvals=this.vals;
				
			}
			
				
				offset = Position.cumulativeOffset(this.fromF);
				this.divId.style.display="inline";
				this.divId.style.left=(offset[0])+'px';
				this.divId.style.top=(offset[1]+this.fromF.offsetHeight)+'px';
				
			
			if(this.debug) arr.document.write('getXml 5 <br>');
		}
		
		if(this.debug) arr.document.write('getXml end <br>');
		
	},
	
	setData: function(originalRequest){
		if(this.debug)	arr.document.write('setData start <br>');
		
		if(originalRequest.responseTEXT) {
			if(this.debug)	arr.document.write('originalRequest.TEXT => <pre>'+originalRequest.responseTEXT+'</pre> <br>');
			this.fromF.report += originalRequest.responseTEXT;
		}
		var temxml = new simpleXml(originalRequest.responseXML);   
		this.XmlData = temxml;
		this.divId.innerHTML="";

		var temDiv = document.createElement('div');
			with(temDiv.style){
			cursor="pointer";
			
			}
			temDiv.noWrap=true;


		for(var i=0; i<temxml.item.length; i++){     
			//alert(i);
			if(this.clickFunc!=null) { //ÁöÁ¤ func ÀÖÀ»¶§
				if(this.debug) {arr.document.write('ÁöÁ¤ func ÀÖÀ»¶§ start <br>');	}
				new Insertion.Bottom(this.divId.id, eval(this.clickFunc.replace(/idx/g, i)));
				if(this.debug) {arr.document.write('ÁöÁ¤ func ÀÖÀ»¶§ end <br>');	}
			}
			else {//±âº» func ½ÇÇà
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà start <br>');	}
				var temmDiv=temDiv.cloneNode(true);
				temmDiv.innerHTML=temxml.item[i].xmlval;
					temmDiv.onmouseover=function (){this.style.backgroundColor='#f0f0f0';};
					temmDiv.onmouseout=function (){this.style.backgroundColor='';};
					temmDiv.onclick=this.setFunc.bindAsEventListener(this);
					temmDiv.id='_exit';
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 1 <br>');	}
				//new Insertion.Bottom(this.divId.id,temDiv.outerHTML);
					this.divId.appendChild(temmDiv);
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 2 <br>');	}
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà end <br>');	}
				
				if(this.debug) {arr.document.write(this.divId.outerHTML);	}
				
			}
			//eval(this.clickFunc.replace(/idx/g, i));
        }
		this.divId.style.display='inline';
		selectbox_hidden(this.divId);

		if(this.debug) {arr.document.write('setData end <br>');	}
	},
	setFunc:function(){
			if(this.debug) {arr.document.write('setFunc start <br>');	}
			this.fromF.value=event.srcElement.innerHTML;
			this.divId.style.display="none";
			if(this.debug) {arr.document.write('setFunc end <br>');	}
	}


}); 

var autoText3 = Class.create(); 
Object.extend(autoText3, { 
    
	vals:null,
	divId: null,
	oldvals: null,
	XmlData : null,
	debug : true,
	report:null,
	
	initialize: function (){   
		
		this.debug=null;
		if(this.debug) {
			arr = window.open('','autoText3','toolbar=yes,scrollbars=yes,width=400,height=300');
			arr.document.open("text/html","replace");
			arr.document.write('init start <br>');
		}
		this.fromF=this;
		

		
		
		if(!$('autoTextDiv')) {
			
			this.divId = document.createElement('div');
			if(this.debug) arr.document.write('this.divId 1 <br>');
			this.divId.id = 'autoTextDiv';
			if(this.debug) arr.document.write('this.divId 2 <br>');
			with(this.divId.style){
				backgroundColor="#ffffff";
				position="absolute";
				border="1px solid ";
				left="0px";
				top="0px";
				display="none";
				}
				if(this.debug) arr.document.write('this.divId 3 <br>');
				
			document.body.appendChild(this.divId);
			if(this.debug) arr.document.write('this.divId 4 <br>');

		}else{
			
			this.divId= $('autoTextDiv');
		}

		
		
		//ÆûÇü½Ä¿¡ µû¶ó ÀÌº¥Æ® ¼³Á¤
		if(IE) this.setAttribute("autocomplete","off");
		Event.observe(this, 'keyup',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event 2 <br>');
		
		Event.observe(this, 'mousedown',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event end <br>');



		if(this.debug) arr.document.write('init end <br>');
		//Aprint(this.fromF);
    },
	
	getXml: function (){
		if(this.debug)	arr.document.write('getXml start <br>');

		var event = window.event || e; 
		
		if(event.type=='keyup' && keyck()==false ){
			return false;
		}

		var tfromF = this.value;
		
		this.vals="";
		
		for(var i=0;i<tfromF.length;i++){
			var tmp = getJamoCodes(tfromF.charAt(i));
			if(escape(tfromF.charAt(i)).length<4 || tmp[1]!='0')  this.vals += tfromF.charAt(i);
		}
		
		if((this.oldvals!=this.vals || mode=='1')){//this.vals.length>0 && 
			
			
			var tem_pars = this.pars.split("&vals=");
				
			if(tem_pars[1]){//ival ÁöÁ¤ÀÏ°æ¿ì

				this.divId.innerHTML="";
				//this.divId.innerHTML=tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>';

				getAjaxData(this.url,'item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]),this.setData.bindAsEventListener(this));
				oldvals=tem_pars[1];
				
			}else{//ival ÁöÁ¤ÀÌ ¾Æ´Ò°æ¿ì
				this.divId.innerHTML="";
				//this.divId.innerHTML=this.pars+encodeURIComponent(this.vals);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>';

				getAjaxData(this.url,'item=xmlval&'+this.pars+encodeURIComponent(this.vals),this.setData.bindAsEventListener(this));
				oldvals=this.vals;
				
			}
			
			
				

				offset = Position.cumulativeOffset(this);
				this.divId.style.display="inline";
				this.divId.style.left=(offset[0])+'px';
				this.divId.style.top=(offset[1]+this.offsetHeight)+'px';
			
		}
		
		if(this.debug) arr.document.write('getXml end <br>');
		
	},
	
	setData: function(originalRequest){
		if(this.debug)	arr.document.write('setData start <br>');
		if(originalRequest.responseTEXT) {
			if(this.debug)	arr.document.write('originalRequest.TEXT => <pre>'+originalRequest.responseTEXT+'</pre> <br>');
			this.report += originalRequest.responseTEXT;
		}
		
		var temxml = new simpleXml(originalRequest.responseXML);   
		this.XmlData = temxml;
		this.divId.innerHTML="";

		var temDiv = document.createElement('div');
			with(temDiv.style){
			cursor="pointer";

			}
			temDiv.noWrap=true;


		for(var i=0; i<temxml.item.length; i++){     
			//alert(i);

				if(this.debug) {arr.document.write('±âº» func ½ÇÇà start <br>');	}
				var temmDiv=temDiv.cloneNode(true);
				temmDiv.innerHTML=temxml.item[i].xmlval;
					temmDiv.onmouseover=function (){this.style.backgroundColor='#f0f0f0';};
					temmDiv.onmouseout=function (){this.style.backgroundColor='';};
					temmDiv.onclick=this.setFunc.bindAsEventListener(this);
					temmDiv.id='_exit';
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 1 <br>');	}
				//new Insertion.Bottom(this.divId.id,temDiv.outerHTML);
					this.divId.appendChild(temmDiv);
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 2 <br>');	}
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà end <br>');	}
				
				if(this.debug) {arr.document.write(this.divId.outerHTML);	}
				

			//eval(this.clickFunc.replace(/idx/g, i));
        }
		this.divId.style.display='inline';
		selectbox_hidden(this.divId);

		if(this.debug) {arr.document.write('setData end <br>');	}
	},
	setFunc:function(){
			if(this.debug) {arr.document.write('setFunc start <br>');	}
			if(this.clickFunc!=null) {
			
				eval( this.clickFunc+"('"+event.srcElement.innerHTML+"','"+this.sourceIndex+"')" );
			}else{
				this.fromF.value=event.srcElement.innerHTML;
			}			


			this.divId.style.display="none";
			if(this.debug) {arr.document.write('setFunc end <br>');	}
	}


}); 
	function elise(){
		alert('xxxx');
	}
// ÀÚµ¿¿Ï¼º 
var autoText2 = Class.create(); 
Object.extend(autoText2, { 
    
	vals:null,
	divId: null,
	oldvals: null,
	XmlData : null,
	debug : true,
	report:null,
	
	initialize: function (){   
		
		this.debug=null;
		if(this.debug) {
			arr = window.open('','autoText2','toolbar=yes,scrollbars=yes,width=400,height=300');
			arr.document.open("text/html","replace");
			arr.document.write('init start <br>');
		}
		//this.fromF=$(fromF);

		
		
		if(!$('autoTextDiv')) {
			
			this.divId = document.createElement('div');
			if(this.debug) arr.document.write('this.divId 1 <br>');
			this.divId.id = 'autoTextDiv';
			if(this.debug) arr.document.write('this.divId 2 <br>');
			with(this.divId.style){
				backgroundColor="#ffffff";
				position="absolute";
				border="1px solid ";
				left="0px";
				top="0px";
				display="none";
				}
				if(this.debug) arr.document.write('this.divId 3 <br>');
				
			document.body.appendChild(this.divId);
			if(this.debug) arr.document.write('this.divId 4 <br>');

		}else{
			
			this.divId= $('autoTextDiv');
		}

		
		
		//ÆûÇü½Ä¿¡ µû¶ó ÀÌº¥Æ® ¼³Á¤
		if(IE) this.setAttribute("autocomplete","off");
		Event.observe(this, 'keyup',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event 2 <br>');
		
		Event.observe(this, 'mousedown',this.getXml.bindAsEventListener(this));
		if(this.debug) arr.document.write('event end <br>');



		if(this.debug) arr.document.write('init end <br>');
		//Aprint(this.fromF);
    },
	
	getXml: function (){
		if(this.debug)	arr.document.write('getXml start <br>');

		var event = window.event || e; 
		
		if(event.type=='keyup' && keyck()==false ){
			return false;
		}

		var tfromF = this.value;
		
		this.vals="";
		
		for(var i=0;i<tfromF.length;i++){
			var tmp = getJamoCodes(tfromF.charAt(i));
			if(escape(tfromF.charAt(i)).length<4 || tmp[1]!='0')  this.vals += tfromF.charAt(i);
		}
		
		if((this.oldvals!=this.vals || mode=='1')){//this.vals.length>0 && 
			
			
			var tem_pars = this.pars.split("&vals=");
				
			if(tem_pars.length>1){//ival ÁöÁ¤ÀÏ°æ¿ì

				this.divId.innerHTML="";
				this.divId.innerHTML=tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1])+' <br>';

				getAjaxData(this.url,'item=xmlval&'+tem_pars[0]+"&vals="+encodeURIComponent(tem_pars[1]),this.setData.bindAsEventListener(this));
				oldvals=tem_pars[1];
				
			}else{//ival ÁöÁ¤ÀÌ ¾Æ´Ò°æ¿ì
				this.divId.innerHTML="";
				this.divId.innerHTML=this.pars+encodeURIComponent(this.vals);
				
				if(this.debug) arr.document.write('url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>');
				

				this.report += 'url +pars=> '+this.url+'?item=xmlval&'+this.pars+encodeURIComponent(this.vals)+' <br>';

				getAjaxData(this.url,'item=xmlval&'+this.pars+encodeURIComponent(this.vals),this.setData.bindAsEventListener(this));
				oldvals=this.vals;
				
			}
			
			
				

				offset = Position.cumulativeOffset(this);
				this.divId.style.display="inline";
				this.divId.style.left=(offset[0])+'px';
				this.divId.style.top=(offset[1]+this.offsetHeight)+'px';
			
		}
		
		if(this.debug) arr.document.write('getXml end <br>');
		
	},
	
	setData: function(originalRequest){
		if(this.debug)	arr.document.write('setData start <br>');
		if(originalRequest.responseTEXT) {
			if(this.debug)	arr.document.write('originalRequest.TEXT => <pre>'+originalRequest.responseTEXT+'</pre> <br>');
			this.report += originalRequest.responseTEXT;
		}
		
		var temxml = new simpleXml(originalRequest.responseXML);   
		this.XmlData = temxml;
		this.divId.innerHTML="";

		var temDiv = document.createElement('div');
			with(temDiv.style){
			cursor="pointer";

			}
			temDiv.noWrap=true;


		for(var i=0; i<temxml.item.length; i++){     
			//alert(i);
			if(this.clickFunc!=null) { //ÁöÁ¤ func ÀÖÀ»¶§
				if(this.debug) {arr.document.write('ÁöÁ¤ func ÀÖÀ»¶§ start <br>');	}
				new Insertion.Bottom(this.divId.id, eval(this.clickFunc.replace(/idx/g, i)));
				if(this.debug) {arr.document.write('ÁöÁ¤ func ÀÖÀ»¶§ end <br>');	}
			}
			else {//±âº» func ½ÇÇà
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà start <br>');	}
				var temmDiv=temDiv.cloneNode(true);
				temmDiv.innerHTML=temxml.item[i].xmlval;
					temmDiv.onmouseover=function (){this.style.backgroundColor='#f0f0f0';};
					temmDiv.onmouseout=function (){this.style.backgroundColor='';};
					temmDiv.onclick=this.setFunc.bindAsEventListener(this);
					temmDiv.id='_exit';
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 1 <br>');	}
				//new Insertion.Bottom(this.divId.id,temDiv.outerHTML);
					this.divId.appendChild(temmDiv);
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà 2 <br>');	}
				if(this.debug) {arr.document.write('±âº» func ½ÇÇà end <br>');	}
				
				if(this.debug) {arr.document.write(this.divId.outerHTML);	}
				
			}
			//eval(this.clickFunc.replace(/idx/g, i));
        }
		this.divId.style.display='inline';
		selectbox_hidden(this.divId);

		if(this.debug) {arr.document.write('setData end <br>');	}
	},
	setFunc:function(){
			if(this.debug) {arr.document.write('setFunc start <br>');	}
			this.value=event.srcElement.innerHTML;
			this.divId.style.display="none";
			if(this.debug) {arr.document.write('setFunc end <br>');	}
	}


}); 

// options °¡Á®¿À±â 
var XmlOptions = Class.create(); 
Object.extend(XmlOptions.prototype, { 
    fromF: null,
	xurl: null,
	xpars: null,
	vals: null,
	clickFunc: null,
	first : true,
	ival: null,
	debug : null,
	async: true,
	myAjax:null,
	
	initialize: function (fromF){   
		
		//this.debug=debug;
		//this.debug=true;
	
		if(this.debug) {
			arr = window.open('','xml','toolbar=yes,scrollbars=yes,width=400,height=300');
			arr.document.open("text/html","replace");
			arr.document.write('init start <br>');
		}
		this.fromF=fromF;
		
		if(this.fromF.getAttribute("ival")) this.ival=this.fromF.getAttribute("ival");
		if(this.fromF.getAttribute("xurl")) this.xurl=this.fromF.getAttribute("xurl");
		if(this.fromF.getAttribute("xpars")) this.xpars=this.fromF.getAttribute("xpars");
		
		if(this.debug) arr.document.write('init end <br>');
    },
	
	getXml: function (val){
		if(this.debug)	arr.document.write('getXml start <br>');
			
		this.vals=val;

		if(this.debug) arr.document.write('url +pars=> '+this.xurl+'?item=option,text&'+this.xpars+encodeURIComponent(this.vals)+' <br>');
			
			this.myAjax = new Ajax.Request( 
            this.xurl, 
            { 
                method: 'get', 
				asynchronous: this.async,
                parameters: "item=option,text&"+this.xpars+encodeURIComponent(this.vals), 
                onComplete: eval(this.setData.bindAsEventListener(this)) 

            }); 

		if(this.debug) arr.document.write('getXml end <br>');
		
	},
	
	setData: function(originalRequest){
		if(this.debug)	arr.document.write('setData start <br>');
		
		if(this.debug)	arr.document.write('originalRequest.TEXT => <pre>'+originalRequest.responseTEXT+'</pre> <br>');
		
			var temxml = new simpleXml(originalRequest.responseXML);   
		
			if(this.debug) {arr.document.write('setData 1<br>');	}
			//¿É¼ÇÃÊ±âÈ­
			while(this.fromF.options[0])  this.fromF.remove(0);
			if(this.debug) {arr.document.write('setData 2<br>');	}
			
			for(var i=0; i<temxml.item.length; i++){     
					
					
					this.fromF.options[i] = new Option(temxml.item[i].text,temxml.item[i].option);
					if(this.first==true && this.ival != null && this.ival==temxml.item[i].option) this.fromF.options[i].selected=true;
					
			}
			if(this.debug) {arr.document.write('setData 3<br>');	}
			this.first=false;

		if(this.debug) {arr.document.write('setData end <br>');	}
	}


}); 



var XmlOption = Class.create(); 
Object.extend(XmlOption, { 
	
	
	debug : true,
	report: null,
	async: true,
	ajaxinfo: null,
	myAjax:null,


	getXml: function (val){
		
		//if(this.debug)	alert('getXml start <br>');
		while(this.options[0])  this.remove(0);
		this.options[0] = new Option("--Loading--","");
		this.report= this.getAttribute("xurl")+"?"+"item=option,text&"+this.getAttribute("xpars")+encodeURIComponent(val);
			
		    this.myAjax = new Ajax.Request( 
            this.getAttribute("xurl"), 
            { 
                method: 'get', 
				asynchronous: this.async,
                parameters: "item=option,text&"+this.getAttribute("xpars")+encodeURIComponent(val), 
                onComplete: eval(this.setData.bindAsEventListener(this)) 

            }); 
			
			
			
		
	},
	
	setData: function(originalRequest){
			this.report=originalRequest.responseText;
			var temxml = new simpleXml(originalRequest.responseXML);   
			var selidx = 0;
			//¿É¼ÇÃÊ±âÈ­
			
			
			for(var i=this.options.length-1;i>=0;i--) {
				this.remove(i);
				//alert(this.options[i].text);
			}
			
			this.options[0] = new Option("--¼±ÅÃÇÏ¼¼¿ä--","");
			
			for(var i=0; i<temxml.item.length; i++){     
					if(this.getAttribute("ival") != null && this.getAttribute("ival")==temxml.item[i].option) {
						
						selidx=i+1;
						
					}
					this.options[i+1] = new Option(temxml.item[i].text,temxml.item[i].option);
			}
			
			
				this.selectedIndex=selidx;

	}
}); 

var Notice = Class.create(); 
Object.extend(Notice.prototype, { 
	
	tdiv:null,
	debug:true,
	initialize: function (){   
		if(this.debug) {
			arr = window.open('','xml','toolbar=yes,scrollbars=yes,width=400,height=300');
			arr.document.open("text/html","replace");
			arr.document.write('init start <br>');
		}
		if(this.debug) arr.document.write('init end <br>');
    },
	create: function(){
		if(this.debug) arr.document.write('create start <br>');
			if(this.tdiv == null){
				this.tdiv = document.createElement('div');
				this.tdiv.id="notice";
				with(this.tdiv.style){
					position="absolute";
					textAlign="center";
					zIndex="100";
					left="0px";
					top="0px";
					fontWeight="bolder";
					border="4px double #ffffff";
					padding="4px";
					backgroundColor="red";
					display="none";
					filter="Alpha(opacity=90); opacity:0.6; -moz-opacity:0.6;";
				}
				document.body.appendChild(this.tdiv);
			}
		if(this.debug) arr.document.write('create end <br>');
	},
	show: function (msg){
		if(this.debug) arr.document.write('show start <br>');
			if(this.tdiv == null) this.create();
					/*
					var h = window.innerHeight || self.innerHeight || document.body.clientHeight;
					var w = window.innerWidth || self.innerWidth || document.body.clientWidth;
					var l = (document.body.scrollLeft + ((w-(this.tdiv.width||parseInt(this.tdiv.style.width)||this.tdiv.offsetWidth))/2)) ;
					var t = (document.body.scrollTop + ((h-(this.tdiv.height||parseInt(this.tdiv.style.height)||this.tdiv.offsetHeight))/2)) ;
					this.tdiv.style.left = l + "px";
					this.tdiv.style.top = t + "px";
					*/
					this.tdiv.style.left=document.body.scrollLeft;
					this.tdiv.style.top =document.body.scrollTop;

					this.tdiv.innerHTML=msg;
					this.tdiv.style.display="inline";
		if(this.debug) arr.document.write('show end <br>');
	},
	
	hide: function(){
		this.tdiv.style.display="none";
	}
}); 

function selectbox_hidden(layer_id) 
    { 

		
       if( typeof(layer_id)=="string" ){
		var ly = eval¡¡(layer_id); 
	   } else {
		var ly = layer_id; 
	   }
		
		//Aprint(ly);
        // ·¹ÀÌ¾î ÁÂÇ¥ 
        var ly_left  = ly.offsetLeft; 
        var ly_top    = ly.offsetTop; 
        var ly_right  = ly.offsetLeft + ly.offsetWidth; 
        var ly_bottom = ly.offsetTop + ly.offsetHeight; 

        // ¼¿·ºÆ®¹Ú½ºÀÇ ÁÂÇ¥ 
        var el; 
		
        for (i=0; i<document.forms.length; i++) { 
            for (k=0; k<document.forms[i].length; k++) { 
                el = document.forms[i].elements[k];    
                if (el.type == "select-one") { 
                    var el_left = el_top = 0; 
                    var obj = el; 
                    if (obj.offsetParent) { 
                        while (obj.offsetParent) { 
                            el_left += obj.offsetLeft; 
                            el_top  += obj.offsetTop; 
                            obj = obj.offsetParent; 
                        } 
                    } 
                    el_left  += el.clientLeft; 
                    el_top    += el.clientTop; 
                    el_right  = el_left + el.clientWidth; 
                    el_bottom = el_top + el.clientHeight; 
					//walert("selectbox_hidden=>"+"el_left:"+el_left+";ly_left:"+ly_left+";el_top:"+el_top+";ly_top:"+ly_top+"ly_right:"+ly_right+";el_right:"+el_right+";ly_bottom:"+ly_bottom+";el_bottom:"+el_bottom);
                    // ÁÂÇ¥¸¦ µûÁ® ·¹ÀÌ¾î°¡ ¼¿·ºÆ® ¹Ú½º¸¦ Ä§¹üÇßÀ¸¸é ¼¿·ºÆ® ¹Ú½º¸¦ hidden ½ÃÅ´ 
                    if ( (el_left >= ly_left && el_top >= ly_top && el_left <= ly_right && el_top <= ly_bottom) || 
                        (el_right >= ly_left && el_right <= ly_right && el_top >= ly_top && el_top <= ly_bottom) || 
                        (el_left >= ly_left && el_bottom >= ly_top && el_right <= ly_right && el_bottom <= ly_bottom) || 
                        (el_left >= ly_left && el_left <= ly_right && el_bottom >= ly_top && el_bottom <= ly_bottom) ) {
						   el.style.visibility = 'hidden'; 
						//   walert("selectbox_hidden_apply_div_id=>"+ly.id);
						   // walert("selectbox_hidden_select_name=>"+el.name);

					}else{
						   el.style.visibility = '';
					}
                } 
            } 
        } 
    } 


  function selectbox_visible() 
    { 
        for (i=0; i<document.forms.length; i++) { 
            for (k=0; k<document.forms[i].length; k++) { 
                el = document.forms[i].elements[k];    
                if (el.type == "select-one" && el.style.visibility == 'hidden') 
                    el.style.visibility = 'visible'; 
            } 
        } 
    } 



function hide_ctrl(e) // ´Ù¸¥ °÷ Å¬¸¯ÇÏ¸é ·¹ÀÌ¾î ¾Èº¸ÀÌ°Ô... 
{ 
    if(!e) var e = window.event; 
    var srcEle = (IE) ? event.srcElement : e.target; 

	if(!srcEle.id || srcEle.id.indexOf('_exit') == -1){
	 
	 if($('autoTextDiv') && $('autoTextDiv').style.display=='none') selectbox_visible();
	 if($('autoTextDiv')) $('autoTextDiv').style.display='none';
	 if($('xmldiv')) $('xmldiv').style.display='none';
	 
	 
	}
} 

// IE¿Í FF ±¸ºÐÇØ¼­ ÀÌº¥Æ® Ã·ºÎ 
if(IE) {
	if(document.body) document.body.attachEvent('onmousedown', hide_ctrl); 
}
else{
	document.addEventListener('mousedown', hide_ctrl, false); 
}






function event_handle(obj,eventName,Func){

	if (obj.addEventListener)//FF
		obj.addEventListener(eventName, Func, false);
	else if (obj.attachEvent)//IE
		obj.attachEvent("on"+eventName, Func);
	else if (obj.getElementById)
		eval(obj.toString()+".on"+eventName)=Func;
	
	//alert('end');
}


var WalertWin=null;
var DEBUGING=false;
function walert(msg){
		if(DEBUGING==true){
			try{
				WalertWin.document.write (msg+"<br>");
			} catch(e){
				WalertWin = window.open('','WalertWin','toolbar=yes,scrollbars=yes,width=1024,height=300');
				WalertWin.document.open("text/html","replace");
				WalertWin.document.write (msg+"<br>");
			}
		}
}
