var _shoutApp="";var _shoutColor=1;var _shoutDoc=null;var _shoutFullLoad=0;var _shoutIdle=0;var _shoutLastPost=null;var _shoutMsgs={};var _shoutRRate=2000;var _shoutRRateMax=5000;var _shoutScrollDown=true;var _shoutScrollInit=false;var _shoutScrollLast=-1;var _shoutScrollTop=0;var _shoutState=0;window.onload=function(){_shoutFullLoad=1};function _shoutStart(c,a){_shoutDoc=document.getElementById(c);_shoutDoc.onscroll=function(f){if(_shoutScrollInit&&_shoutScrollLast!=_shoutDoc.scrollTop&&!_shoutScrollTop&&!_shoutState){var d=_shoutScrollLast-_shoutDoc.scrollTop>0;var g=Math.max(0,_shoutDoc.scrollHeight-_shoutDoc.offsetHeight-_shoutDoc.scrollTop);_shoutScrollDown=(!d&&g<50)||_shoutScrollLast==-1;_shoutScrollLast=_shoutDoc.scrollTop}};_shoutLastPost=new Date().getTime();_shoutApp=a;_shoutRRate=_shoutRRateMax;_shoutScrollBottom();var b=_shoutDoc.innerHTML+"ENDOFFILE";_shoutDoc.innerHTML="";_shoutUpdate(b);setTimeout("_shoutGetContent()",_shoutRRateMax)}function _shoutGetContent(b,a){_shoutAjax("/shout/shout"+_shoutApp+".html?"+new Date().getTime(),"_shoutContent(xmlHttp.responseText,"+new Date().getTime()+","+b+","+a+");")}function _shoutContent(e,d,c,a){if(d>=_shoutLastPost&&_shoutState!=1){_shoutUpdate(e,a)}var b=new Date().getTime()-_shoutLastPost;if(b>1000*60*60){if(!_shoutIdle){_shoutDoc.innerHTML+='<br /><div style="background:#FFFFFF;text-align:center"><b><a href="javascript:;" onclick="_shoutRefresh();setTimeout(\'_shoutGetContent()\',_shoutRRateMax);" style="color:#000000">You have been idle for more than 1 hour. Please click here to refresh the chat box.</a></b></div>';_shoutIdle=1;_shoutScrollBottom()}}_shoutRRate+=(Math.ceil((new Date().getTime()-_shoutLastPost)*0.005));_shoutRRate=Math.min(_shoutRRateMax,Math.max(2000,_shoutRRate),_shoutRRate);if(c!==false&&!_shoutIdle){setTimeout("_shoutGetContent()",_shoutRRate)}}function _shoutPost(h,c,g,f,d){var e=document.getElementById(g);var a=document.getElementById(h);d.disabled=true;e.blur();e.disabled=true;a.value=_shoutTrim(a.value);if(a.value==c||a.value==""){alert("Please enter your name.");d.disabled=false;e.disabled=false;a.value="";a.focus();return}e.value=_shoutTrim(e.value);if(f!=""){var b=new RegExp("^"+f,"i");e.value=e.value.replace(b,"")}if(e.value==f||e.value==""){alert("Please enter your message.");d.disabled=false;e.disabled=false;e.value="";e.focus();return}msgVal=e.value;_shoutAjax("/shout/post.php?name="+escape(a.value)+"&msg="+escape(msgVal)+"&nocache="+new Date().getTime(),"_shoutPosted(xmlHttp.responseText,'"+d.id+"','"+g+"','"+f+"');");_shoutLastPost=new Date().getTime()}function _shoutPosted(c,e,d,b){var a=document.getElementById(d);a.disabled=false;document.getElementById(e).disabled=false;if(c.match(/^ERROR=/)){c=c.replace(/ERROR=/,"");alert(c);return}a.value="";a.focus();_shoutUpdate(c)}function _shoutUpdate(k,j){if(_shoutState==1){return}_shoutState=1;if(!k.match(/ENDOFFILE$/)){return}k=_shoutTrim(k.replace(/ENDOFFILE$/,""));if(_shoutEmpty(_shoutMsgs)){_shoutDoc.innerHTML=""}var c=k.split("/-->");var h="";var o="";var e=0;var m={};var g=0;for(var f in c){var d=_shoutTrim(c[f]);var b=d.match(/[0-9]+$/);if(b==null||d==""){continue}var l=_shoutMsgs[b]!=undefined&&_shoutMsgs[b]!="";d=d.replace(/<!--\/SEP[0-9]+/,"");if(e==0){if(l){e=_shoutMsgs[b].match(/shoutBg1/)?1:2}else{e=_shoutColor}_shoutColor=e}if(e==2){d=d.replace(/shoutBg1/g,"shoutBg2")}else{d=d.replace(/shoutBg2/g,"shoutBg1")}var n='<div id="__shout'+b+'">'+d+"</div>";if(l&&_shoutMsgs[b]!=n){document.getElementById("__shout"+b).innerHTML=d}_shoutMsgs[b]=n;e=e==1?2:1;if(!l){if(!g){g=2}h+=n}else{if(g==2){g=1}}o+=n;m[b]=n}if(!_shoutEmpty(_shoutMsgs)){for(var b in _shoutMsgs){if(_shoutTrim(_shoutMsgs[b])==""){continue}if(m[b]==undefined){_shoutMsgs[b]="";if(document.getElementById("__shout"+b)!=undefined){document.getElementById("__shout"+b).parentNode.removeChild(document.getElementById("__shout"+b))}}}}if(g==1){_shoutDoc.innerHTML="";h=o}var a=document.createElement("div");a.innerHTML=h;_shoutDoc.appendChild(a);if(_shoutScrollDown){setTimeout("_shoutScroll();_shoutScrollTop = 0;",1)}else{if(j){setTimeout("_shoutDoc.scrollTop = _shoutScrollTop;_shoutScrollTop = 0;",1)}else{_shoutScrollTop=0}}_shoutState=0}function _shoutScroll(){_shoutScrollBottom()}function _shoutScrollBottom(){_shoutDoc.scrollTop=_shoutDoc.scrollHeight;if(_shoutScrollInit==false){if(_shoutFullLoad>0||_shoutDoc.scrollHeight>0){_shoutScrollInit=true}setTimeout("_shoutScrollBottom()",100)}}function _shoutDelete(a){_shoutRefresh(false);_shoutAjax("/shout/delete.php?id="+a,"_shoutDeleted(xmlHttp.responseText);")}function _shoutDeleted(a){if(a.match(/^ERROR=/)){a=a.replace(/ERROR=/,"");alert(a);return}_shoutUpdate(a,true)}function _shoutBan(a){_shoutRefresh(false);_shoutAjax("/shout/delete.php?id="+a+"&ban=1","_shoutBanned(xmlHttp.responseText);")}function _shoutBanned(a){if(a.match(/^ERROR=/)){a=a.replace(/ERROR=/,"");alert(a);return}_shoutUpdate(a,true)}function _shoutRefresh(a){_shoutScrollTop=_shoutDoc.scrollTop;_shoutScrollLast=0;_shoutState=2;_shoutIdle=0;_shoutLastPost=new Date().getTime();_shoutMsgs={};_shoutDoc.innerHTML='<div style="padding:4px;text-align:center">REFRESHING...</div>';if(a!==false){_shoutGetContent(false,true)}}function _shoutPrefill(a){document.getElementById("shoutboxMsg").value="@"+a+" - ";if(document.getElementById("shoutboxMsg").type=="text"){document.getElementById("shoutboxMsg").focus()}}function _shoutAjax(url,codeSuccess){var xmlHttp;try{xmlHttp=new XMLHttpRequest()}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){alert("Your browser does not support AJAX!");return false}}}xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){eval(codeSuccess)}};xmlHttp.open("GET",url,true);xmlHttp.send(null)}function _shoutEmpty(a){for(var b in a){if(a.hasOwnProperty(b)){return false}}return true}function _shoutTrim(a){return a.replace(/^\s+|\s+$/g,"")};