/*----------------------------------------------------------------- ÇÁ·Î±×·¥À̸§ : °Ë»ö¾î ÀÚµ¿¿Ï¼º ÃÖÃÊÀÛ¼ºÀÚ : ½Åµ¿±Ô ÃÖÃÊÀÛ¼ºÀÏ : 2006.03.23 (¸ñ) -----------------------------------------------------------------*/ var searchSuggestDisplay = false; var lastSearchWord = ''; var searchSuggestionWords = new Array(); var searchSuggestionLinks = new Array(); var lastSearchSuggestionWords = ''; var currentSearchSuggestionElement = 0; var timerSearchAreaController; function hideSuggestion() { if(searchSuggestDisplay == false) { try { document.getElementById('searchSuggestion').innerHTML = ''; document.getElementById('searchSuggestion').style.display = 'none'; document.getElementById('searchSuggestionMask').style.display = 'none'; } catch(e) { } } } function getSuggestion(obj) { if(document.searchItem.sf.value != 'itemTitle') return; objvalue = trim(obj.value); if(objvalue == lastSearchWord) { return; } loadXMLDoc('/main/common/include/inc_autoCompleteIng.php?w=' + objvalue + '&t=' + Date(), showSuggestion); lastSearchWord = objvalue; } function showSuggestion(str) { if(!str) { lastSearchSuggestionWords = ''; searchSuggestDisplay = false; hideSuggestion(); //document.getElementById('searchSuggestion').innerHTML = '


Ãßõ °Ë»ö¾î°¡ ¾ø½À´Ï´Ù
'; return; } if(lastSearchSuggestionWords == str && lastSearchSuggestionWords) { return; } lastSearchSuggestionWords = str; currentSearchSuggestionElement = 0; searchSuggestionWords = str.split("\n"); var tmp = searchSuggestionWords[0].split("`"); if(searchSuggestionWords.length == 1 && tmp[0] == document.getElementById('searchWordForm').value) { document.getElementById('searchSuggestionMask').style.display = 'none'; document.getElementById('searchSuggestion').style.display = 'none'; return; } document.getElementById('searchSuggestionMask').style.top = document.getElementById('searchWordForm').offsetTop + 19; document.getElementById('searchSuggestionMask').style.left = document.getElementById('searchWordForm').offsetLeft; document.getElementById('searchSuggestionMask').style.width = document.getElementById('searchWordForm').offsetWidth; document.getElementById('searchSuggestionMask').style.display = 'inline'; document.getElementById('searchSuggestion').style.top = document.getElementById('searchWordForm').offsetTop + 19; document.getElementById('searchSuggestion').style.left = document.getElementById('searchWordForm').offsetLeft; document.getElementById('searchSuggestion').style.width = document.getElementById('searchWordForm').offsetWidth; document.getElementById('searchSuggestion').style.display = 'inline'; document.getElementById('searchSuggestion').innerHTML = ''; var elementWidth = (searchSuggestionWords.length > 4) ? document.getElementById('searchWordForm').offsetWidth : document.getElementById('searchWordForm').offsetWidth; for(var i=0; i" + showStr[0] + showStr[1] + ""; } } function insertSearchWord(idx) { if(searchSuggestionWords[idx]) { var ssw = searchSuggestionWords[idx].split("`"); document.getElementById('searchWordForm').value = ssw[0]; } } function setCurrentSearchSuggestionElement(i) { if(currentSearchSuggestionElement != 0) { document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = ''; } if(i == 0) return; currentSearchSuggestionElement = i; document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FFEFA3'; //document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).focus(); } function selectSearchElement(e) { if(event.keyCode == '40') { if(currentSearchSuggestionElement != 0) { try { document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FDF7D5'; } catch(e) { return; } } currentSearchSuggestionElement++; try { document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FFEFA3'; document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).focus(); } catch(e) { try { currentSearchSuggestionElement--; document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FFEFA3'; } catch(e) { } } return false; } if(event.keyCode == '38') { if(currentSearchSuggestionElement != 0) { try { document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FDF7D5'; } catch(e) { return; } } currentSearchSuggestionElement--; try { document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FFEFA3'; document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).focus(); } catch(e) { document.getElementById('searchWordForm').focus(); try { currentSearchSuggestionElement++; document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).style.background = '#FFEFA3'; } catch(e) { } } return false; } if(event.keyCode == '13') { insertSearchWord(currentSearchSuggestionElement - 1); document.getElementById('searchWordForm').focus(); return false; } return true; } /*----------------------------------------------------------------- AJAX functions -----------------------------------------------------------------*/ var xmlHTTPReq = null; var xmlHTTPReqCB = null; /* * some work to use XMLHTTPRequest Object */ function prepareXmlHTTPRequest() { if(window.XMLHttpRequest) { try { xmlHTTPReq = new XMLHttpRequest(); } catch(e) { xmlHTTPReq = false; } } else if(window.ActiveXObject) { try { xmlHTTPReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHTTPReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xmlHTTPReq = false; } } } } function processReqChange() { if (xmlHTTPReq.readyState == 4) { // Loaded if (xmlHTTPReq.status == 200) { // only if "OK" xmlHTTPReqCB(unescape(xmlHTTPReq.responseText)); } else { //alert("error"); } } } /* * Simple Call for requesting Document */ function loadXMLDoc(url, cb) { prepareXmlHTTPRequest(); if (xmlHTTPReq) { xmlHTTPReqCB = cb; xmlHTTPReq.onreadystatechange = processReqChange; try { xmlHTTPReq.open("GET", url, true); xmlHTTPReq.send(""); } catch (e) { //alert("There may be one or more problem to execute XML request"); } } delete xmlHTTPReq; } /* * call of Form element for requesting Document */ function submitFormToXMLDoc(form_id, cb) { var form; var method; var action; var postData = ""; form = document.getElementById(form_id); if ( !form ) { //alert("check form id"); return false; } method = form.method.toUpperCase(); if ( !method ) { //alert("form must have an attribute 'method'"); return false; } action = form.action; if ( !action ) { //alert("form must have an attribute 'action'"); return false; } prepareXmlHTTPRequest(); if (xmlHTTPReq) { xmlHTTPReqCB = cb; xmlHTTPReq.onreadystatechange = processReqChange; } else { return false; } if (method == "POST") { xmlHTTPReq.open(method, action, true); if (xmlHTTPReq) { for (i=0; i