$(document).ready(init);var msgTimeout;var logDisplayed=false;function init(){$("#clchat_form").submit(addMsg);$("#clchat_cmd_logs").click(switchDisplayLog);$("#clchat_cmd_archive").click(rqArchive);$("#clchat_cmd_flush").click(rqFlush);$("#clchat_loading").hide();$("#clchat_dialogBox").hide();$("#clchat_loading").ajaxStart(function(){$(this).show()});$("#clchat_loading").ajaxStop(function(){$(this).hide()});rqRefresh();rqRefreshUserList();setInterval(rqRefresh,refreshRate);setInterval(rqRefreshUserList,userListRefresh);$("#clchat_msg").focus()}function exRefresh(a){$("#clchat_text").empty();$("#clchat_text").append(a);if($(".newLine").size()){document.getElementById("clchat_chatarea").scrollTop=document.getElementById("clchat_chatarea").scrollHeight;$(".newLine").fadeIn("slow")}}function rqRefresh(){$.ajax({url:"ajaxHandler.php?cmd=rqRefresh&cidReq="+cidReq+getGidReqParam(),ifModified:true,success:function(a){exRefresh(a)},dataType:"html"})}function exRefreshUserList(a){$("#clchat_user_list").empty();$("#clchat_user_list").append(a)}function rqRefreshUserList(){$.ajax({url:"ajaxHandler.php?cmd=rqRefreshUserList&cidReq="+cidReq+getGidReqParam(),ifModified:true,success:function(a){exRefreshUserList(a)},dataType:"html"})}function switchDisplayLog(){if(!logDisplayed){rqDisplayLogs();logDisplayed=true}else{exHideLogs();logDisplayed=false}}function exDisplayLogs(a){$("#clchat_log").hide();$("#clchat_log").empty();$("#clchat_log").append(a);$("#clchat_log").show()}function rqDisplayLogs(){$.ajax({url:"ajaxHandler.php?cmd=rqLogs&cidReq="+cidReq+getGidReqParam(),success:function(a){exDisplayLogs(a)},dataType:"html"});return false}function exHideLogs(){$("#clchat_log").hide();$("#clchat_log").empty()}function showDialog(a){clearTimeout(msgTimeout);$("#clchat_dialogBox").empty();$("#clchat_dialogBox").append(a);$("#clchat_dialogBox").show("slow");msgTimeout=setTimeout(hideDialog,refreshRate)}function hideDialog(){$("#clchat_dialogBox").hide("slow")}function addMsg(){if($("#clchat_msg").val().length>0){$.ajax({url:"ajaxHandler.php?cmd=rqAdd&cidReq="+cidReq+getGidReqParam(),data:$("#clchat_msg").serialize(),success:function(a){exRefresh(a);$("#clchat_msg").val("");$("#clchat_msg").focus()},dataType:"html"});return false}else{return false}}function rqArchive(){$.ajax({url:"ajaxHandler.php?cmd=rqArchive&cidReq="+cidReq+getGidReqParam(),success:function(a){showDialog(a)},dataType:"html"});return false}function rqFlush(){if(confirm(lang.confirmFlush)){$.ajax({url:"ajaxHandler.php?cmd=rqFlush&cidReq="+cidReq+getGidReqParam(),success:function(a){showDialog(a);exHideLogs();rqRefresh()},dataType:"html"})}return false}function getGidReqParam(){if(typeof gidReq!="undefined"){return"&gidReq="+gidReq}else{return""}};