/*-----------------------------------------------------------------
ÇÁ·Î±×·¥À̸§ : °Ë»ö¾î ÀÚµ¿¿Ï¼º
ÃÖÃÊÀÛ¼ºÀÚ : ½Åµ¿±Ô
ÃÖÃÊÀÛ¼ºÀÏ : 2006.03.23 (¸ñ)
-----------------------------------------------------------------*/
var searchSuggestDisplay = false;
var lastSearchWord = '';
var searchSuggestionWords = new Array();
var searchSuggestionLinks = new Array();
var lastSearchSuggestionWords = '';
var currentSearchSuggestionElement = 0;
function hideSuggestion()
{
if(searchSuggestDisplay == false)
{
try
{
document.getElementById('searchSuggestion').innerHTML = '';
document.getElementById('searchSuggestion').style.display = 'none';
document.getElementById('searchOption').style.display = 'none';
}
catch(e)
{
}
}
}
function getSuggestion(obj)
{
if(document.searchItem.sf.value != 'ttl')
{
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)
{
document.getElementById('searchOption').style.display = 'block';
document.getElementById('searchSuggestion').style.display = 'block';
document.getElementById('searchSuggestion').innerHTML = '';
if(!str)
{
lastSearchSuggestionWords = '';
//searchSuggestDisplay = false;
//hideSuggestion();
document.getElementById('searchSuggestion').innerHTML = '
Ãßõ °Ë»ö¾î°¡ ¾ø½À´Ï´Ù.';
document.getElementById('searchSuggestion').style.visibility = 'hidden';
return;
}
else
{
document.getElementById('searchSuggestion').style.visibility = 'visible';
}
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('searchOption').style.display = 'none';
document.getElementById('searchSuggestion').style.display = 'none';
return;
}
for(var i=0; i' + lastSearchWord + '');
document.getElementById('searchSuggestion').innerHTML += "" + 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).className = '';
}
if(i == 0) return;
currentSearchSuggestionElement = i;
document.getElementById('searchSuggestionElement' + currentSearchSuggestionElement).className = 'selected';
}
function selectSearchElement(e)
{
var height = 18;
var showLine = 11;
var curr = currentSearchSuggestionElement;
var target;
var obj, currObj;
if(event.keyCode == '40')
{
target = curr + 1;
}
else if(event.keyCode == '38')
{
target = curr - 1;
}
else if(event.keyCode == '13')
{
if (currentSearchSuggestionElement)
{
insertSearchWord(currentSearchSuggestionElement - 1);
searchSuggestDisplay = false;
currentSearchSuggestionElement = 0;
return false;
}
else
{
return true;
}
}
else
{
return true;
}
if(obj = document.getElementById('searchSuggestionElement' + target))
{
if(currObj = document.getElementById('searchSuggestionElement' + curr))
{
currObj.className = '';
}
obj.className = 'selected';
obj.focus();
if (document.getElementById('searchSuggestion').scrollTop < Math.max(0, height * (target - showLine)))
{
document.getElementById('searchSuggestion').scrollTop = Math.max(0, height * (target - showLine));
}
else if (document.getElementById('searchSuggestion').scrollTop > height * (target - 1))
{
document.getElementById('searchSuggestion').scrollTop = height * (target - 1);
}
currentSearchSuggestionElement = target;
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