// Shoutbox script (c) 2008 by Saga-Games \\ var ajaxColor; var ajaxColorTimeHandle; var ajaxTimeHandle; var timeHandle; var shoutMaxSize = 350; // Max. Größe var openSpeed = 8; // Geschwindigkeit var direction; // Nach oben oder unten? var fadeStart = -1; // Start des Fadevorgangs var IE = (navigator.appName.indexOf("Microsoft") !=-1); document.getElementById("shoutboxdiv").innerHTML="";var shoutSize = 0; updateBox(); adjustForm(); function openshoutbox() { if(!document.getElementById) {return true;} if(fadeStart != -1) return false; shoutSize = 0; var sbd=document.getElementById("shoutboxdiv"); sbd.style.display="block"; sbd.innerHTML='
' +'' +'
' +'
' +'' +'
' +'
' +'
Smilies:
' +' Lächeln Grinsen Zwinkern Ätsch! Glücklich Sonnenbrille Traurig Genervt Neutral Achtung! Weinen Erstaunt Ups... Herz LOL! Leeres Gesicht' +'Liste ausblenden
'; if (http != null) createAjaxShoutbox(); // use ajax else sbd.innerHTML += ''; adjustForm(); var dt = new Date; fadeStart = dt.getTime(); shoutboxFadeIn(); return false; } function closeshoutbox() { if(fadeStart != -1) return false; if (http != null) { // use ajax http.abort(); http.open("GET", "shoutbox.php?activate=off&empty", true); try {http.send(null);} catch (e) {} } else if(navigator.cookieEnabled == true) { // use cookie document.cookie = "shoutbox=; expires=Thu, 01-Jan-70 00:00:01 GMT;"; } else { // use html document.getElementById("shoutbox").src = "shoutbox.php?activate=off&stay"; } var dt = new Date; fadeStart = dt.getTime(); shoutboxFadeOut(); return false; } function shoutboxFadeIn() { var dt = new Date; direction = 1; window.clearTimeout(timeHandle); shoutSize = (dt.getTime() - fadeStart) / openSpeed; updateBox(); if(shoutSize < 100) { timeHandle = window.setTimeout("shoutboxFadeIn()", 10); } else { document.getElementById("openshoutbox").style.display="none"; document.getElementById("closeshoutbox").style.display="inline"; fadeStart = -1; } } function shoutboxFadeOut() { var dt = new Date; direction = -1; window.clearTimeout(timeHandle); shoutSize = 100 - (dt.getTime() - fadeStart) / openSpeed; updateBox(); if(shoutSize > 0) { timeHandle = window.setTimeout("shoutboxFadeOut()", 10); } else { document.getElementById("openshoutbox").style.display="inline"; document.getElementById("closeshoutbox").style.display="none"; document.getElementById("shoutboxdiv").innerHTML = ""; fadeStart = -1; } } function updateBox() { if(!document.shoutform) {return;} if(shoutSize < 0) shoutSize = 0; if(shoutSize > 100) shoutSize = 100; with(document.getElementById("shoutbox").style) { opacity = shoutSize / 100; if(IE) filter="Alpha(opacity=" + shoutSize + ")"; height = Math.round(shoutMaxSize * percent2height(shoutSize)) + "px"; } with(document.shoutform.style) { opacity = shoutSize / 100; if(IE) filter="Alpha(opacity=" + shoutSize + ")"; height = Math.round(65 * percent2height(shoutSize)) + "px"; } } function sbRemovetext(element, standard) { hideSmilies(); if(element.value == standard) { element.value=""; element.style.color="#000"; } } function sbRestoretext(element, standard) { if(element.value == "" || element.value == standard) { element.value=standard; element.style.color="#888"; } else { element.style.color="#000"; } } function adjustForm() { if(document.shoutform) { hideSmilies(); document.getElementById("shoutsmilies").onmousedown=showSmilies; sbRestoretext(document.shoutform.name, "Name"); sbRestoretext(document.shoutform.text, "Nachricht"); } } function checkshoutform(){ with(document.shoutform.text) { if(value=="" || value=="Nachricht"){ alert("Bitte gib zuerst einen Text ein."); focus(); return false; } } if(http != null) { ajaxFade(16); if(document.getElementById("reloadsb")) document.getElementById("reloadsb").firstChild.src="bilder/ajax.gif"; http.abort(); http.open("POST", "shoutbox.php?ajax", true); http.onreadystatechange = showAjax; http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); var clearText = true; try {http.send("sc=a9357beeafcef390f66ecfe2e8f31c24&name=" + escapex(document.shoutform.name.value) + "&text=" + escapex(document.shoutform.text.value));} catch (e) {clearText = false;} if(clearText == true) { document.shoutform.text.value=""; document.shoutform.text.focus(); } return false; } return true; } function showSmilies(ev){ if(!ev) ev=window.event; var woffsetX, woffsetY; if(typeof document.documentElement.scrollLeft=='number') woffsetX = document.documentElement.scrollLeft; if(typeof document.scrollLeft=='number') woffsetX = document.scrollLeft; if(typeof window.pageXOffset=='number') woffsetX = window.pageXOffset; if(typeof document.documentElement.scrollTop=='number') woffsetY = document.documentElement.scrollTop; if(typeof document.scrollTop=='number') woffsetY = document.scrollTop; if(typeof window.pageYOffset=='number') woffsetY = window.pageYOffset; with(document.getElementById("smilieliste").style) { display="block"; if(ev) { left = (woffsetX+ev.clientX)+"px"; top = (woffsetY+ev.clientY)+"px"; } } } function hideSmilies(){ document.getElementById("smilieliste").style.display="none"; } function addSmilie(code){ with(document.shoutform.text) { var tcol = style.color; if(value == "Nachricht" && (tcol.indexOf("888") || tcol.indexof("136"))) {value="";} value += " " + code; style.color="black"; } hideSmilies(); } function percent2height(percent) { if(percent <= 0) return 0; // avoid NaN if(percent >= 100) return 1; // avoid NaN return (1 - Math.cos(Math.abs(percent * direction) / 100 * Math.PI)) / 2; } function showAjax() { if (!http || http.readyState != 4) return; ajaxFade(-8); document.getElementById("shoutbox").innerHTML = http.responseText; window.clearTimeout(ajaxTimeHandle); ajaxTimeHandle = window.setTimeout("updateShoutbox()", 20000); document.getElementById("shoutbox").style.backgroundImage="none"; if(document.getElementById("reloadsb")) document.getElementById("reloadsb").firstChild.src="bilder/shout-refresh.png"; } function updateShoutbox() { if(http == null || http.readyState == 1) return; window.clearTimeout(ajaxTimeHandle); if(document.getElementById("reloadsb")) document.getElementById("reloadsb").firstChild.src="bilder/ajax.gif"; http.abort(); http.open("GET", "shoutbox.php?ajax", true); http.onreadystatechange = showAjax; try {http.send(null);} catch (e) {} } function createAjaxShoutbox() { if(document.getElementById("shoutbox")) document.getElementById("shoutboxdiv").removeChild(document.getElementById("shoutbox")); var shoutboxcontent = document.createElement("div"); shoutboxcontent.id="shoutbox"; with(shoutboxcontent.style) { margin="0"; padding="2px"; width="154px"; height=shoutSize+"px"; overflow="auto"; background="url(bilder/ajax.gif) no-repeat center"; } shoutboxcontent.onclick=function() {hideSmilies();} document.getElementById("shoutboxdiv").appendChild(shoutboxcontent); ajaxColor = 248; http.abort(); http.open("GET", "shoutbox.php?activate=on&stay&ajax", true); http.onreadystatechange = showAjax; try {http.send(null);} catch (e) {updateShoutbox()} } function ajaxFade(step) { if(!document.getElementById("shoutbox")) return; window.clearTimeout(ajaxColorTimeHandle); ajaxColor+=step; if(ajaxColor < 0) ajaxColor = 0; else if(ajaxColor > 160 && Math.abs(step) == step) ajaxColor = 160; else ajaxColorTimeHandle = window.setTimeout("ajaxFade(" + step + ")", 10); document.getElementById("shoutbox").style.color="rgb("+ajaxColor+","+ajaxColor+","+ajaxColor+")"; } function escapex(text) { return escape(encode64(text)).replace(/\+/g, "%2B"); } // This code was written by Tyler Akins and has been placed in the // public domain. It would be nice if you left this header intact. // Base64 code from Tyler Akins -- http://rumkin.com function encode64(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) enc3 = enc4 = 64; else if(isNaN(chr3)) enc4 = 64; output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while (i < input.length); return output; }