/* if (typeof AITIA_POSITION == 'undefined') { document.write(""); } */ var search_lastSearchString = ''; var search_lastSendSearchString = ''; var _timedCall = 0; var searchTimer = null; var automaticFocus = false; var searchControl; var siteSearch; var SEARCH_MIN_SEARCHSTRING_LENGTH = 2; var GOOGLE_SEARCH_API_KEY; var RESULT_DIV = "googleResults"; var RESULTS_NUM = 5; var STRING_MAX_LENGTH = 42; var ALL_RESULTS_STRING = LANG['SEARCH_ALL_GOOGLE_RESULTS']; var NO_RESULTS_STRING = LANG['SEARCH_NO_GOOGLE_RESULTS']; var RESULT_TITLE = "Google"; var searchDelay = 700; // delay between typing and request function search_fastSearchManage(webraInstanceId, automatic, resultPosition) { if (automaticFocus) { automaticFocus = false; return; } if (window.event && window.event.keyCode == 13) { if (searchTimer) { clearTimeout(searchTimer); searchTimer = null; document.getElementById('searchInput').style.backgroundPosition = "-1000px"; } if (document.getElementById('searchInput')) { search_lastSendSearchString = document.getElementById('searchInput').value; } search_sendSearchRequest(webraInstanceId, resultPosition); } else { if (document.getElementById('searchInput') && document.getElementById('searchInput').value.length > SEARCH_MIN_SEARCHSTRING_LENGTH && search_lastSearchString != document.getElementById('searchInput').value) { if (searchTimer) { clearTimeout(searchTimer); } searchTimer = setTimeout("search_fastSearchManageSend('" + webraInstanceId + "', '" + resultPosition + "');", searchDelay); } } if (document.getElementById('searchInput')) { search_lastSearchString = document.getElementById('searchInput').value; } } function search_fastSearchManageSend(webraInstanceId, resultPosition) { if (document.getElementById('searchInput') && document.getElementById('searchInput').value.length > SEARCH_MIN_SEARCHSTRING_LENGTH && search_lastSearchString == document.getElementById('searchInput').value) { search_lastSendSearchString = document.getElementById('searchInput').value; search_sendSearchRequest(webraInstanceId, resultPosition); search_fastSearchManage(webraInstanceId, false, resultPosition); } } function search_sendSearchRequest(webraInstanceId, resultPosition) { if (document.getElementById('searchInput').value.length >= SEARCH_MIN_SEARCHSTRING_LENGTH) { var callbackParams = new Array(); callbackParams.push(Array('resultPosition', resultPosition)); document.getElementById('searchInput').style.backgroundPosition = "right"; addRequest('/main.php?webraInstance=' + webraInstanceId + '&webraRequestType=xmlhttp&webra_action=search_xmlhttprequest&searchStr=' + encodeURIComponent(document.getElementById('searchInput').value), 'search_refreshSearchResult', Array(), callbackParams); } } function search_refreshSearchResult(answerXML, callbackParams) { var resultPosition; if (callbackParams) { for (var i = 0; i < callbackParams.length; i++) { if (callbackParams[i][0] == "resultPosition") { resultPosition = callbackParams[i][1]; } } } if (!resultPosition) { resultPosition = 'left'; } var answer = unescape(answerXML); if (document.getElementById('searchInput') && search_lastSendSearchString == document.getElementById('searchInput').value) { var searchInput = document.getElementById('searchInput'); var newDiv = document.getElementById('searchresultfixed'); searchInput.style.backgroundPosition = '-1000px'; if (newDiv) { newDiv.parentNode.removeChild(newDiv); newDiv.setAttribute('id', ''); newDiv.innerHTML = ''; newDiv = null; } if (!newDiv) { //tartalmazó elem létrehozása, ha még nincs var newDiv = document.createElement('div'); document.body.appendChild(newDiv); newDiv.setAttribute('id', 'searchresultfixed'); newDiv.setAttribute('class', 'select-free'); newDiv.innerHTML = '
'; } newDiv.style.position = 'absolute'; document.getElementById('searchresult').style.position = 'static'; newDiv.style.display = 'block'; var searchresultElement = document.getElementById('searchresult'); if (searchresultElement) { if (GOOGLE_SEARCH_API_KEY != '') { try { loadGoogleJS(); } catch (err) { console.info(err.message); } } searchresultElement.innerHTML = answer; newDiv.style.visibility = 'visible'; var searchInputX = findPosX(searchInput); var searchInputY = findPosY(searchInput); if (resultPosition == 'left') { if (searchInputX + newDiv.offsetWidth < Aitia.Position.getInnerWidth()) { // a felugró popup nem lógna ki jobb oldalon newDiv.style.top = (searchInputY + searchInput.offsetHeight) + 'px'; newDiv.style.left = (searchInputX) + 'px'; } else { // a felugró popup kilógna jobb oldalon newDiv.style.top = (searchInputY + searchInput.offsetHeight) + 'px'; newDiv.style.left = (Aitia.Position.getInnerWidth() - newDiv.offsetWidth) + 'px'; } } else if (resultPosition == 'right') { if (0 < searchInputX + searchInput.offsetWidth - newDiv.offsetWidth) { // a felugró popup nem lógna ki bal oldalon newDiv.style.top = (searchInputY + searchInput.offsetHeight) + 'px'; newDiv.style.left = (searchInputX + searchInput.offsetWidth - newDiv.offsetWidth) + 'px'; //newDiv.style.backgroundColor = 'red'; } else { // a felugró popup kilógna bal oldalon newDiv.style.top = (searchInputY + searchInput.offsetHeight) + 'px'; newDiv.style.left = (Aitia.Position.getInnerWidth() - newDiv.offsetWidth) + 'px'; //newDiv.style.backgroundColor = 'green'; } } if (document.getElementById('searchresult_close')) { document.getElementById('searchresult_close').style.visibility = 'visible'; if (document.all) { document.getElementById('searchresult_close').style.left = searchresultElement.clientWidth - 5 + 'px'; } else { document.getElementById('searchresult_close').style.left = searchresultElement.offsetWidth - 5 + 'px'; } } alphaBackgrounds(); } } } function search_closeResultbox() { hideElementTimer('searchresultfixed', 1000, 1); hideElementTimer('searchresult_close', 1, 1); } // Google keresés függvényei --------------------- // Google kereső JS betöltő fv function loadGoogleJS() { if (typeof google == 'undefined' || (typeof google == 'object' && typeof google.load != 'function')) { // 1: még nem volt betöltve a google jsapi, ezért nincs google class // 2: be van töltve a google simplemap api, ezért van google class, csak nincs load metódusa var script = document.createElement("script"); script.src = document.location.protocol + "//www.google.com/jsapi?callback=loadGoogleApi"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); } else { loadGoogleApi(); } } // Google kereső api betöltő fv function loadGoogleApi() { if (typeof siteSearch == 'undefined') { // be kell tölteni a search api-t // A googleMain elindítja az első keresést is google.load('search', '1', {"nocss" : true, "callback": googleMain}); } else { // Már be van töltve a search api, indítható a keresés googleStartSearch(); } } // Google kereső inicializáló fv function googleMain() { siteSearch = new google.search.WebSearch(); siteSearch.setUserDefinedLabel(RESULT_TITLE); siteSearch.setResultSetSize(google.search.Search.LARGE_RESULTSET); siteSearch.setNoHtmlGeneration(); siteSearch.setUserDefinedClassSuffix("siteSearch"); siteSearch.setSiteRestriction(GOOGLE_SEARCH_API_KEY); siteSearch.setSearchCompleteCallback(null, googleSearchComplete, [null]); googleStartSearch(); } // Google keresés indítása function googleStartSearch() { var searchInput = document.getElementById('searchInput'); if (!searchInput) { return false; } siteSearch.execute(searchInput.value); } // Google keresés eredményének feldolgozása function googleSearchComplete() { var divText; var input = document.getElementById("searchInput"); if (siteSearch.results && siteSearch.results.length) { var i; divText = "
" + RESULT_TITLE + " (" + siteSearch.cursor.estimatedResultCount + ")"; for (i = 0; i < siteSearch.results.length; i++) { if (RESULTS_NUM > i) { var result = siteSearch.results[i]; if (result.titleNoFormatting.length > STRING_MAX_LENGTH) { result.titleNoFormatting = result.titleNoFormatting.substring(0, STRING_MAX_LENGTH - 3) + "..."; } divText += ""; } } divText += "
"; if (document.getElementById(RESULT_DIV) != null) { document.getElementById(RESULT_DIV).innerHTML = divText; } } else { if (document.getElementById(RESULT_DIV) != null) { document.getElementById(RESULT_DIV).innerHTML = NO_RESULTS_STRING; } } //setCloseDivPosition(); } // Google keresés függvényeinek vége ------------- // GUI függvények -------------------------------- function search_dateFieldStepper(e, nextField, maxlen) { if (String.fromCharCode(Aitia.Event.getKeyCode(e)).match(/[a-zA-Z0-9]/) && maxlen <= Aitia.Event.getTarget(e).value.length) { document.getElementById(nextField).focus(); } return true; } // GUI függvények vége ---------------------------