function _AutoTextMan() {
	var AutoTextMan = Class.create({
		initialize: function(inputBox, searchFunction) {
		    this.inputBox = inputBox;
			this.searchFunction = searchFunction;
			this.keyword = '';
			
			this.inputBox.setAttribute('autocomplete', 'off');
			this.inputBox.setStyle('ime-mode', 'active');
			
			var body = $$('body');
			this.body = body[0];
			
			this.autoTextTRCount = 0;
			this.autoTextTRNow = -1;
			this.autoTextTROverNow = -1;
            
            this.createAutoImage();
			this.inputBoxTopLeft = this.inputBox.cumulativeOffset();			
			this.inputBoxWidth   = this.inputBox.getWidth();
			this.inputBoxHeight  = this.inputBox.getHeight();
			this.createAutoTextDiv();

			Event.observe(window, 'resize', this.resizeAutoTextMan.bind(this));
			
			Event.observe(this.inputBox, 'click', this.searchAutoText.bind(this));//°Ë»ö
			Event.observe(this.inputBox, 'click', this.showAutoTextDiv2.bind(this));						
			
			Event.observe(this.inputBox, 'focus', this.setInputValue.bind(this));
			Event.observe(this.inputBox, 'blur', this.setInputValue2.bind(this));
			
			if(Prototype.Browser.IE) {
				Event.observe(this.inputBox, 'keyup', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keypress', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keydown', this.scrollPressAutoText.bind(this));
			}
			else {
				Event.observe(this.inputBox, 'keyup', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keypress', this.scrollPressAutoText.bind(this));
			}
			Event.observe(document, 'click', this.hideAutoTextDiv2.bind(this));			
			
			if(this.inputBox.value == '') {
			    this.inputBox.value = '°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä';
			}
		},
		setInit: function(inputBox, searchFunction) {
		    
		    try{
		        Event.stopObserving(this.inputbox, 'click');
		        
		        Event.stopObserving(this.inputBox, 'focus');
			    Event.stopObserving(this.inputBox, 'blur');
    		    
                if(Prototype.Browser.IE) {
				    Event.stopObserving(this.inputBox, 'keyup');
				    Event.stopObserving(this.inputBox, 'keypress');
				    Event.stopObserving(this.inputBox, 'keydown');
			    }
			    else {
				    Event.stopObserving(this.inputBox, 'keyup');
				    Event.stopObserving(this.inputBox, 'keypress');
			    }
			}catch(e){};
		    
		    this.inputBox = inputBox;
			this.searchFunction = searchFunction;
			this.keyword = '';
			this.inputBox.value = '°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä';
			
			this.inputBox.setAttribute('autocomplete', 'off');
			this.inputBox.setStyle('ime-mode', 'active');
			
			var body = $$('body');
			this.body = body[0];
			this.inputBoxTopLeft = this.inputBox.cumulativeOffset();
			this.inputBoxWidth = this.inputBox.getWidth();
			this.inputBoxHeight = this.inputBox.getHeight();

			Event.observe(window, 'resize', this.resizeAutoTextMan.bind(this));
			
			Event.observe(this.inputBox, 'click', this.searchAutoText.bind(this));//°Ë»ö
			Event.observe(this.inputBox, 'click', this.showAutoTextDiv2.bind(this));			
			
			Event.observe(this.inputBox, 'focus', this.setInputValue.bind(this));
			Event.observe(this.inputBox, 'blur', this.setInputValue2.bind(this));
			
			if(Prototype.Browser.IE) {
				Event.observe(this.inputBox, 'keyup', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keypress', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keydown', this.scrollPressAutoText.bind(this));
			}
			else {
				Event.observe(this.inputBox, 'keyup', this.searchAutoText.bind(this));
				Event.observe(this.inputBox, 'keypress', this.scrollPressAutoText.bind(this));
			}
			Event.observe(document, 'click', this.hideAutoTextDiv2.bind(this));			
			
		},
		setInputValue: function() {
		    if(this.inputBox.value == '°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä') {
		        this.inputBox.value = '';
		    }
//		    else if(this.inputBox.value == '') {
//		        this.inputBox.value = '°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä';
//		    }
		},
		setInputValue2: function() {
		    if(this.inputBox.value == '') {
		        this.inputBox.value = '°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä';
		    }
		    //this.hideAutoTextDiv();
		},
		
		hideAutoTextDiv: function() {

			this.autoTextDiv.hide();
			if($('Combo_H_Large')) $('Combo_H_Large').show();
			if($('Combo_H_Middle')) $('Combo_H_Middle').show();
			if($('Combo_H_Small')) $('Combo_H_Small').show();
			if($('SelAreaResult'))  $('SelAreaResult').show();			    					
		},
		hideAutoTextDiv2: function(event) {
            
			var autoImg = Event.findElement(event, 'span');
			if(autoImg == this.AutoImageDiv ) {			    
			
			    Event.stop(event); 
			    return;
			    
			}
			
			var ele = Event.findElement(event, 'INPUT');   	
			
			if(ele != this.inputBox ) {
				this.autoTextDiv.hide();				
			    if($('Combo_H_Large')) $('Combo_H_Large').show();
			    if($('Combo_H_Middle')) $('Combo_H_Middle').show();
			    if($('Combo_H_Small')) $('Combo_H_Small').show();			    
			    if($('SelAreaResult'))  $('SelAreaResult').show();			    		
			}
		},
		showAutoTextDiv2: function() {		    
			if(this.inputBox.value.length > 0) {
				this.autoTextDiv.show();
				if($('Combo_H_Large')) $('Combo_H_Large').hide();
				if($('Combo_H_Middle')) $('Combo_H_Middle').hide();
				if($('Combo_H_Small')) $('Combo_H_Small').hide();				
				if($('SelAreaResult'))  $('SelAreaResult').hide();			    		
			}
		},
		showAutoTextDiv: function() {
		  	this.autoTextDiv.show();
			if($('Combo_H_Large')) $('Combo_H_Large').hide();
			if($('Combo_H_Middle')) $('Combo_H_Middle').hide();
			if($('Combo_H_Small')) $('Combo_H_Small').hide();			
			if($('SelAreaResult'))  $('SelAreaResult').hide();			    		
		},		
		
		createAutoTextDiv: function() {
				
			this.autoTextDiv = new Element('div');			
			this.autoTextDiv.style.zIndex = 2;			
			var table1 = new Element('table');
			table1.width = '100%';
			table1.border = 0;
			table1.cellpadding = 0;
			table1.cellspacing = 1;
			table1.setStyle({'backgroundColor':'#9E8C6D'});
			
			var tbody1 = new Element('tbody');
			var tbody2 = new Element('tbody');
			
			var tr11 = new Element('tr');
			var td111 = new Element('td');

			td111.setStyle({'backgroundColor':'#FFFFFF'});
			
			this.autoTextInnerDiv = new Element('div');
			this.autoTextInnerDiv.setStyle({'background-color':'#FFFFFF', 'width':'100%'});
			this.autoTextInnerDiv.style.overflowY = 'hidden';
			this.autoTextInnerDiv.style.overflowX = 'hidden';

			
			var table1111 = new Element('table');
			table1111.width = '100%';
			table1111.border = 0;
			table1111.cellspacing = 0;
			table1111.cellpadding = 0;
			
			var tr11111 = new Element('tr');
			this.autoTextContentTD = new Element('td');
			
			this.autoTextContentTD.setStyle({'padding':'10px'});
			this.autoTextContentTD.className = 'nomal_txt';
			
			var tr12 = new Element('tr');
			var td121 = new Element('td');
			td121.align = 'right';
			td121.className = 'nomal_stxt';
			td121.setStyle({'backgroundColor':'#FBE9C1', 'padding':'3px'});
			
			var a1 = new Element('a');
			this.autoTextOption = new Element('a');
			var span = new Element('span');
			
			span.innerHTML = ' | ';
			a1.href = '/Scripts/Customer/Faq/FaqView.aspx?idx=199';
			a1.target = '_blank';
			a1.innerHTML = 'µµ¿ò¸»';
			
			this.autoTextOption.value = Cookies.get('AutoTextOption');
			this.autoTextOption.href = 'javascript:void(0)';
			this.autoTextOption.onclick = this.updateAutoTextOption.bind(this);
            
            this.autoTextContentTD.align = 'left';
            
			if(this.autoTextOption.value == "null" || this.autoTextOption.value == null || this.autoTextOption.value == "1") {
				this.autoTextContentTD.innerHTML = 'ÇöÀç<span class="tit_orangetxt"><b> ÀÚµ¿¿Ï¼º </b></span>±â´ÉÀ» »ç¿ë Áß ÀÔ´Ï´Ù.';
				this.autoTextOption.innerHTML = '±â´É²ô±â';
			}
			else {
				this.autoTextContentTD.innerHTML = '<span class="tit_orangetxt"><b>ÀÚµ¿¿Ï¼º ±â´ÉÀÌ¶õ?</b></span><br>»ç¿ëÀÚ°¡ ¸¹ÀÌ Ã£´Â °Ë»ö¾î¸¦ ¹Ì¸® ÃßÃµÇØ ÁÖ´Â Æí¸®ÇÑ ¼­ºñ½º ÀÔ´Ï´Ù.';
				this.autoTextOption.innerHTML = '±â´ÉÄÑ±â';
			}
			
			td121.appendChild(a1);
			td121.appendChild(span);
			td121.appendChild(this.autoTextOption);
			
			tr11111.appendChild(this.autoTextContentTD);
			tbody1.appendChild(tr11111);
			table1111.appendChild(tbody1);
			this.autoTextInnerDiv.appendChild(table1111);
			td111.appendChild(this.autoTextInnerDiv);
			tr11.appendChild(td111);
			tr12.appendChild(td121);
			tbody2.appendChild(tr11);
			tbody2.appendChild(tr12);
			
			table1.appendChild(tbody2);
			
			this.autoTextDiv.appendChild(table1);

			this.body.appendChild(this.autoTextDiv);
			
			this.resizeAutoTextDiv();
			
			this.autoTextDiv.hide();
		},
		resizeAutoTextDiv: function() {
			this.autoTextDiv.absolutize();			
	        this.autoTextDiv.setStyle({'width'  :(this.inputBoxWidth + 23 ) + 'px'
                        , 'left':(this.inputBoxTopLeft.left -3 )+ 'px'
                        , 'top' :(this.inputBoxTopLeft.top + this.inputBoxHeight + 2) + 'px'});		
			
		},
		createAutoImage: function() {
			
            var backImgUrl , backImgWidth;
			
			this.AutoImageDiv = new Element('span');
			
			//ÅëÇÕ°Ë»ö Ã¢ 23px
			if(this.inputBox.getHeight() > 16){
                backImgUrl      ="/Images/Main/bg_inputbox02.gif";
                backImgWidth    = "17px";
                btnImgUrl       = "/Images/Main/btn_arrowmore.gif";
                
            //Áöµµ°Ë»öÃ¢16px            	    
			}else{
                backImgUrl      = "/Images/Map/SearchMap/bg_searchbox02.gif";
                backImgWidth    = "18px";
                btnImgUrl       = "/Images/Map/SearchMap/IconSearchAuto.gif";
			}
			this.AutoImageDiv.setStyle({'width':backImgWidth
                                    ,'background-image':backImgUrl
                                    ,'background-position':'center'
                                    ,'text-align':'center'
			                    });
			
			var image = new Element('img');
			image.src = btnImgUrl;
			image.onclick = this.showAutoText.bind(this);
			image.setStyle({'cursor':'pointer'});
			this.AutoImageDiv.appendChild(image);
			Element.insert(this.inputBox.parentNode, this.AutoImageDiv);
			
			//Element.next(this.inputBox).innerHTML =;
			//this.inputBox.parentElement.parentElement.appendChild(AutoImageTd);
			//this.inputBox.parentElement.parentNode.insertBefore(AutoImageTd,this.inputBox.parentElement.nextSibling);
			//this.inputBox.parentElement.insert(AutoImageTd);
			//this.inputBox.parentElement.parentNode.insertBefore(AutoImageTd,this.inputBox.parentElement.nextSiblings);
			//this.inputBox.parentElement.insertAdjacentElement("afterEnd", AutoImageTd);				
            
		},
		resizeAutoImage: function() {
		
			this.inputBoxTopLeft = this.inputBox.cumulativeOffset();
			this.inputBoxWidth = this.inputBox.getWidth();
			this.inputBoxHeight = this.inputBox.getHeight();
			/*
			this.AutoImageDiv.absolutize();
			var imageWidth = 10;
			var imageHeight = 7;
			var left = this.inputBoxTopLeft.left + this.inputBoxWidth - (imageWidth * 1.5);
			this.AutoImageDiv.setStyle({'width':imageWidth + 'px', 'left':left + 'px', 'top':(this.inputBoxTopLeft.top) + 'px', 'height':imageHeight + 'px', paddingTop:parseInt((this.inputBoxHeight - imageHeight) / 2) + 'px'});
            */			
		},
		resizeAutoTextMan: function() {
			this.resizeAutoImage();
			this.resizeAutoTextDiv();
		},
		showAutoText: function(event) {
		
			if(this.autoTextDiv.getStyle('display') == "none"){
				this.showAutoTextDiv2();
			}else{
			    this.hideAutoTextDiv();
			}
			/*
			if(this.autoTextDiv.getStyle('display') == "block" || this.autoTextDiv.getStyle('display') == "") {
				//this.autoTextDiv.hide();
			    this.hideAutoTextDiv();
			}
			else {						    
				this.showAutoTextDiv2();
				//this.autoTextDiv.show();				
			}*/			
		},
		updateAutoTextOption: function() {
			if(this.autoTextOption.value == null || this.autoTextOption.value == "1") {
				this.autoTextOption.value = "0";
				Cookies.set('AutoTextOption', '0', 365);
			}
			else {
				this.autoTextOption.value = "1";
				Cookies.set('AutoTextOption', '1', 365);
			}
			this.clearAutoText();
		},
		searchAutoText: function(e) {
			if(e.keyCode == Event.KEY_RETURN) {
				this.searchFunction();
				this.clearAutoText();
				return false;
			}
			else if(e.keyCode ==  Event.KEY_UP || e.keyCode ==  Event.KEY_DOWN || e.keyCode == Event.KEY_BACKSAPCE || e.keyCode == Event.KEY_TAB || e.keyCode == Event.KEY_ESC
				|| e.keyCode == Event.KEY_LEFT || e.keyCode == Event.KEY_RIGHT || e.keyCode == Event.KEY_DELETE
				|| e.keyCode == Event.KEY_HOME || e.keyCode == Event.KEY_END || e.keyCode == Event.KEY_PAGEUP
				|| e.keyCode == Event.KEY_PAGEDOWN) {
				return false;
			}
			else {
				//°Ë»ö ¼öÇà
				var keyword = this.inputBox.value.strip();
				if(this.keyword != keyword) {
					this.keyword = keyword;
				}
				else {
					return false;
				}
				
				if(this.keyword.length == 0) {
					this.hideAutoTextDiv();
					return false;
				}
				
				if(this.autoTextOption.value == '0') {
					return false;
				}
				
				this.KeywordLength = 0;
				
				if(Prototype.Browser.IE) {
					new Ajax.Request('/Scripts/Common/Service/SearchAutoText.aspx',
					{
						method : 'post',
						parameters : {'Keyword': this.keyword},
						onSuccess: this.searchAutoText_CallBack.bind(this),
						onFailure: function(){return;}
					});
				}
				else {
					new Ajax.Request('/Scripts/Common/Service/SearchAutoText.aspx',
					{
						method : 'post',
						parameters : {'Keyword': this.keyword},
						encoding : 'euc-kr',
						contentType : 'application/x-www-form-urlencoded',
						onSuccess: this.searchAutoText_CallBack.bind(this),
						onFailure: function(){return;}
					});
				}
				return false;
			}
		},
		scrollAutoText: function() {
			if($('autoTextTR_' + this.autoTextTRNow)) {
				if($('autoTextTR_' + this.autoTextTRNow).getHeight() * this.autoTextTRNow > this.autoTextDiv.getHeight()-57) {
					this.autoTextInnerDiv.scrollTop = ($('autoTextTR_' + this.autoTextTRNow).getHeight() + 2) * (this.autoTextTRNow - 4);
				}
			}
		},
		scrollPressAutoText: function(e) {
			if(e.keyCode ==  Event.KEY_UP) {
				if(this.autoTextTRNow > 0) {
					if($('autoTextTR_' + this.autoTextTRNow)) {
						$('autoTextTR_' + this.autoTextTRNow).style.backgroundColor = '#ffffff';
					}
					this.autoTextTRNow--;
					if($('autoTextTR_' + this.autoTextTRNow)) {
						$('autoTextTR_' + this.autoTextTRNow).style.backgroundColor = '#e8dfc5';
						this.inputBox.value = $('autoTextTR_' + this.autoTextTRNow).value;
					}
				}
				this.scrollAutoText();
			}
			else if (e.keyCode == Event.KEY_DOWN) {
				if(this.autoTextTRNow < this.autoTextTRCount - 1) {
					if($('autoTextTR_' + this.autoTextTRNow)) {
						$('autoTextTR_' + this.autoTextTRNow).style.backgroundColor = '#ffffff';
					}
					this.autoTextTRNow++;
					if($('autoTextTR_' + this.autoTextTRNow)) {
						$('autoTextTR_' + this.autoTextTRNow).style.backgroundColor = '#e8dfc5';
						this.inputBox.value = $('autoTextTR_' + this.autoTextTRNow).value;
					}
				}
				this.scrollAutoText();
			}
		},
		clearAutoText: function() {
			var childTable = this.autoTextContentTD.childElements();

			if(childTable != null || childTable != undefined) {
				for(var i = 0; i < childTable.length; i++) {
					childTable[i].remove();
				}
			}
			
			this.autoTextInnerDiv.setStyle({'height':''});
			this.autoTextInnerDiv.style.overflowY = 'hidden';
			this.autoTextContentTD.setStyle({'padding':'10px'});

			this.autoTextContentTD.align = 'left';
			
			if(this.autoTextOption.value == null || this.autoTextOption.value == "1") {
				this.autoTextOption.innerHTML = '±â´É²ô±â';
				this.autoTextContentTD.innerHTML = 'ÇöÀç<span class="tit_orangetxt"><b> ÀÚµ¿¿Ï¼º </b></span>±â´ÉÀ» »ç¿ë Áß ÀÔ´Ï´Ù.';
			}
			else {
				this.autoTextOption.innerHTML = '±â´ÉÄÑ±â';
				this.autoTextContentTD.innerHTML = '<span class="tit_orangetxt"><b>ÀÚµ¿¿Ï¼º ±â´ÉÀÌ¶õ?</b></span><br>»ç¿ëÀÚ°¡ ¸¹ÀÌ Ã£´Â °Ë»ö¾î¸¦ ¹Ì¸® ÃßÃµÇØ ÁÖ´Â Æí¸®ÇÑ ¼­ºñ½º ÀÔ´Ï´Ù.';
			}
			
			this.autoTextDiv.hide();			
		},
		searchAutoText_CallBack: function(res) {
			var result = res.responseText;
			
			var childTable = this.autoTextContentTD.childElements();
			
			if(childTable != null || childTable != undefined) {
				for(var i = 0; i < childTable.length; i++) {
					childTable[i].remove();
				}
			}

			if(result.length == 0) {
				this.hideAutoTextDiv();
				return;
			}
			
			this.autoTextInnerDiv.setStyle({'height':'110px'});
			this.autoTextInnerDiv.style.overflowY = 'scroll';
			this.autoTextContentTD.align = 'left';
			
			this.showAutoTextDiv2();
			
			if($('Combo_H_Large')) $('Combo_H_Large').hide();
			if($('Combo_H_Middle')) $('Combo_H_Middle').hide();
			if($('Combo_H_Small')) $('Combo_H_Small').hide();
			
			this.autoTextContentTD.innerHTML = '';
			this.autoTextContentTD.setStyle({'padding':'0px'});
			
			var keywords = result.split('|');
			
			this.KeywordLength = keywords.length;
			
			var table = new Element('table');
			var tbody = new Element('tbody');
			
			table.width = '100%';

			this.autoTextTRCount = keywords.length;
			this.autoTextTRNow = -1;
			this.autoTextTROverNow = -1;

			for(var i = 0; i < keywords.length; i++) {
				var tr = new Element('tr');
				var td = new Element('td');
				
				tr.id = 'autoTextTR_' + i;
				tr.setStyle({'cursor':'pointer'});
				
				td.setStyle({'padding-left':'10px'});
				
				tr.value = keywords[i];
				tr.onmouseover = this.overAutoTextTR.bind(this, i);
				td.onclick = this.clickAutoTextTr.bind(this, i);
				td.setStyle({'text-decoration':'none'});
				td.addClassName('autotext_txt');
				
				keywords[i] = keywords[i].replace(this.inputBox.value, '<span class="select_txt">' + this.inputBox.value + '</span>');

				var a = new Element('a');
				a.href = 'javascript:void(0);';
				a.setStyle({'display':'block'});
				a.addClassName('autotext_txt');
				a.innerHTML = keywords[i];
				
				td.appendChild(a);
				//td.innerHTML = keywords[i];
				
				tr.appendChild(td);
				tbody.appendChild(tr);
			}
			
			table.appendChild(tbody);
			
			this.autoTextContentTD.appendChild(table);
		},
		clickAutoTextTr: function(index) {
			this.overAutoTextTR(index);
			this.inputBox.value = $('autoTextTR_' + this.autoTextTROverNow).value;
			
			this.searchFunction();
			this.clearAutoText();
			return false;
		},
		overAutoTextTR: function(index) {
			if($('autoTextTR_' + this.autoTextTROverNow)) {
				$('autoTextTR_' + this.autoTextTROverNow).style.backgroundColor = '#ffffff';
			}
			
			this.autoTextTROverNow = index;
			
			if($('autoTextTR_' + this.autoTextTROverNow)) {
				$('autoTextTR_' + this.autoTextTROverNow).style.backgroundColor = '#e8dfc5';
			}
		}
	});
	window.AutoTextMan = AutoTextMan;
};
_AutoTextMan();
