
function trim(str,chars){return ltrim(rtrim(str,chars),chars);}
function ltrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function rtrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}
function submitComment(){if(document.commentSubmitProcessing)
return false;txt=trim(document.getElementById('comment-text-holder').value);if(txt.length<1){throwCommentError('trim');return;}
var ajaxanator=marvel_loader.init('onesite_user/os_process_comment');ajaxanator.request={params:[document.com_contentId,document.com_contentType,document.com_userID,txt,document.get_params,document.com_obj,document.com_os_user_state],expire:0,mode:'json'};ajaxanator.callback=refreshComment;document.commentSubmitProcessing=true;ajaxanator.energize();}
function flagComment(cID){var ajaxanator=marvel_loader.init('onesite_user/os_flag_user_content');ajaxanator.request={params:['discussion_post',cID],expire:0,mode:'json'};ajaxanator.callback=function(){var msg;if(this.result=='success'){msg='Thank you. Your flag has been submitted and will be reviewed by an administrator shortly.';}else if(this.result=='user_flagged_recently'){msg='Thank you, for helping us keep these discussions clean of foul language.\nPlease come back in a few minutes and try marking this one again.';}else
msg='Error occurred! Unable to delete at this time';alert(msg);}
ajaxanator.energize();}
function deleteComment(cID,uID){var ajaxanator=marvel_loader.init('onesite_user/os_delete_comment');ajaxanator.request={params:[cID,uID],expire:0,mode:'json'};ajaxanator.callback=function(){if(this.result=='success'){hide('comment-'+cID);clearCachedComments();}else
alert('Error occurred! Unable to delete at this time');}
ajaxanator.energize();}
function clearCachedComments(){var ml=marvel_loader.init('onesite_user/clear_cached_comments');ml.request={params:[document.com_contentId,document.com_contentType,document.get_params,document.com_obj,document.com_os_user_state],expire:0,mode:'json'}
ml.energize();}
function showCommentBox(){}
function throwCommentError(error){}
function goToPage(num){newpage=new String(num);document.get_params.page=newpage;loadComment();}
function refreshComment(){switch(this.result){case'success':document.getElementById('comment-text-holder').value='';loadComment();break;case'error':break;}}
function loadComment(){var ajaxanator=marvel_loader.init('onesite_user/os_get_comments_w');ajaxanator.request={params:[document.com_contentId,document.com_contentType,document.get_params,document.com_obj,document.com_os_user_state],expire:0,mode:'htm',src:'utility_boxes/templates/onesite_comments.tmpl.htm'};ajaxanator.callback=function(){document.commentSubmitProcessing=false;};ajaxanator.energize('comments-holder');}
document.commentSubmitProcessing=false;
