/******************************************************************************************************************** AJAX XMLHttpRequest Objekt ********************************************************************************************************************/ var xmlHttp = null; try { // Mozilla, Opera, Safari sowie Internet Explorer (ab v7) xmlHttp = new XMLHttpRequest(); } catch(e) { try { // MS Internet Explorer (ab v6) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { // MS Internet Explorer (ab v5) xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp = null; } } } /******************************************************************************************************************** SUCHE ********************************************************************************************************************/ var currentSearchSelection = 0; var currentSearch; var lastSearchNavigation; document.onkeydown = function(e) { if (!e || !e.keyCode) return true; var k = e.keyCode; if(k == 38 && k == 40) { return false; } } function doSearchNav(e) { if(document.getElementById('searchRecommendation').style.display == 'none') return; if(e.keyCode == 40) { if (new Date().getTime() - lastSearchNavigation < 100) return; lastSearchNavigation = new Date().getTime(); dehighlightSearchResults(); if (document.getElementById('searchRes' + (currentSearchSelection + 1))) currentSearchSelection++; else if (currentSearchSelection == 0) { currentSearchSelection = 1; } else { currentSearchSelection = 0; document.getElementById('searchbox').value = currentSearch; return; } document.getElementById('searchbox').value = document.getElementById('searchRes' + currentSearchSelection).innerText; document.getElementById('searchRes' + currentSearchSelection).style.backgroundColor = '#dddddd'; } else if (e.keyCode == 38) { if (new Date().getTime() - lastSearchNavigation < 100) return; lastSearchNavigation = new Date().getTime(); dehighlightSearchResults(); if (document.getElementById('searchRes' + (currentSearchSelection - 1))) currentSearchSelection--; else if (currentSearchSelection == 0) { currentSearchSelection = 1; while(document.getElementById('searchRes' + currentSearchSelection)) { currentSearchSelection++; } currentSearchSelection--; } else { currentSearchSelection = 0; document.getElementById('searchbox').value = currentSearch; return; } document.getElementById('searchbox').value = document.getElementById('searchRes' + currentSearchSelection).innerText; document.getElementById('searchRes' + currentSearchSelection).style.backgroundColor = '#dddddd'; } } function doSubmitSearch() { if (currentSearchSelection == 0 || currentSearch == document.getElementById('searchbox').value) return true; document.getElementById('searchRes' + currentSearchSelection).onclick(); return false; } function doSearch(e) { if (e.keyCode >= 38 && e.keyCode <= 40) return; if (e.keyCode == 27) { currentSearchSelection = 0; document.getElementById('searchbox').value = currentSearch; document.getElementById('searchRecommendation').style.display = 'none'; return; } currentSearch = document.getElementById('searchbox').value; if (xmlHttp) { xmlHttp.open('GET', '/search.php?s=' + currentSearch, true); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { document.getElementById('searchRecommendation').innerHTML = xmlHttp.responseText; if (xmlHttp.responseText.length > 0) { document.getElementById('searchRecommendation').style.display = 'block'; } else { document.getElementById('searchRecommendation').style.display = 'none'; } } }; xmlHttp.send(null); } } function dehighlightSearchResults() { var i = 0; while(true) { i++; if (document.getElementById('searchRes' + i)) document.getElementById('searchRes' + i).style.backgroundColor = '#ffffff'; else break; } } /******************************************************************************************************************** PREIS DETAILS ANZEIGEN ********************************************************************************************************************/ function togglePriceDetails(id) { if (document.getElementById('priceDetails_' + id).style.display == 'none') { document.getElementById('priceDetails_' + id).style.display = 'block'; } else { document.getElementById('priceDetails_' + id).style.display = 'none'; } } /******************************************************************************************************************** FALSCHER PREIS MELDEN ********************************************************************************************************************/ function toggleWrongPriceInput(id) { if (document.getElementById('notifyWrongPriceInput_' + id).style.display == 'none') { document.getElementById('notifyWrongPriceInput_' + id).style.display = 'block'; if (!document.getElementById('wrongPriceComment_' + id).disabled) document.getElementById('wrongPriceComment_' + id).focus(); } else { document.getElementById('notifyWrongPriceInput_' + id).style.display = 'none'; } } function sendWrongPriceInfo(id) { document.getElementById('wrongPriceButton_' + id).disabled = true; document.getElementById('wrongPriceComment_' + id).disabled = true; if (xmlHttp) { var params = 'Id=' + id + '&Text=' + document.getElementById('wrongPriceComment_' + id).value; xmlHttp.open('POST', '/wrongprice.php', true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.setRequestHeader('Content-Length', params.length); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { document.getElementById('notifyWrongPriceInput_' + id).style.display = 'none'; } }; xmlHttp.send(params); } } /******************************************************************************************************************** EMAIL-SERVICE ********************************************************************************************************************/ function toggleEmailService() { if (document.getElementById('emailService').style.display == 'none') { document.getElementById('emailService').style.display = 'block'; if (!document.getElementById('emailServiceEmail').disabled) document.getElementById('emailServiceEmail').focus(); } else { document.getElementById('emailService').style.display = 'none'; } } function registerForEmailService(productId) { if (!isValidEmail(document.getElementById('emailServiceEmail').value)) { document.getElementById('emailServiceEmail').style.backgroundColor = '#ffe1e1'; document.getElementById('emailServiceEmail').focus(); return; } document.getElementById('emailServiceButton').disabled = true; document.getElementById('emailServiceEmail').disabled = true; document.getElementById('emailServiceEmail').style.backgroundColor = '#f6f6f6'; if (xmlHttp) { var params = 'Pid=' + productId + '&Email=' + document.getElementById('emailServiceEmail').value; xmlHttp.open('POST', '/emailservice.php', true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.setRequestHeader('Content-Length', params.length); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { document.getElementById('emailService').style.display = 'none'; alert(xmlHttp.responseText); } }; xmlHttp.send(params); } } function isValidEmail(email) { var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/; if (pattern.test(email)) return true; else return false; } /******************************************************************************************************************** VOTINGS ********************************************************************************************************************/ var voted = false; var starsVoted = 0; function toggleWriteComment() { if (document.getElementById('commentForm').style.display == 'none') { document.getElementById('commentForm').style.display = 'block'; if (!document.getElementById('commentName').disabled) document.getElementById('commentName').focus(); } else { document.getElementById('commentForm').style.display = 'none'; } } function voteStar(star) { if (voted) return; for(i = 1; i <= star; i++) { document.getElementById('voteStar' + i).src = '/images/symbols/black_star_full.gif'; } for(i = star + 1; i <= 6; i++) { document.getElementById('voteStar' + i).src = '/images/symbols/black_star_empty.gif'; } starsVoted = star; } function submitShopVote(shopId) { submitVote("Shop", shopId); } function submitProductVote(productId) { submitVote("Product", productId); } function submitVote(entityType, entityId) { if (document.getElementById('commentName').value.length < 5) { document.getElementById('commentName').style.backgroundColor = '#ffe1e1'; document.getElementById('commentName').focus(); return; } document.getElementById('commentName').style.backgroundColor = '#f6f6f6'; if (starsVoted == 0) { for(i = 1; i <= 6; i++) { document.getElementById('voteStar' + i).src = '/images/symbols/red_star_empty.gif'; } return; } document.getElementById('commentSubmitButton').disabled = true; document.getElementById('commentName').disabled = true; document.getElementById('commentText').disabled = true; document.getElementById('commentName').style.backgroundColor = '#f6f6f6'; voted = true; if (xmlHttp) { var params = (entityType == 'Shop' ? 'Sid=' : 'Pid=') + entityId + '&Name=' + document.getElementById('commentName').value + '&Comment=' + document.getElementById('commentText').value + '&Stars=' + starsVoted; xmlHttp.open('POST', '/vote.php', true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.setRequestHeader('Content-Length', params.length); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4) { document.getElementById('commentForm').style.display = 'none'; alert(xmlHttp.responseText); } }; xmlHttp.send(params); } } /******************************************************************************************************************** Live-Ticker auf Startseite ********************************************************************************************************************/ var liveTickerPos = 0; function animateLiveTicker() { document.getElementById('tickerText1').style.left = (document.getElementById('tickerText1').style.left.substring(0, document.getElementById('tickerText1').style.left.indexOf('px')) - 1) + 'px'; document.getElementById('tickerText2').style.left = (document.getElementById('tickerText2').style.left.substring(0, document.getElementById('tickerText2').style.left.indexOf('px')) - 1) + 'px'; if (document.getElementById('tickerText2').offsetLeft == 10) { var tickerSpan1 = document.getElementById('tickerText1'); document.getElementById('navigationContextHome').removeChild(tickerSpan1); document.getElementById('tickerText2').style.left = '0px'; tickerSpan1.style.left = '0px'; document.getElementById('navigationContextHome').appendChild(tickerSpan1); } else if (document.getElementById('tickerText1').offsetLeft == 10) { var tickerSpan2 = document.getElementById('tickerText2'); document.getElementById('navigationContextHome').removeChild(tickerSpan2); document.getElementById('tickerText1').style.left = '0px'; tickerSpan2.style.left = '0px'; document.getElementById('navigationContextHome').appendChild(tickerSpan2); } } /******************************************************************************************************************** Externe Links XHTML valid ********************************************************************************************************************/ function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i