function getPosition(e){ var left = 0; var top = 0; while (e.offsetParent){ if (e.offsetLeft != "") left += e.offsetLeft; if (e.offsetTop != "") top += e.offsetTop; e = e.offsetParent; } if (e.offsetLeft != "") left += e.offsetLeft; if (e.offsetTop != "") top += e.offsetTop; return {x:left, y:top}; } var noAjax=0; var searchBox = 0; var searchCurrent = ""; var searchTimer = 0; function keyUp(e,srcObj) { var characterCode; if (e && e.which) { // (NN4) e = e; characterCode = e.which; } else { // IE+FF e = event; characterCode = e.keyCode; } if (characterCode == 13) { closeSearch(srcObj); noAjax=1; //document.search.submit(); document.forms["frmSearch"].submit(); } else { doSearch(srcObj); } } function doSearch (srcObj) { if (searchTimer != 0) { window.clearTimeout(searchTimer); searchTimer = 0; } if (srcObj.value == searchCurrent) return(false); searchTimer = window.setTimeout("timerSearch(3)", 200); return(false); } function timerSearch(searchTextLenght) { searchTimer = 0; srcObj = document.getElementById('search_string'); var searchStringLength = srcObj.value.length; if(searchStringLength >= searchTextLenght && noAjax == 0) { searchCurrent = srcObj.value; myUrl = "http://www.sportxx.ch/action.cfm"; $.ajax({ type: "GET", url: myUrl, data: ({ action:'element' ,type:'search' ,execute:'display' ,search_mode:'result' ,search_life:'active' ,dms_search_active:'true' ,productsearch_search_active:'true' ,search_string: searchCurrent }) ,beforeSend: function() { $("div#searchBox").html('loading'); }, success: loadSearch ,error: errorSearch ,cache: false ,async: true }); } } var allowClose = false; var suppressCloseBox = false; function preventCloseBox () { suppressCloseBox = true; } function loadSearch(result) { srcObj = document.getElementById('search_string'); splits = result.split(''); if (splits[1] != srcObj.value) return; result = splits[2]; searchBox.innerHTML = result; if (result != "") {} searchBox.style.display = 'block'; /* $("div#searchBox a[href]").click( function() { $("#search_string").val(this.title); document.forms["headerboundingboxSearch"].submit(); return false; } ) */ } function errorSearch(XMLHttpRequest, code, msg) { alert("Ajax-Error "+code+": " + msg); } function openSearch(srcObj, searchText, searchTextLenght) { srcObj.value = ""; parentObj = document.getElementById('frmHeaderSuche'); if (searchBox == 0) { pos = getPosition(srcObj); searchBox = document.createElement("div"); searchBox.id = 'searchBox'; searchBox.className = 'searchBoxStyle'; searchBox.style.zIndex = 1000; searchBox.onmouseover = function() {allowClose = false;}; searchBox.onmouseout = function() {allowClose = true;}; parentObj.appendChild(searchBox); searchBox.innerHTML = "Bitte geben Sie einen Suchbegriff mit mindestens drei Buchstaben ein."; } searchBox.style.display = 'block'; } document.onclick = function() { if(allowClose) { closeSearchTimer(); allowClose = false; } else { //focus } } function closeSearch (srcObj) { if (suppressCloseBox == false && searchBox != 0) { window.setTimeout("closeSearchTimer()",200); } suppressCloseBox = false; } function closeSearchTimer() { srcObj = document.getElementById('search_string'); // alert(allowClose); if (searchBox != 0 && allowClose == true) { searchBox.style.display = 'none'; } } function resizeSearch (e) { if (searchBox != 0) { srcObj = document.getElementById('search_string'); pos = getPosition(srcObj); } } window.onresize = resizeSearch;