jQuery(document).ready(function($){$('form.Activity textarea').setMaxChars(1000);$('ul.Activities a.Delete, ul.Activities a.DeleteComment').popup({confirm:true,followConfirm:false,afterConfirm:function(json,sender){var row=$(sender).parents('li:first');$(row).slideUp('fast',function(){$(row).remove();});}});$('ul.Activities li').livequery(function(){$(this).find('a.Delete').hide();$(this).hover(function(){$(this).find('a.Delete').show();},function(){$(this).find('a.Delete').hide();});});$('a.CommentOption').live('click',function(){var comments=$(this).parents('li.Activity').find('ul.ActivityComments');comments.toggle();comments.find('a.CommentLink').click();return false;});$('a.CommentLink').live('click',function(){var anchor=this;$(anchor).hide();var row=$(anchor).parents('li.CommentForm');var frm=$(row).find('form');frm.show();var textbox=frm.find('textarea');textbox.focus().blur(function(){if(this.value==''){var comments=$(anchor).parents('.Comments');var children=$(comments).children();var rowCount=children.length-1;if(rowCount>0){$(comments).find('.Errors').remove();$(frm).hide();$(anchor).show();}else{$(comments).hide();}}});return false;});$('ul.ActivityComments form input.Button').live('click',function(){var button=this;var frm=$(button).parents('form');var row=$(frm).parents('li.CommentForm');var textbox=$(row).find('textarea');var postValues=frm.serialize()+'&DeliveryType=VIEW&DeliveryMethod=JSON';var activityId=frm.find('[name$=ActivityID]').val();var action=frm.attr('action');$.ajax({type:"POST",url:action,data:postValues,dataType:'json',error:function(XMLHttpRequest,textStatus,errorThrown){$.popup({},XMLHttpRequest.responseText);},success:function(json){json=$.postParseJson(json);$('div.Errors').remove();if(json.FormSaved==false){if(json.StatusMessage!=null&&json.StatusMessage!='')
$(row).prepend(json.StatusMessage);}else{$(row).before(json.Data);textbox.val('').blur();$('ul.ActivityComments li.Hidden').slideDown('fast');}}});return false;});});