var forumID;var endDate;var last=new Date();var tm=60;var busy=false;function setAjaxRefresh(f,d){forumID=f;endDate=d;window.setTimeout(query,tm*1000);}document.onmousemove=function(){last=new Date();};function query(){var now=new Date();now.setSeconds(now.getSeconds()-tm);if(now<=last){getNewItems();}window.setTimeout(query,tm*1000);}function getNewItems(){if(busy){return;}busy=true;$.ajax({type:"POST",url:"/forum/ws/service.aspx/GetNewItems",data:"{'forumID':'"+forumID+"', 'endDate':'"+endDate+"'}",dataType:"json",contentType:"application/json; charset=UTF-8",timeout:tm*1000,error:function(request,error,ex){$("#newMessages").html("E' necessario aggiornare manualmente la pagina per ricevere notifica di nuovi messaggi.");$("#newMessages").fadeIn(400);},success:function(msg){showNotification(msg.d);}});}function showNotification(counter){if(counter>0){$("#newMessagesCount").html(counter);$("#newMessages").fadeIn(400);}busy=false;}function setThreadTracking(postID,c){$.ajax({type:"POST",url:"/forum/ws/service.aspx/SetThreadTracking",data:"{'postID':'"+postID+"'}",dataType:"json",contentType:"application/json; charset=UTF-8",timeout:tm*1000,beforeSend:function(){c.attr("disabled",true);},error:function(request,error,ex){},success:function(msg){c.removeAttr("disabled");}});}function hideReadThreads(c){$.ajax({type:"POST",url:"/forum/ws/service.aspx/HideReadThreads",data:"{}",dataType:"json",contentType:"application/json; charset=UTF-8",timeout:tm*1000,beforeSend:function(){c.attr("disabled",true);},error:function(request,error,ex){},success:function(msg){c.removeAttr("disabled");}});}
