var lastTime=0;var idleTime=0;var interval=3000;var isIdle=false;var idleNotify=false;var shoutCountDisplay=15;var timer=null;var altClass="alt1";var pageRefresh=true;var shoutIdArray=[];var kirbyLeft=true;$(document).ready(function(){danceKirby();Update();$("form#shoutbox").submit(function(){if(!isIdle){var msg=$("#msg").val();if(msg!=""){$.ajax({type:"POST",url:"0d189553f40e477dac09a91c68dce052.php",data:"act=new&msg="+msg,complete:function(data){idleTime=0;Refresh();}});$("#msg").val("");}}return false;});});function Refresh(){$.ajax({type:"POST",url:"0d189553f40e477dac09a91c68dce052.php",data:"act=update&time="+lastTime+"&shoutCount="+shoutCountDisplay,complete:function(data){var obj=$.parseJSON(data.responseText);$.each(obj,function(na,shoutData){if(!inShoutIdArray(shoutData.shout_id)){var string=null;var id="<span style='display: none;'>"+shoutData.shout_id+"</span>";var alertMe="";var msgOrAction="msg";if(shoutData.shout_msg.toLowerCase().match(shoutData.my_username.toLowerCase())!=null){alertMe="alertMe";}if(shoutData.shout_msg.substr(0,3)=="/me"){string=id+"<span class='action'><span style='color: #"+shoutData.user_colour+"; font-weight: bold;'>"+shoutData.username+"</span> "+shoutData.shout_msg.substr(4)+"</span>";msgOrAction="action";}else if(shoutData.shout_msg.substr(0,5)=="/star"){string=id+"<span class='action' style='color: #d100d1;'><span style='color: #"+shoutData.user_colour+"; font-weight: bold;'>"+shoutData.username+"</span> gives a big StarRaven wave to "+shoutData.shout_msg.substr(6)+"</span>";msgOrAction="action";}else if(shoutData.shout_msg.substr(0,6)=="/dance"){string=id+"<span class='action'><span style='color: #"+shoutData.user_colour+"; font-weight: bold;'>"+shoutData.username+"</span> <span class='kirby'>(v ^.^ v)</span></span>";}else{string=id+"<span class='msg'><span style='font-weight: bold;'><span style='color: #"+shoutData.user_colour+"; text-decoration: underline;'>"+shoutData.username+"</span> :</span> "+shoutData.shout_msg+"</span>";}if(shoutData.shout_time>lastTime){lastTime=shoutData.shout_time;}var add="<div class='fade "+altClass+" "+alertMe+"'>"+"<span title='Shout #"+shoutData.shout_id+"'>"+string+"</span></div>";$("div#shoutbox_msgs").prepend(add);if(!pageRefresh){$("div.fade").slideDown("fast");}else{$("div.fade").fadeIn("slow");}if(shoutIdArray.length==shoutCountDisplay){shoutIdArray.pop();}shoutIdArray.unshift(shoutData.shout_id);if(altClass=="alt1"){altClass="alt2";}else{altClass="alt1";}}});pageRefresh=false;var shoutCount=$("div#shoutbox_msgs > div").size();if(shoutCount>shoutCountDisplay){var removeCount=shoutCount-shoutCountDisplay;for(var i=0;i<removeCount;i++){$("div#shoutbox_msgs div:last").remove();}}}});}function Update(){if(!isIdle){if(!idleNotify){Refresh();idleTime+=interval/1000;if(idleTime>300){idleNotify=true;}}else{var shoutCount=$("div#shoutbox_msgs > div").size();for(var i=0;i<shoutCount;i++){$("div#shoutbox_msgs div:last").remove();}$("form#shoutbox").fadeOut("slow");$("form#shoutbox").remove();$("div#shoutbox_msgs").prepend("<div class='fade alt1'><span class='msg'>Chat session has timed out! Refresh the page!</span></div>");$("div.fade").fadeIn("slow");isIdle=true;}clearTimeout(timer);timer=setTimeout(Update,interval);}}function inShoutIdArray(id){for(var i=0;i<shoutIdArray.length;i++){if(shoutIdArray[i]==id){return true;}}return false;}function danceKirby(){if($("span.kirby").html()=="(v ^.^ v)"){if(kirbyLeft){$("span.kirby").html("&lt;(^.^&lt;)");kirbyLeft=false;}else{$("span.kirby").html("(&gt;^.^)&gt;");kirbyLeft=true;}}else if(($("span.kirby").html()=="&lt;(^.^&lt;)")||($("span.kirby").html()=="(&gt;^.^)&gt;")){$("span.kirby").html("(v ^.^ v)");}setTimeout(danceKirby,500);}