
$.namespace('globe.pluck');var pluckGlobalActivity="";function getRecommendCount(articleKey){var requestBatch=new RequestBatch();requestBatch.AddToRequest(articleKey);requestBatch.BeginRequest(serverUrl,renderRecommend);}
function getCommentCount(articleKey){var requestBatch=new RequestBatch();requestBatch.AddToRequest(articleKey);requestBatch.BeginRequest(serverUrl,renderCommentsCount);}
function renderRecommend(responseBatch)
{var currentCount=0;if(responseBatch.Responses.length==0){$(".recommendCount").html(currentCount+" Times");}else{var article=responseBatch.Responses[0].Article;currentCount=article.Recommendations.NumberOfRecommendations;if(currentCount==1)
{$(".recommendCount").html(currentCount+" Time");}else{$(".recommendCount").html(currentCount+" Times");}}}
function renderCommentsCount(responseBatch)
{var currentCount=0;if(responseBatch.Responses.length!=0){var article=responseBatch.Responses[0].Article;currentCount=article.Comments.NumberOfComments;if(currentCount!=0)
{$("#articleCommentCount").text("("+currentCount+")");}}}
function articleRecommend(){var pageUrl="";var pageTitle="";var pgTtlIndex="";var pgTtlIndex2="";var section="";section=globe.conf.uniqueSectionName;pageUrl=document.location.href;pageTitle=document.title;pageTitle=pageTitle.replace(/| The Globe and Mail/,"");pageTitle=pageTitle.replace(/- The Globe and Mail/,"");var requestBatch=new RequestBatch();var recommendAction=new RecommendAction(articleKey);requestBatch.AddToRequest(new UpdateArticleAction(articleKey,pageUrl,pageTitle,new Section(section),null));requestBatch.AddToRequest(recommendAction);requestBatch.BeginRequest(serverUrl,recommendComplete);}
function recommendComplete(responseBatch){if(responseBatch.Messages[0].Message=="ok"){getRecommendCount(articleKey);}}
globe.pluck.articleInfo=function(){var articleKeyArray=new Array();if($(".social-media")){$(".sm-comments").each(function(){articleId=(this.id).split("_")[0];articleKeyArray.push(new ArticleKey(articleId));});var noCalls=Math.ceil(articleKeyArray.length/20);if(noCalls>0){for(var x=0;x<noCalls;x++){start=x*20;end=start+20;if(end>articleKeyArray.length){end=articleKeyArray.length;}
var requestBatch=new RequestBatch();for(var i=start;i<end;i++){if(articleKeyArray[i].ArticleKey.Key!="")
{requestBatch.AddToRequest(articleKeyArray[i]);}}
requestBatch.BeginRequest(serverUrl,globe.pluck.renderInfo);}}}};globe.pluck.renderInfo=function(responseBatch){var linkTextComment="";var linkTextRecommend="";if(responseBatch.Responses.length>0){if(globalPluckLocation=="blog"){linkTextComment=" Comments";linkTextRecommend=" Recommends";}
for(var res=0;res<responseBatch.Responses.length;res++){var articleId=responseBatch.Responses[res].Article.ArticleKey.Key;var numberOfComments=(responseBatch.Responses[res].Article.Comments.NumberOfComments);var numberOfRecommendations=(responseBatch.Responses[res].Article.Recommendations.NumberOfRecommendations);$(".social-media[id^='"+articleId+"']").each(function(){var articleInfoType=(this.id).split("_")[1];if(articleInfoType=="comment"){showValue=numberOfComments+linkTextComment;}else if(articleInfoType=="recommend"){showValue=numberOfRecommendations+linkTextRecommend;}
if(showValue){$("#"+this.id+" .sm-container").html(showValue);}});}}};globe.pluck.getMostDiscussed=function(isArticle){if(typeof isArticle=="undefined"){isArticle=false;}
var sections=new Array(new Section("All"));var categories=new Array(new Category("All"));var contributors=new Array();contributors[0]=new UserTier("Standard");contributors[1]=new UserTier("Trusted");contributors[2]=new UserTier("Featured");contributors[3]=new UserTier("Staff");contributors[4]=new UserTier("Editor");var activity=new Activity("Commented");var age=15;var numItemsToGet=10;var requestBatch=new RequestBatch();var discoveryAction=new DiscoverArticlesAction(sections,categories,contributors,activity,age,numItemsToGet);requestBatch.AddToRequest(discoveryAction);if(isArticle==false){requestBatch.BeginRequest(serverUrl,globe.pluck.renderMostPopularDiscussed);}else{var startHTML=$('#most-commented').html();$('#most-commented').html("<div class=\"div-table\"><div class=\"div-cell first\">Loading content...</div></div>"+startHTML)
requestBatch.BeginRequest(serverUrl,globe.pluck.renderMostPopularArticle);}};globe.pluck.renderMostPopularDiscussed=function(responseBatch){var recentHTML="";var tableCounter=0;if(responseBatch.Responses.length==1){var discoveryAction=responseBatch.Responses[0].DiscoverArticlesAction;for(var i=0;i<discoveryAction.DiscoveredArticles.length;i++){tableCounter=i+1;recentHTML+="<tr><td class=\"mostPopularCount\">"+tableCounter+"</td><td class=\"mostPopularItemData\">"+globe.pluck.getMostPopularDiscussedArticleLink(discoveryAction.DiscoveredArticles[i])+"</td></tr>";}
$('#most-commented').html("<table class=\"mostCommentedList\">"+recentHTML+"</table>");}};globe.pluck.renderMostPopularArticle=function(responseBatch){var recentHTML="";var tableCounter=0;if(responseBatch.Responses.length==1){var discoveryAction=responseBatch.Responses[0].DiscoverArticlesAction;for(var i=0;i<discoveryAction.DiscoveredArticles.length;i++){var linkHTML="";var className="";tableCounter=i+1;if(i==0){className="first";}
linkHTML+="<div class=\"div-cell\">";linkHTML+="<div class=\"number\">"+(i+1)+"</div>";linkHTML+="<div class=\"link\">"+globe.pluck.getMostPopularDiscussedArticleLink(discoveryAction.DiscoveredArticles[i],true)+"</div>";linkHTML+="</div>";if(i%2==0){recentHTML+="<div class=\"div-row "+className+"\">";recentHTML+=linkHTML;if(i==discoveryAction.DiscoveredArticles.length-1){recentHTML+="<div class=\"div-cell\"></div>";recentHTML+="</div>";}}else{recentHTML+=linkHTML;recentHTML+="</div>";}}
$("#most-commented div.div-table").html(recentHTML);}};globe.pluck.getMostPopularDiscussedArticleLink=function(article,isArticle)
{if(typeof isArticle=="undefined"){isArticle=false;}
var html="";var hrefURL="";var pageTitle="";var numberOfComments=article.Comments.NumberOfComments;var numberOfRecommendations=article.Recommendations.NumberOfRecommendations;if(article.PageTitle==null||article.PageTitle=="")
{hrefURL="#";pageTitle="Not Available";}else{hrefURL=article.PageUrl
pageTitle=article.PageTitle}
if(isArticle==false){var html="<h4><a href='"+hrefURL+"'>"+pageTitle+"</a></h4>\n";html+="<span id=\""+article.ArticleKey.Key+"\" class=\"social-media\">"
html+="<a href='"+hrefURL+"' class=\"comments sm-container\" title=\"Read the comments for this story\">"+numberOfComments+"</a>";html+="</span>";}else{var html="<a href=\""+hrefURL+"\" title=\""+pageTitle+"\" class=\"grey-chevron\">"+pageTitle+"</a>";}
return html;};globe.pluck.getMostRecommended=function(){var sections=new Array(new Section("All"));var categories=new Array(new Category("All"));var contributors=new Array();contributors[0]=new UserTier("Standard");contributors[1]=new UserTier("Trusted");contributors[2]=new UserTier("Featured");contributors[3]=new UserTier("Staff");contributors[4]=new UserTier("Editor");var activity=new Activity("Recommended");var age=15;var numItemsToGet=20;var requestBatch=new RequestBatch();var discoveryAction=new DiscoverArticlesAction(sections,categories,contributors,activity,age,numItemsToGet);requestBatch.AddToRequest(discoveryAction);requestBatch.BeginRequest(serverUrl,globe.pluck.renderMostRecommended);};globe.pluck.renderMostRecommended=function(responseBatch){var recentHTML="";var tableCounter=0;var articleIndex="";var articleIdString="";if(responseBatch.Responses.length==1){var discoveryAction=responseBatch.Responses[0].DiscoverArticlesAction;for(var i=0;i<discoveryAction.DiscoveredArticles.length;i++){articleIdString=discoveryAction.DiscoveredArticles[i].ArticleKey.Key;articleIndex=articleIdString.indexOf('CommentArticle');if(articleIndex==-1){tableCounter=tableCounter+1;recentHTML+="<tr><td class=\"mostPopularCount\">"+tableCounter+"</td><td class=\"mostPopularItemData\">"+globe.pluck.getRecommendedArticleLink(discoveryAction.DiscoveredArticles[i])+"</td></tr>";}}
$('#most-recommended').html("<table class=\"mostRecommendedList\">"+recentHTML+"</table>");}};globe.pluck.getRecommendedArticleLink=function(article)
{var html="";var hrefURL="";var pageTitle="";var numberOfComments=article.Comments.NumberOfComments;var numberOfRecommendations=article.Recommendations.NumberOfRecommendations;if(article.PageTitle==null||article.PageTitle=="")
{hrefURL="#";pageTitle="Not Available";}else{hrefURL=article.PageUrl
pageTitle=article.PageTitle}
var html="<h4><a href='"+hrefURL+"'>"+pageTitle+"</a></h4>\n";html+="<span id=\""+article.ArticleKey.Key+"\" class=\"social-media\">"
html+="<a href='"+hrefURL+"' class=\"comments sm-container\" title=\"Read the comments for this story\">"+numberOfComments+"</a>";html+="</span>";html+="<span id=\""+article.ArticleKey.Key+"\" class=\"social-media\">";html+="<a href='"+hrefURL+"' class=\"recommendations sm-container\" title=\"Recommend this article\">"+numberOfRecommendations+"</a>";html+="</span>";return html;};var arrayDissapprovalData=new Array();var globalArea="-ds";var globalCommentKey=null;var globalPluckUserName="";var globalPluckArtPagIn=0;var globalPluckBloPagIn=0;var globalPluckScroll=null;var globalPluckOrder="TimeStampAscending";var globalPluckIteration="";function getLatestComments(){globalPluckLocation="latest";var requestBatch=new RequestBatch();var commentPage=new CommentPage(articleKey,5,1,"TimeStampDescending");requestBatch.AddToRequest(commentPage);requestBatch.BeginRequest(serverUrl,renderLatestCommentPage);}
function renderLatestCommentPage(responseBatch){if(responseBatch.Responses.length==0){globe.pluck.noCommentsMessage('#latest-comments-container',"latest")}else{if(responseBatch.Responses.length==1){if(responseBatch.Responses[0].CommentPage.NumberOfComments=="0"){globe.pluck.noCommentsMessage('#latest-comments-container',"latest");}else{globe.pluck.commentConstructor(responseBatch,'#latest-comments-container',"latest")}}else{globe.pluck.commentConstructor(responseBatch,'#latest-comments-container',"latest")}}}
globe.pluck.getLatestMostRecommendedComments=function(iteration){globalPluckLocation="latest";globalPluckIteration=iteration;var requestBatch=new RequestBatch();var commentPage="";if(iteration=="first"){commentPage=new CommentPage(articleKey,5,1,"RecommendationsDescending");}else{commentPage=new CommentPage(articleKey,5,1,"TimeStampDescending");}
requestBatch.AddToRequest(commentPage);requestBatch.BeginRequest(serverUrl,globe.pluck.renderRecommendedReviews);}
globe.pluck.renderRecommendedReviews=function(responseBatch){console.log(responseBatch);console.log(responseBatch.Responses.length);if(responseBatch.Responses.length==0){globe.pluck.noCommentsMessage('#latest-comments-container',"latest")}else{if(responseBatch.Responses.length==1){if(responseBatch.Responses[0].CommentPage.NumberOfComments=="0"){if(globalPluckIteration=="first"){globe.pluck.getLatestMostRecommendedComments("second")}else{globe.pluck.noCommentsMessage('#latest-comments-container',"latest");}}else{globe.pluck.commentConstructor(responseBatch,'#latest-comments-container',"latest")}}else{globe.pluck.commentConstructor(responseBatch,'#latest-comments-container',"latest")}}}
globe.pluck.getComments=function(page,scrollTo,sortOrder){globalPluckLocation="comments";globalPluckArtPagIn=page;globalPluckScroll=scrollTo;var sortCookie=$.cookie("gam.user.sortOrder");if(sortCookie==""){if(sortOrder==""){globalPluckOrder="TimeStampDescending";$.cookie('gam.user.sortOrder',globalPluckOrder,{expires:9999});}else{$.cookie('gam.user.sortOrder',sortOrder,{expires:9999});globalPluckOrder=sortOrder;}}else{if(sortCookie==sortOrder){globalPluckOrder=sortCookie}else{if(sortOrder==""){globalPluckOrder=sortCookie}else{$.cookie('gam.user.sortOrder',sortOrder,{expires:9999});globalPluckOrder=sortOrder;}}}
$("div#comment-sort-order").show()
$("div#comments h4.commentsTabHeader").show();var requestBatch=new RequestBatch();var commentPage=new CommentPage(articleKey,10,page,globalPluckOrder);requestBatch.AddToRequest(commentPage);requestBatch.BeginRequest(serverUrl,globe.pluck.renderCommentPage);}
globe.pluck.renderCommentPage=function(responseBatch){if(responseBatch.Responses.length==0){globe.pluck.noCommentsMessage('#comment-container',"comments");}else{if(responseBatch.Responses.length==1){if(responseBatch.Responses[0].CommentPage.NumberOfComments=="0"){globe.pluck.noCommentsMessage('#comment-container',"comments");}else{$("div#commentSortedByHeader").show();globe.pluck.commentConstructor(responseBatch,'#comment-container',"comments")}}else{$("div#commentSortedByHeader").show();globe.pluck.commentConstructor(responseBatch,'#comment-container',"comments")}}}
globe.pluck.getBlogComments=function(page,scrollTo){globalPluckLocation="blog";globalPluckBloPagIn=page;var requestBatch=new RequestBatch();var commentPage=new CommentPage(articleKey,10,page,"TimeStampAscending");requestBatch.AddToRequest(commentPage);requestBatch.BeginRequest(serverUrl,globe.pluck.renderBlogComments);}
globe.pluck.renderBlogComments=function(responseBatch){if(responseBatch.Responses.length==0){globe.pluck.noCommentsMessage('#latest-blog-comments-content',"blog");}else{if(responseBatch.Responses.length==1){if(responseBatch.Responses[0].CommentPage.NumberOfComments=="0"){globe.pluck.noCommentsMessage('#latest-blog-comments-content',"blog");}else{globe.pluck.commentConstructor(responseBatch,'#latest-blog-comments-content',"blog")}}else{globe.pluck.commentConstructor(responseBatch,'#latest-blog-comments-content',"blog")}}}
globe.pluck.closedComments=function(text,className){if(!className){className="comments-disabled";}
var closedHtml="";closedHtml="<div id=\"noCommentMessage\" class='"+className+"'>";closedHtml+="<h1>Comments have been disabled</h1>";closedHtml+="Editor's Note: "+text+"</span>";closedHtml+="</div>";return closedHtml;}
globe.pluck.commentConstructor=function(responseBatch,commentDiv,location){var commentBlockHtml="";var commentFormHtml="";var commentPage=responseBatch.Responses[0].CommentPage;var totalCommentPages=Math.ceil(commentPage.NumberOfComments/10);var currentPaginPage=commentPage.OnPage
var paginationHtml="";var pluckCookieId="";var regMessage="";var divUsrProCon="";var divLogOutCon="";var scroll="scrollBottom"
var guideLines="<h1>Join the conversation.</h1>Editor's Note: Comments that appear on the site are not the opinion of The Globe and Mail, but only of the comment writer. Personal attacks, offensive language and unsubstantiated allegations are not allowed. For more information on our commenting policies, please see our <a href=\"http://www.theglobeandmail.com/community/community-guidelines/article1340680/\">Community Guidelines</a> page, or read our full <a href=\"http://v1.theglobeandmail.com/help/termsandconditions/\">Terms and Conditions</a>";pluckCookieId=globe.pluck.getHdCookie();if(pluckCookieId!=""){globe.pluck.getUserName(pluckCookieId);regMessage="You are logged in as: ";divUsrProCon="<a href=\""+globe.conf.publicationUrl+"community/\" rel='profile' >Edit Profile</a>";divLogOutCon="<a href='"+globe.conf.publicationUrl+"logout/\' rel='logout'>Log out</a>";}else{regMessage="You are currently not logged in";divUsrProCon="<a href='"+globe.usrm.loginUrl()+"' rel=''>Login</a>";divLogOutCon="<a href='"+globe.usrm.registerUrl()+"'>Register</a>";}
if(totalCommentPages>1)
{paginationHtml=globe.pluck.commentPagination(currentPaginPage,totalCommentPages,location);}
for(var i=0;i<commentPage.Comments.length;i++){commentBlockHtml+=getCommentHtml(commentPage.Comments[i],location,i);arrayDissapprovalData[i]=commentPage.Comments[i];}
if(pluckCookieId!=""){globe.pluck.getUserName(pluckCookieId);}
if(location=="latest")
{if($(commentDiv).hasClass("disabled-comments")){commentFormHtml=globe.pluck.closedComments(pluckCommentCloseReason);$(commentDiv).html("<table id=\"pluckCommentsTable\">"+commentBlockHtml+"</table>"+commentFormHtml);}else{if(globe.conf.uniqueSectionName=='carprofile'){$(commentDiv).html("<table id=\"pluckCommentsTable\">"+commentBlockHtml+"</table><br/><img id=\"joinComments\" src=\""+globe.conf.mediaUrl+"/images/pluck/join-the-reviews.png\" title=\"View all reviews and join the conversation\" onclick=\"joinComment(); s.events='event8';s.tl(this,'o','Comment');\"/>");}else{$(commentDiv).html("<table id=\"pluckCommentsTable\">"+commentBlockHtml+"</table><br/><img id=\"joinComments\" src=\""+globe.conf.mediaUrl+"/images/pluck/join-the-conversation.png\" title=\"Join the conversation\" onclick=\"joinComment(); s.events='event8';s.tl(this,'o','Comment');\"/>");}}}else{if($(commentDiv).hasClass("disabled-comments")){commentFormHtml=globe.pluck.closedComments(pluckCommentCloseReason);}else{if(pluckCookieId!=""){commentFormHtml+="\t<form class=\"comments\">\n";commentFormHtml+="   \t<div class=\"comments-input-container\">\n";commentFormHtml+="       \t<div class=\"user-info\">\n";commentFormHtml+="           \t<div class=\"user-name\">"+regMessage+"<br/><span>"+globalPluckUserName+"</span></div>\n";commentFormHtml+="           \t<div class=\"user-profile\">"+divUsrProCon+"</div>\n";commentFormHtml+="           \t<div class=\"log-out\">"+divLogOutCon+"</div>\n";commentFormHtml+="       \t</div>\n";commentFormHtml+="       \t<div class=\"comments-input-info\">\n";commentFormHtml+="           \t<div class=\"chars-remaining\">Characters remaining: <div class=\"num-of-chars\">2000</div></div>\n";commentFormHtml+="           \t<textarea id=\"commentInputBody\" class=\"postComment\" rows=\"5\" cols=\"55\" maxlength=\"2000\" onkeyup=\"globe.pluck.characterCount()\"></textarea><br/>\n";commentFormHtml+="            \t<div class=\"comment-messages-container\">\n"
commentFormHtml+="                 \t<div id=\"commentUserMessage\" class=\"comment-sys-messages\"></div>\n";commentFormHtml+="            \t</div>\n";if(globe.conf.uniqueSectionName=='carprofile'){commentFormHtml+="            \t<img class=\"postComment userconversion-link\" src=\""+globe.conf.mediaUrl+"/images/pluck/post-review.png\" title=\"Post a comment\" onclick=\"postComment(articleKey); s.events='event8';s.tl(this,'o','Comment');\"/>\n";}else{commentFormHtml+="            \t<img class=\"postComment userconversion-link\" src=\""+globe.conf.mediaUrl+"/images/pluck/postComment.png\" title=\"Post a comment\" onclick=\"postComment(articleKey); s.events='event8';s.tl(this,'o','Comment');\"/>\n";}
commentFormHtml+="        \t</div>\n";commentFormHtml+="\t</form>\n";}else{commentFormHtml+="\t<br\>\n";commentFormHtml+="\t<div class=\"comments-log-reg-links\">\n";commentFormHtml+="       \t<div class=\"comment-spacer\">&nbsp</div>\n";commentFormHtml+="       \t<div class=\"user-info\">\n";commentFormHtml+="           \t<div class=\"user-name\">"+regMessage+"<br/><span>"+globalPluckUserName+"</span></div>\n";commentFormHtml+="           \t<div class=\"user-profile\">"+divUsrProCon+"</div>\n";commentFormHtml+="           \t<div class=\"log-out\">"+divLogOutCon+"</div>\n";commentFormHtml+="       \t</div>\n";commentFormHtml+="       \t<div class=\"comments-input-info\">\n";if(globe.conf.uniqueSectionName=='carprofile'){commentFormHtml+="            \t<h1>You must be logged in to submit a review.</h1>\n";}else{commentFormHtml+="            \t<h1>You must be logged in to submit a comment.</h1>\n";}
commentFormHtml+="       \t</div>\n";commentFormHtml+="\t</div>\n";}}
if(commentDiv=="#latest-blog-comments-content"){$(commentDiv).html("<div id=\"allComments\"><table cellspacing=\"0\" cellpadding=\"0\" id='commentsTable'>"+commentBlockHtml+"</table>\n<div id=\"commentPagination\">"+paginationHtml+"</div>\n</div>\n");$("#latest-blog-comment-input").html("<div id=\"guideLines-container\">\n<div id=\"guideLines\">"+guideLines+"</div>\n</div>\n<div id=\"newComments\">"+commentFormHtml+"</div>");}else{$(commentDiv).html("<div id=\"allComments\"><table cellspacing=\"0\" cellpadding=\"0\" id='commentsTable'>"+commentBlockHtml+"</table>\n<div id=\"commentPagination\">"+paginationHtml+"</div>\n</div>\n"+"<div id=\"guideLines-container\">\n<div id=\"guideLines\">"+guideLines+"</div>\n</div>\n<div id=\"newComments\">"+commentFormHtml+"</div>");}}
if(globalPluckScroll!=null){globe.pluck.scrollToPost(globalPluckScroll);}
globe.pluck.getDissapprovalCount();}
function getCommentHtml(comment,tab,n){var currentCommentBody="";var html="";var userKey="";var displayName="";var disNameLen=0;var tmpDisName="";var tmp2DisName="";var avatarImage="";if(comment.AbuseReportCount>="3"){currentCommentBody="Moderator's Note: "+comment.Author.DisplayName+"'s "+"comment is currently under review.";}else{currentCommentBody=comment.CommentBody}
displayName=comment.Author.DisplayName
disNameLen=displayName.length
if(displayName.length>10){if(displayName.indexOf(" ")==-1){tmpDisName=displayName.substr(0,11)
tmp2DisName=displayName.substr(11,disNameLen);displayName=tmpDisName+"&#8203;"+tmp2DisName;}}
userKey=comment.Author.UserKey.Key;if(comment.Author.UserTier=="Editor"){avatarImage="\t<img id=\"comment-avatar\" src='"+globe.conf.mediaUrl+"/images/pluck/editor-avatar.png'/>\n";}else{avatarImage="\t<img id=\"comment-avatar\" src='"+globe.conf.mediaUrl+"/images/pluck/default-avatar.png'/>\n";}
if(comment.Author.IsBlocked!="True")
{html+="    <tr class=\"commentSpacer\"><td class=\"commentSpacerInside\" colspan=\"3\"><div class=\"commentSpacerBorder\">&nbsp</div></td></tr>"
html+=" <tr>\n";html+="  <td id='commentUser'>\n";html+="   "+avatarImage;html+="           \t<div id=\"comment-username\">\n";html+="            \t<a id=\"commnet-persona-link\" href=\""+globe.conf.publicationUrl+"community/?userid="+userKey+"&plckUserId="+userKey+"\">"+displayName+"</a></div>\n";html+="  </td>\n";html+="  <td id='commentDivider'>\n";html+="        &nbsp;";html+="  </td>\n";html+="  <td id='commentBody'>\n";html+="   \t<div class='commentTimeStamp'>";html+="       \t"+comment.PostedAtTime+"<a id=\"pluck-comment-index-"+n+"\" name=\""+comment.CommentKey.Key+"\"></a>\n";html+="   \t</div>\n";html+="   \t<div class='commentText'>";html+="       \t"+currentCommentBody+"\n";html+="   \t</div>\n";html+="   \t<div class='commentActions'>\n";html+="       \t<div class='commentRecDis'>\n";html+="          \t<a href=\"javascript:;\" onclick=\"globe.pluck.commentRecommend('"+comment.CommentKey.Key+"')\" class=\"pluckCommentRecommendIcon\" ><img border=\"0\" class='recommendImages' src='"+globe.conf.mediaUrl+"/images/pluck/recommendUp.png'   title='Recommend This Comment'></a><div class='commentRecommendCount'>"+comment.NumberOfRecommendations+"  </div>\n";html+="           \t<a href=\"javascript:;\" onclick=\"globe.pluck.commentDissapproval('"+comment.CommentKey.Key+"')\" ><img border=\"0\" class='recommendImages' src='"+globe.conf.mediaUrl+"/images/pluck/recommendDown.png' title='Disapprove This Comment'></a><div id='CommentArticle:"+comment.CommentKey.Key+""+"-"+globalPluckLocation+globalArea+"' class='commentRecommendCount'>0  </div>\n";html+="       \t</div>";html+="       \t<div class='commentReportAbuse'>\n";html+="             \t<a href=\"javascript:;\" onclick=\"globe.pluck.commentAbuseShow(event,'"+comment.CommentKey.Key+"');\" class=\"pluckReportAbuse\">Report Abuse</a>\n";html+="       \t</div>";html+="   \t</div>\n";html+="  </td>\n";html+=" </tr>\n";}
return html;}
globe.pluck.noCommentsMessage=function(div,location){var messageHtml="";var formHtml="";var userName="";var pluckCookieId="";var regMessage="";var divUsrProCon="";var divLogOutCon="";$("div#comments h4.commentsTabHeader").hide();$("div#commentSortedByHeader").hide();$("div#comment-sort-order").hide();pluckCookieId=globe.pluck.getHdCookie();if(pluckCookieId!=""){globe.pluck.getUserName(pluckCookieId);regMessage="You are logged in as: ";divUsrProCon="<a href=\""+globe.conf.publicationUrl+"community/\" rel='profile' >Edit Profile</a>";divLogOutCon="<a href='"+globe.conf.publicationUrl+"logout/\' rel='logout'>Log out</a>";}else{regMessage="You are currently not logged in";divUsrProCon="<a href='"+globe.usrm.loginUrl()+"' rel=''>Login</a>";divLogOutCon="<a href='"+globe.usrm.registerUrl()+"'>Register</a>";}
messageHtml=messageHtml+"<div id=\"noCommentMessage\">";if(globe.conf.uniqueSectionName=='carprofile'){messageHtml=messageHtml+"<h1>Write your own  car review.</h1>";}else{messageHtml=messageHtml+"<h1>Start the conversation.</h1>";}
messageHtml=messageHtml+"Editor's Note: Comments that appear on the site are not the opinion of The Globe and Mail, but only of the comment writer. Personal attacks, offensive language and unsubstantiated allegations are not allowed. For more information on our commenting policies, please see our <a href=\"http://www.theglobeandmail.com/community/community-guidelines/article1340680/\">Community Guidelines</a> page, or read our full <a href=\"http://v1.theglobeandmail.com/help/termsandconditions/\">Terms and Conditions</a>";messageHtml=messageHtml+"</div>";if($(div).hasClass("disabled-comments")){messageHtml=globe.pluck.closedComments(pluckCommentCloseReason,'zero-comments');}
if(location=="latest"){messageHtml=messageHtml;if(!$(div).hasClass("disabled-comments")){if(globe.conf.uniqueSectionName=='carprofile'){messageHtml+="<br/><img id=\"joinComments\" src=\""+globe.conf.mediaUrl+"/images/pluck/write-review.png\" title=\"Write a review\" onclick=\"joinComment(); s.events='event8';s.tl(this,'o','Comment');\"/>";}else{messageHtml+="<br/><img id=\"joinComments\" src=\""+globe.conf.mediaUrl+"/images/pluck/start-the-conversation.png\" title=\"Start the conversation\" onclick=\"joinComment(); s.events='event8';s.tl(this,'o','Comment');\"/>";}}
$(div).html(messageHtml);}else{if(pluckCookieId!=""){formHtml+="\t<br\>\n";formHtml+="\t<form class=\"comments\">\n";formHtml+="   \t<div class=\"comments-input-container\">\n";formHtml+="       \t<div class=\"user-info\">\n";formHtml+="           \t<div class=\"user-name\">"+regMessage+"<br/><span>"+globalPluckUserName+"</span></div>\n";formHtml+="           \t<div class=\"user-profile\">"+divUsrProCon+"</div>\n";formHtml+="           \t<div class=\"log-out\">"+divLogOutCon+"</div>\n";formHtml+="       \t</div>\n";formHtml+="       \t<div class=\"comments-input-info\">\n";formHtml+="           \t<div class=\"chars-remaining\">Characters remaining: <div class=\"num-of-chars\">2000</div></div>\n";formHtml+="           \t<textarea id=\"commentInputBody\" class=\"postComment\" rows=\"5\" cols=\"55\" maxlength=\"2000\" onkeyup=\"globe.pluck.characterCount()\"></textarea><br/>\n";formHtml+="            \t<div class=\"comment-messages-container\">\n"
formHtml+="                 \t<div id=\"commentUserMessage\" class=\"comment-sys-messages\"></div>\n";formHtml+="            \t</div>\n";if(globe.conf.uniqueSectionName=='carprofile'){formHtml+="            \t<img class=\"postComment userconversion-link\" src=\""+globe.conf.mediaUrl+"/images/pluck/postComment.png\" title=\"Post your car review\" onclick=\"postComment(articleKey); s.events='event8';s.tl(this,'o','Comment');\"/>\n";}else{formHtml+="            \t<img class=\"postComment userconversion-link\" src=\""+globe.conf.mediaUrl+"/images/pluck/postComment.png\" title=\"Post a Comments\" onclick=\"postComment(articleKey); s.events='event8';s.tl(this,'o','Comment');\"/>\n";}
formHtml+="        \t</div>\n";formHtml+="\t</form>\n";}else{formHtml+="\t<br\>\n";formHtml+="\t<div class=\"comments-log-reg-links\">\n";formHtml+="       \t<div class=\"comment-spacer\">&nbsp</div>\n";formHtml+="       \t<div class=\"user-info\">\n";formHtml+="           \t<div class=\"user-name\">"+regMessage+"<br/><span>"+globalPluckUserName+"</span></div>\n";formHtml+="           \t<div class=\"user-profile\">"+divUsrProCon+"</div>\n";formHtml+="           \t<div class=\"log-out\">"+divLogOutCon+"</div>\n";formHtml+="       \t</div>\n";formHtml+="       \t<div class=\"comments-input-info\">\n";if(globe.conf.uniqueSectionName=='carprofile'){formHtml+="            \t<h1>You must be logged in to submit a review.</h1>\n";}else{formHtml+="            \t<h1>You must be logged in to submit a comment.</h1>\n";}
formHtml+="       \t</div>\n";formHtml+="\t</div>\n";}
if(!$(div).hasClass("disabled-comments")){if(div=="#latest-blog-comments-content"){$(div).html(messageHtml+"\n");$("#latest-blog-comment-input").html("<div id=\"newComments\">"+formHtml+"</div>");}else{$(div).html(messageHtml+formHtml);}}else{$(div).html(messageHtml);}}}
globe.pluck.getHdCookie=function(){var pluckCookie=$.cookie("hd");var stringIndex=0;var pluckCookieUsrId="";if(pluckCookie!=null){stringIndex=pluckCookie.indexOf("|",0);pluckCookieUsrId=pluckCookie.substring(0,stringIndex);}
return pluckCookieUsrId;};globe.pluck.getUserName=function(pluckId){var requestBatch=new RequestBatch();var user=new UserKey(pluckId);requestBatch.AddToRequest(user)
requestBatch.BeginRequest(serverUrl,globe.pluck.returnUserName);}
globe.pluck.returnUserName=function(responseBatch){var user="";if(responseBatch.Responses.length!=0){user=responseBatch.Responses[0].User;globalPluckUserName=user.DisplayName;$("div.user-name span").html(globalPluckUserName)}}
globe.pluck.commentDissapproval=function(id){var requestBatch=new RequestBatch();var shadowArticleKey=new ArticleKey("CommentArticle:"+id);requestBatch.AddToRequest(new UpdateArticleAction(shadowArticleKey,'','',null,null));requestBatch.AddToRequest(new RecommendAction(shadowArticleKey,1));requestBatch.AddToRequest(shadowArticleKey);requestBatch.BeginRequest(serverUrl,globe.pluck.dissapprovalComplete);}
globe.pluck.dissapprovalComplete=function(responseBatch){if(responseBatch.Messages[0].Message=='ok'){if(globalPluckLocation=="comments"){globe.pluck.getComments(globalPluckArtPagIn,null,globalPluckOrder)}else if(globalPluckLocation=="blog"){globe.pluck.getBlogComments(globalPluckBloPagIn)}else{getLatestComments()}}else{alert("You have already vote against this comment.");}}
globe.pluck.getDissapprovalCount=function(){var articleKeyX="";var requestBatch=new RequestBatch();for(var k=0;k<arrayDissapprovalData.length;k++)
{articleKeyX=new ArticleKey("CommentArticle:"+arrayDissapprovalData[k].CommentKey.Key);requestBatch.AddToRequest(articleKeyX);}
requestBatch.BeginRequest(serverUrl,globe.pluck.renderDissapprovalCount);}
globe.pluck.renderDissapprovalCount=function(responseBatch){if(responseBatch.Responses.length!=0){var article="";var disCountNum=0;var id="";for(var index=0;index<responseBatch.Responses.length;index++){article=responseBatch.Responses[index].Article;disCountNum=article.Recommendations.NumberOfRecommendations;id=article.ArticleKey.Key
if(globalArea!=""){id=id+"-"+globalPluckLocation+globalArea;}
document.getElementById(id).innerHTML=article.Recommendations.NumberOfRecommendations;}
arrayDissapprovalData=new Array();}}
globe.pluck.commentAbuseShow=function(evt,key){if($('#pluck-reportAbuse').hasClass('sent')){$('#pluck-reportAbuse').removeClass('sent');$('#pluck-reportAbuse h4').text('Alert us to this comment');$('#pluck-reportAbuse p:first').text('Please let us know if this reader\'s comment breaks the editor\'s rules and is obscene, abusive, threatening, unlawful, harassing, defamatory, profane or racially offensive by selecting the appropriate option to describe the problem.');$('#pluck-reportAbuse form').show();}
var tempX=0;var tempY=0;var height=$('#pluck-reportAbuse').height();var width=$('#pluck-reportAbuse').width();globalCommentKey=key;if($.browser.msie){evt.pageX=evt.clientX+document.documentElement.scrollLeft-(width/2)+"px"
evt.pageY=evt.clientY+document.documentElement.scrollTop-(height/2)+"px"
tempX=evt.pageX
tempY=evt.pageY}else{tempX=evt.pageX-(width/2)+"px"
tempY=evt.pageY-(height/2)+"px"}
$("#pluck-reportAbuse").css({left:tempX,top:tempY})
$("#pluck-reportAbuse").fadeToggle();}
globe.pluck.commentAbuseClose=function(){$("#pluck-reportAbuse").fadeToggle();}
globe.pluck.commentReportAbuse=function(){var reason=$("input[@name='alertReason']:checked").val();var description="";if(reason=="other"){description=$("input#otherReason").val();}
var requestBatch=new RequestBatch();var commentKey=new CommentKey(globalCommentKey);var abuseReport=new ReportAbuseAction(commentKey,reason,description);requestBatch.AddToRequest(abuseReport);requestBatch.BeginRequest(serverUrl,globe.pluck.abuseResported);}
globe.pluck.abuseResported=function(responseBatch){if(responseBatch.Messages[0].Message=='ok'){$('#pluck-reportAbuse').addClass('sent');$('#pluck-reportAbuse form').hide();$('#pluck-reportAbuse h4').text('Your alert has been received');$('#pluck-reportAbuse p:first').text('Our editorial staff has been notified about this comment.');}}
globe.pluck.commentPagination=function(currentPage,totalPages,location){var prev=0;var next=0;var prevLink="";var nextLink="";var itemLink="";var paginationHtml="";var linkLimite=10;var startValue=0;var endValue=0;var checkValue=0;var k=0;var linkBase="";var firstPageLink=null;var lastPageLink=null;prev=currentPage-1;if(prev<=0){prev=1}
next=(currentPage*1)+1;if(next>totalPages){next=totalPages}
if(location=="blog"){linkBase="javascript:globe.pluck.getBlogComments";clickEvent="";}else{linkBase="javascript:globe.pluck.getComments";clickEvent="onclick=\"showCommentsTop()\"";}
prevLink="<a href=\""+linkBase+"("+prev+", null, '"+globalPluckOrder+"')\" "+clickEvent+"><img border=\"0\" src='"+globe.conf.mediaUrl+"/images/pluck/prev-button.png' title='Previous'></a> ";nextLink="<a href=\""+linkBase+"("+next+", null, '"+globalPluckOrder+"')\" "+clickEvent+"><img border=\"0\" src='"+globe.conf.mediaUrl+"/images/pluck/next-button.png' title='Next'></a>";firstPageLink="<a href=\""+linkBase+"(1, null, '"+globalPluckOrder+"')\" "+clickEvent+">First </a>"
lastPageLink="<a href=\""+linkBase+"("+totalPages+", null, '"+globalPluckOrder+"')\" "+clickEvent+"> Last</a>"
if(totalPages<10){for(var i=0;i<totalPages;i++){k=1;k=k+i;if(k!=currentPage){itemLink+="<a onclick=\"showCommentsTop()\" href=\""+linkBase+"("+k+", null, '"+globalPluckOrder+"')\">"+k+"</a> ";}else{itemLink+="<a onclick=\"showCommentsTop()\" href=\""+linkBase+"("+k+", null, '"+globalPluckOrder+"')\" class=\"selected\">"+k+"</a> ";}}}else{var actualLinkLimit=(totalPages<10)?totalPages:10;var startValue=currentPage-Math.floor(10/3)-1;if(startValue+actualLinkLimit>totalPages)startValue=totalPages-actualLinkLimit+1;if(startValue<1)startValue=1;for(var linkCount=0;linkCount<actualLinkLimit;linkCount++){var jumpNum=linkCount+startValue;if(jumpNum!=currentPage){itemLink+="<a onclick=\"showCommentsTop()\" href=\""+linkBase+"("+jumpNum+", null, '"+globalPluckOrder+"')\">"+jumpNum+"</a> ";}else{itemLink+="<a onclick=\"showCommentsTop()\" href=\""+linkBase+"("+jumpNum+", null, '"+globalPluckOrder+"')\" class=\"selected\">"+jumpNum+"</a> ";}}}
if(currentPage!=1){paginationHtml+=firstPageLink;paginationHtml+=prevLink;}
paginationHtml+=itemLink;if(currentPage!=totalPages){paginationHtml+=nextLink;paginationHtml+=lastPageLink;}
return paginationHtml;}
globe.pluck.commentRecommend=function(id){var requestBatch=new RequestBatch();requestBatch.AddToRequest(new RecommendAction(new CommentKey(id)));requestBatch.BeginRequest(serverUrl,globe.pluck.recommendationComplete);}
globe.pluck.recommendationComplete=function(responseBatch){if(responseBatch.Messages[0].Message=='ok'){if(globalPluckLocation=="comments"){globe.pluck.getComments(globalPluckArtPagIn,null,globalPluckOrder)}else if(globalPluckLocation=="blog"){globe.pluck.getBlogComments(globalPluckBloPagIn)}else{getLatestComments()}}else{alert(responseBatch.Messages[0].Message);}}
globe.pluck.refresh=function(){window.location.reload(false);}
globe.pluck.scrollToPost=function(scrollTo){var idIndex=0;idIndex=($("table#commentsTable tr").length)-1;var targetOffset=$("a#pluck-comment-index-"+idIndex).offset().top;$('html,body').animate({scrollTop:targetOffset},200);}
globe.pluck.comentsPerPage=function(){}
$("li#newest").click(function(){globe.pluck.getComments(globalPluckArtPagIn,null,"TimeStampDescending")
$("li#newest").removeClass("comment-sort-option")
$("li#oldest").removeClass("sort-option-selected")
$("li#mostUp").removeClass("sort-option-selected")
$("li#mostDown").removeClass("sort-option-selected")
$("li#newest").addClass("sort-option-selected")
$("li#oldest").addClass("comment-sort-option")
$("li#mostUp").addClass("comment-sort-option")
$("li#mostDown").addClass("comment-sort-option")});$("li#oldest").click(function(){globe.pluck.getComments(globalPluckArtPagIn,null,"TimeStampAscending")
$("li#newest").removeClass("sort-option-selected")
$("li#oldest").removeClass("comment-sort-option")
$("li#mostUp").removeClass("sort-option-selected")
$("li#mostDown").removeClass("sort-option-selected")
$("li#newest").addClass("comment-sort-option")
$("li#oldest").addClass("sort-option-selected")
$("li#mostUp").addClass("comment-sort-option")
$("li#mostDown").addClass("comment-sort-option")});$("li#mostUp").click(function(){globe.pluck.getComments(globalPluckArtPagIn,null,"RecommendationsDescending")
$("li#newest").removeClass("sort-option-selected")
$("li#oldest").removeClass("sort-option-selected")
$("li#mostUp").removeClass("comment-sort-option")
$("li#mostDown").removeClass("sort-option-selected")
$("li#newest").addClass("comment-sort-option")
$("li#oldest").addClass("comment-sort-option")
$("li#mostUp").addClass("sort-option-selected")
$("li#mostDown").addClass("comment-sort-option")});$("li#mostDown").click(function(){globe.pluck.getComments(globalPluckArtPagIn,null,"RecommendationsAscending")
$("li#newest").removeClass("sort-option-selected")
$("li#oldest").removeClass("sort-option-selected")
$("li#mostUp").removeClass("sort-option-selected")
$("li#mostDown").removeClass("comment-sort-option")
$("li#newest").addClass("comment-sort-option")
$("li#oldest").addClass("comment-sort-option")
$("li#mostUp").addClass("comment-sort-option")
$("li#mostDown").addClass("sort-option-selected")});globe.pluck.getMostCommented=function(){var sections=new Array(new Section("All"));var categories=new Array(new Category("All"));var contributors=new Array();contributors[0]=new UserTier("Standard");contributors[1]=new UserTier("Trusted");contributors[2]=new UserTier("Featured");contributors[3]=new UserTier("Staff");contributors[4]=new UserTier("Editor");var activity=new Activity("Commented");var age=15;var numItemsToGet=10;var requestBatch=new RequestBatch();var discoveryAction=new DiscoverArticlesAction(sections,categories,contributors,activity,age,numItemsToGet);requestBatch.AddToRequest(discoveryAction);requestBatch.BeginRequest(serverUrl,globe.pluck.renderMostCommented);}
globe.pluck.renderMostCommented=function(responseBatch){if(responseBatch.Responses.length==1){var discoveryAction=responseBatch.Responses[0].DiscoverArticlesAction;var recentHTML="";for(var i=0;i<discoveryAction.DiscoveredArticles.length;i++){tableCounter=i+1;recentHTML+="<tr><td class=\"mostCommentCount\">"+tableCounter+".</td><td class=\"mostCommentItemData\">"+globe.pluck.getArticleLink(discoveryAction.DiscoveredArticles[i])+"</td></tr>"}
$('#most-discussed').html("<table cellspace=\"0\" cellpadding=\"0\" class=\"mostCommentedFragList\">"+recentHTML+"</table>");}}
globe.pluck.getArticleLink=function(article)
{var html="<a href='"+article.PageUrl+"'>"+article.PageTitle+"</a>\n";return html;}
function postComment(articleKey){var section="";var pluckCookie=null;var pageUrl=null;var pageTitle=null;var commentBody="";var maxChar=0;var pgTtlIndex="";var pgTtlIndex2="";var error=false;var checkBody=new RegExp(/<img|<table|<h1|<h2|<h3|<h4|<a|<ol|<ul|<li|<br|<tr|<td|<th|<div|<em|<span|<font/);var checkBody2=new RegExp(/img>|table>|h1>|h2>|h3>|h4>|a>|ol>|ul>|li>|br>|tr>|td>|th>|div>|em>|span>|font>/);pluckCookie=$.cookie("hd");if(pluckCookie!=null){commentBody=$("textarea#commentInputBody").val();maxChar=parseInt($('textarea#commentInputBody').attr('maxlength'))
if(commentBody.length>maxChar){globe.pluck.commentErrorHandler("Large Comment");}else{pageUrl=document.location.href;pageTitle=document.title;pageTitle=pageTitle.replace(/. The Globe and Mail/,"");$("#commentUserMessage").hide();if(commentBody.length!=0){if(checkBody.test(commentBody)){error=true
globe.pluck.commentErrorHandler("html");}
if(checkBody2.test(commentBody)){error=true
globe.pluck.commentErrorHandler("html");}}
commentBody=commentBody.replace(/[\n]/g,"<br/>");var requestBatch=new RequestBatch();var commentAction=new CommentAction(articleKey,pageUrl,pageTitle,commentBody);if(error==false){section=globe.conf.uniqueSectionName;requestBatch.AddToRequest(new UpdateArticleAction(articleKey,pageUrl,pageTitle,new Section(section),null));requestBatch.AddToRequest(commentAction);requestBatch.AddToRequest(new CommentPage(articleKey,1,1,"TimeStampAscending"));requestBatch.BeginRequest(serverUrl,commentSubmitted);}}}else{if($.cookie("OLD_PROFILE")=="Y"){globe.common.register.showConversion();}else{globe.pluck.commentErrorHandler("No pluck cookie")}}}
function commentSubmitted(responseBatch){var responseMessage="";var totalCommentPages=1;if(responseBatch.Messages[0].Message=='ok'){totalCommentPages=Math.ceil(responseBatch.Responses[0].CommentPage.NumberOfComments/10);if(globalPluckLocation=="blog"){globe.pluck.getBlogComments(totalCommentPages);}else{getLatestComments();globe.pluck.getComments(1,"scrollTop","TimeStampDescending");getCommentCount(articleKey);}}else{responseMessage=responseBatch.Messages[0].Message;globe.pluck.commentErrorHandler(responseMessage)}}
globe.pluck.commentErrorHandler=function(error){var messageCheckIndex="";var parsedMessage="";var newMessage="";var filterCheckIndex="";messageCheckIndex=error.indexOf("on request");if(messageCheckIndex!=-1){parsedMessage=error.substring(0,messageCheckIndex-1);}else{parsedMessage=error;}
filterCheckIndex=error.indexOf("CommentActionRequest ");if(filterCheckIndex!=-1){parsedMessage="profanity";}
switch(parsedMessage){case"No pluck cookie":newMessage="Please login to leave a comment.";break;case"Comment submission denied by authentication level: Weak":newMessage="Please login to leave a comment.";break;case"Error validating input: 'CommentBody cannot be blank.'":newMessage="Comments cannot be blank.";break;case"We restrict rapid posting of multiple comments for quality reasons. You have already posted a comment within the last several seconds. Please try again later.":newMessage="You have already posted a comment within the last several seconds. Please try again later.";break;case"Large Comment":newMessage="Your comment must be less than 2000 characters.";break;case"profanity":newMessage="You included words not permitted by our language filter.";break;case"html":newMessage="HTML is not allowed in the comments.";break;default:newMessage="An unexpected error occurred please try again.";}
$("#commentUserMessage").show().html(newMessage);}
globe.pluck.characterCount=function(){var max=parseInt($('textarea#commentInputBody').attr('maxlength'));if($('textarea#commentInputBody').val().length>max){$('textarea#commentInputBody').val($('textarea#commentInputBody').val().substr(0,$('textarea#commentInputBody').attr('maxlength')));}
$('.num-of-chars').html(max-$('textarea#commentInputBody').val().length);}
