function getCookieUUID() {
			var ocCookies = document.cookie.split( ';' );
			var tempCookie = "";
			var tempCookie2 = "";
			var tempCookie3 = "";
			var uuid = "";
			for(i=0; i < ocCookies.length; i++) {
				tempCookie = ocCookies[i].split('=');
				cookie_name = tempCookie[0].replace(/^\s+|\s+$/g, '');
				
				if(cookie_name == "at") {
					var atcookie = tempCookie[1];
					tempCookie2 = atcookie.split("%26");
					for(j=0; j < tempCookie2.length; j++) {
						tempCookie3 = tempCookie2[j].split("%3D");
						if(tempCookie3[0] == "u") {
							uuid = tempCookie3[1];
						}
					}
				}
			}
			return uuid;
			
		}

var showRecommendedOnly = false;
		var orderby = 'TimeStampDescending';
		var oncommentsPage = 1;
		function pullComments(orderby, showRecommendedOnly, oncommentsPage) {
			var showreconlylink = document.getElementById('showreconly'); 
			if(showreconlylink) {
				if(showRecommendedOnly) {
					showreconlylink.innerHTML = "Show All Comments";
				}
				else {
					showreconlylink.innerHTML = "Show Recommended Comments Only";
				}
			}
			
			var requestBatch = new RequestBatch();  
			var articleKey = new ArticleKey(count[0]);  
			var commentPage = new CommentPage(articleKey, 10, oncommentsPage, orderby);          
			requestBatch.AddToRequest(commentPage);   
			requestBatch.BeginRequest(serverUrl, renderCommentPage); 
		}
		
		function renderCommentPage(responseBatch) { 
			if (responseBatch.Responses.length == 0) {  
				alert('Article Not Found.');  
			} else {  
				var commentBlock = document.getElementById('slrenderedComments'); 
				var commentBlockHtml = "<div id='Comments_OuterContainer' class='Comments_Container'><table class='Comments_Table' cellspacing='0' cellpadding='0'>";  
				var commentPage = responseBatch.Responses[0].CommentPage;  
				var total_comments = commentPage.NumberOfComments;
				var uuid = getCookieUUID();
				for(var i=0; i < commentPage.Comments.length; i++) {  
					if((showRecommendedOnly && commentPage.Comments[i].NumberOfRecommendations > 0) || !showRecommendedOnly) {
						if((commentPage.Comments[i].Author.IsBlocked == "False" && commentPage.Comments[i].AbuseReportCount < 4) || (commentPage.Comments[i].Author.IsBlocked == "True" && commentPage.Comments[i].Author.UserKey.Key == uuid)) {
							commentBlockHtml += getCommentHtml(commentPage.Comments[i]);
						}
					}
				}
				commentBlockHtml += "</table><div class='commentPagination'>";
				var numPages = Math.ceil(total_comments / 10);
				
				if(numPages > 1 && oncommentsPage != 1) {
					commentBlockHtml += 	" <a href='javascript:var oncommentsPage = 1;pullComments(orderby, showRecommendedOnly, 1)'>&lt;&lt;First</a> ";
				}
				
				for(var j=1; j <= numPages; j++) {
					if(j == oncommentsPage) {
						commentBlockHtml += " " + j + " ";	
					}
					else {
						commentBlockHtml += " <a href='javascript:var oncommentsPage = " + j + ";pullComments(orderby, showRecommendedOnly, " + j + ")'>" + j + "</a> ";
					}
				}
				
				if(numPages > 1 && oncommentsPage != numPages) {
					commentBlockHtml += 	" <a href='javascript:var oncommentsPage = " + numPages + ";pullComments(orderby, showRecommendedOnly, " + numPages + ")'>Last&gt;&gt;</a> ";
				}
				commentBlockHtml += "</div></div>";
                   
				
				commentBlock.innerHTML = commentBlockHtml;  
			}  
		} 
		
		function getCommentHtml(comment) {
			var html = "";
			html += '<tr class="Comments_TableRowColor"><td class="Comments_UserImage">';
			html += '<a href="/share/profiles?slid=' + comment.Author.UserKey.Key + '&plckUserId=' + comment.Author.UserKey.Key + '">';
			html += '<img src="' + comment.Author.AvatarPhotoUrl + '" border="0"></a>';
			html += '</td><td class="Comments_TableRight"><div class="Comments_From">';
			html += '<a href="/share/profiles?slid=' + comment.Author.UserKey.Key + '&plckUserId=' + comment.Author.UserKey.Key + '">';
			html += comment.Author.DisplayName + '</a> wrote:</div>';
			html += '<div id="CommentBody" class="Comments_CommentText">' + comment.CommentBody + '</div>';
			html += '<div class="Comments_NestedDate">' + comment.PostedAtTime + '</div>';
			html += '<table class="Comments_NestedTable" cellspacing="0" cellpadding="0"><tr>';
			html += '<td class="Comments_NestedRecommend">';
			if(comment.CurrentUserHasRecommended == "True") {
				html += '<div id="recommend:' + comment.CommentKey.Key + '">';
				html += '<div style="display: inline;"><div class="Recommend_Container">';
				
				html += '<span class="SiteLife_Recommended">Recommended (' + comment.NumberOfRecommendations + ')</span></div></div></div>';
			}
			else {
				html += '<div id="recommend:' + comment.CommentKey.Key + '">';
				html += '<a class="SiteLife_Recommend" onclick="return gSiteLife.PostRecommendation(';
				html += "'Comment', '" + comment.CommentKey.Key + "', 'recommend:" + comment.CommentKey.Key + "', document.title);";
				html += '" href="#none">Recommend</a>(' + comment.NumberOfRecommendations + ')</div>';
			}
			html += '</td><td class="Comments_NestedReport">';
			if(comment.CurrentUserHasReportedAbuse == "True") {
				html += '<div id="rpt_' + comment.CommentKey.Key + '"><div style="display: inline;">';
				html += '<span class="SiteLife_Reported">Reported</span></div></div>';
			}
			else {
				html += '<div id="rpt_' + comment.CommentKey.Key + '"><span>';
				html += '<a id="' + comment.CommentKey.Key + '_RptAbuse" class="SiteLife_ReportAbuse" onclick="ShowReportAbuse(event,document.URL,gSiteLife.__baseUrl + \'/AbuseReport/ReportAbuse?plckElementId=rpt_' + comment.CommentKey.Key + '&plckTargetKey=' + comment.CommentKey.Key + '&plckTargetKeyType=Comment\');';
				html += 'return false;" href="#none">Report Abuse</a></span></div>';
			}
			html += '</td></tr></table></td></tr>';
			return html;  
		}  