').attr('id','c-list'));if(!tpc_c_comment_module_initialized){tpc_c_total_comments=data.meta.totalComments;var _totalComments=$('').attr("class","c-live").html(tpc_c_total_comments+" comments");var _pendingComments=$('').attr("class","c-pending").html(data.meta.pendingComments+" pending");var _optionDescending=$('').attr('id','c-sort-desc').attr('selected','selected').attr('value','desc').html('Newest First');var _optionAscending=$('').attr('id','c-sort-asc').attr('value','asc').html('Oldest First');var _sorter=$('').attr('id','c-sort').append(_optionDescending).append(_optionAscending);_sorter.change(function(){tpc_c_descending=($(this).val()=='desc');tpc_resetCommentModule();tpc_loadArticleCommentModule();});var _rssContainer=$('').attr('id','c-rss').attr('href',tpc_c_rss_url).html(' Follow comments with RSS');$('#c-info-panel').append(_rssContainer).append(_totalComments).append(_pendingComments).append(_sorter);}}else{$('#c-info-panel').append($('').attr('id','c-no-comments').html('There are no comments yet for this story'));$('#c-view').children().remove();}
tpc_c_comment_module_initialized=true;}
function tpc_createCommentHead(item,idx){var _userIdentStr=''+item.name+'';if(item.location!='')_userIdentStr+=' from '+item.location+'';tpc_c_df.d.setTime(item.createDate.time);var _commentDate=tpc_c_df.format('MMM dx, yyyy h:ii a');var _className="c-user-head"+((idx%2==0)?" c-even-head":" c-odd-head");var _domCHead=$('').attr('class',_className).append($('').attr('class','c-user').html(((tpc_c_debug)?''+idx+' ':'')+_userIdentStr)).append($('').attr('class','c-date').html(_commentDate)).append($(' ').attr('clear','all'));return _domCHead;}
function tpc_createCommentBody(item,idx){var _className="c-user-body"+((idx%2==0)?" c-even-body":" c-odd-body");return $('').attr('class',_className).html(item.body);}
function tpc_createLoadMoreCommentsAnchor(){var _floor=tpc_c_last_comment_idx;var _ceiling=(tpc_c_last_comment_idx+tpc_c_increment_len);if(_ceiling>tpc_c_total_comments)
_ceiling=tpc_c_total_comments;var _loadMessage="Click here to load comments "+_floor+"-"+_ceiling+" of "+tpc_c_total_comments;return $('').attr('id','c-load-more-comments').attr('href','javascript:tpc_loadNextCommentSet()').attr('onclick','tpc_loadNextCommentSet()').html(_loadMessage);}
function tpc_resetCommentModule(){$('#c-view').children().remove();$('#c-view').html('
Loading comments...
');}
function tpc_commentShowAd(){var _adTag=$('#jquery-comment-ad-hint').html();if(_adTag=='SHOW_AD'){var _ad=$('').attr('class','c-advertisement-container').html('ADVERTISEMENT ');$('#c-list').append($('').attr('class','c-advertisement-item').append(_ad));}}
function tpc_loadNextCommentSet(){$('#c-load-more-comments').html('');$.getJSON(tpc_c_json_url,function(data){var _count=0;var _floor=tpc_c_last_comment_idx;var _ceiling=tpc_c_last_comment_idx+tpc_c_increment_len;if(_ceiling>tpc_c_total_comments)
_ceiling=tpc_c_total_comments;$.each(data.result,function(i,item){_count++;if(_count>_floor&&_count<=_ceiling){$('#c-list').append($('').attr('id','c-li-'+item.id).append(tpc_createCommentHead(item,_count)).append(tpc_createCommentBody(item,_count)));tpc_c_last_comment_idx=_count;}});$('#c-load-more-comments').remove();if(_ceiling1){var _commentCollection=data.result;if(!tpc_c_descending){if(tpc_c_debug)alert("Reversing array.");_commentCollection.reverse();}
var _count=0;$.each(_commentCollection,function(i,item){_count++;if(i').attr('id','c-li-'+item.id).append(tpc_createCommentHead(item,_count)).append(tpc_createCommentBody(item,_count)));tpc_c_last_comment_idx=_count;}});if(tpc_c_total_comments>tpc_c_increment_len){$('#c-list').append(tpc_createLoadMoreCommentsAnchor());}}});}