if(!Comment){var Comment={}}$(function(){$(window).unload(function(){for(var E in Comment){E=""}Comment=""});function B(E){return parseInt($(E).attr("id").replace(/.+_(.+)/,"$1"))}var A=function(){var E=$(this).closest("form");if($(this).val()||E.is(".focus")){E.children(".commentButtons").show()}else{E.children(".commentButtons").hide()}};Comment.showHideTabCounts=function(){if($("#commentsCountBox > .count").val()=="0"){$("#commentsCountBox").hide()}else{$("#commentsCountBox > .count").show()}};$("#newCommentInput").bind("paste keyup keydown focus blur",function(){$(this).each(A)}).each(A);$("#newCommentInput").autogrow().maxChars(512,"> .buttonBar > span.charcounter > span.chars").prev("label.overlabel").hideLabelOnEnter().end().closest("form").submit(function(){var E=this;return $(this).ajaxPostForm("show",$(E).find("> .buttonBar"),{waitingMessage:"adding...",success:function(G,F){$("<div></div>").html(G).find("> li.comment").hide().appendTo("#commentsList").each(function(){$(this).find("> ul.commentAnswersTier1 > li.overflow").removeClass("overflow");$(this).find("> ul.commentAnswersTier1 > li.showMoreCtr").remove();C(this)}).fadeIn("normal",function(){$(this).highlight()});$("#newCommentInput").val("").each(A).triggerHandler("blur");$("#commentsCountBox > .count").text($("#commentsList li.comment").length).highlight(1000);$("#newCommentForm").removeClass("focus").each(A);$("#formCommentOnReview").hide();Comment.showHideTabCounts()}})});$("#newCommentForm").hover(function(){$(this).addClass("focus")},function(){$(this).removeClass("focus")});$("#comments").listen("click",".cancelNewCommentLink",function(){$(this).closest("form").find("> div.newCommentCtr > textarea").val("").each(A).triggerHandler("blur");if($(this).closest("ul").is(".commentReplies")){$(this).closest("li.commentReplyCtr").hide()}$("#newCommentForm").removeClass("focus").each(A);$("#formCommentOnReview").hide();return false});$("#commentsList").listen("click",".showMoreCommentsLink",function(){$(this).closest("ul").children(".comment.overflow").hide().removeClass("overflow").fadeIn("slow");$(this).closest("li").remove();return false});$("#commentsList").listen("click",".replyLink",function(){if(!this.initedForm){var G=B($(this).closest("li.comment"));var F=$("#commentReplyForm").clone().attr("id","commentReplyForm_"+G);F.wrap("<li class='commentReplyCtr'></li>");var E=$(F).find("> div.newCommentCtr > textarea");E.attr("id","replyToCommentTextarea_"+G);E.prev("label.overlabel").attr("for","replyToCommentTextarea_"+G);F.closest("li").hide().appendTo($(this).closest("li.comment").find("> ul.commentReplies")).fadeIn();F.find("> input.replyToCommentInput").val(G);$(E).autogrow({minHeight:30}).maxChars(512,"> .buttonBar > span.charcounter > span.chars").prev("label.overlabel").hideLabelOnEnter();$(E).bind("paste keyup keydown focus blur",function(){$(this).each(A)}).each(A);$(F).submit(function(){return $(this).ajaxPostForm("show",$(F).find("> .buttonBar > .buttons"),{waitingMessage:"replying...",success:function(J,I){var H=$("<div></div>").html(J).find("> li.comment").hide();H.insertBefore($(I).closest("li"));H.slideDown().highlight(1000);$(I).find("> div.newCommentCtr > textarea").val("").each(A).triggerHandler("blur");$("#commentsCountBox > .count").text($("#commentsList li.comment").length).highlight(1000);C($(I).closest("ul.commentAnswersTier1").parent("li.comment"))}})});this.initedForm=true}$(this).closest("li.comment").find("> ul.commentReplies > li.commentReplyCtr").show().find(">form").show().find("> div.newCommentCtr > textarea").focus();return false}).listen("click",".deleteCommentLink",function(){return $(this).ajaxPostForm("headers",this,{success:function(F,E){$(E).closest("li.comment").slideUp(function(){var G=$(this).closest("ul.commentAnswersTier1").parent("li.comment");$(this).remove();C(G)});$("#commentsCountBox > .count").text($("#commentsList li.comment").length).highlight(1000);Comment.showHideTabCounts()}});return false});var C=function(H){var G=$(H).find(" > div.commentBlock > div.commentText > div.commentOnReview");if(!G.length){return }var E=B(G);if(E){var F=$(H).find(" li.comment").length;var I=$("#review_"+E+"> .reviewContents > .reviewActions > .commentOnReviewLink");I.find("> .count").text(F);I.addClass("hasComments");if(F==0){I.removeClass("hasComments")}if(F>1){$(I).addClass("plural")}}};Comment.updateCommentLinks=function(){var E=0;if(Decision.updateDetails.comments){var G=[];for(var F=0;F<Decision.updateDetails.comments.length;F++){if(!$(Decision.updateDetails.comments[F]).length){G.push(Decision.updateDetails.comments[F])}}Decision.updateDetails.comments=G;E=Decision.updateDetails.comments.length}if(E){$("#refreshCommentsBar > .count").text(E);$("#refreshCommentsBar").slideDown();if(E>1){$("#refreshCommentsBar").addClass("plural")}else{$("#refreshCommentsBar").removeClass("plural")}$("#newCommentsShortcut").show().addClass("show")}else{$("#refreshCommentsBar").removeClass("plural").slideUp();$("#newCommentsShortcut").hide().removeClass("show")}};var D;$("#refreshCommentsLink").click(function(){if(D){return }D=true;var F=this;$(F).replaceWithWaitIcon("refreshing...");var G={respondWithView:"updates"};var E=$.trim($("#commentsUpdatedSince").text());if(E){G.updatedSince=E}$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/comment",data:G,global:false,success:function(J){var H=$("<div/>").html(J);var I=$.trim(H.find("#updatedSince").text());$("#commentsUpdatedSince").text(I);H.find("#commentsList > li").each(function(){var K=$("#comment_"+B(this));if(!K.length){$(this).hide().appendTo("#commentsList").fadeIn("normal",function(){$(this).highlight()})}else{K.hide().appendTo("#commentsList").removeClass("overflow").fadeIn();$(this).find("> ul.commentAnswersTier1 > li.comment").each(function(){var M=$("#comment_"+B(this));var L=$(K).find("> ul.commentAnswersTier1");if(!M.length){if($(L).find("> li.commentReplyCtr").length){$(this).hide().insertBefore($(L).find("> li.commentReplyCtr")).fadeIn("normal",function(){$(this).highlight()})}else{$(this).hide().appendTo(L).fadeIn("normal",function(){$(this).highlight()})}}else{if($(L).find("> li.commentReplyCtr").length){$(M).removeClass("overflow").hide().insertBefore($(L).find("> li.commentReplyCtr")).fadeIn()}else{$(M).removeClass("overflow").hide().appendTo(L).fadeIn()}$(this).find("> ul.commentAnswersTier2 > li.comment").each(function(){var O=$("#comment_"+B(this));if(!O.length){var N=$(M).find("> ul.commentAnswersTier2");if($(N).find("> li.commentReplyCtr").length){$(this).hide().insertBefore($(N).find("> li.commentReplyCtr")).fadeIn("normal",function(){$(this).highlight()})}else{$(this).hide().appendTo(N).fadeIn("normal",function(){$(this).highlight()})}}})}});C(K)}});$("#commentsCountBox > .count").text($("#commentsList li.comment").length).highlight(1000);Comment.showHideTabCounts();D="";$(F).hideNearbyWaitIcon();Decision.updateVisibleUpdateItems()},error:function(){$(F).hideNearbyWaitIcon();D=""}});return false})});var Review={};$(function(){$(window).unload(function(){for(var i in Review){i=""}Review=""});function getId(elem){return parseInt($(elem).attr("id").replace(/.+_(.+)/,"$1"))}Review.updateReviews=function(updateDetails){var data={respondWithView:"updates"};var pageUpdatedAsOf=$.trim($("#optionsUpdatedSince").text());if(pageUpdatedAsOf){data.updatedSince=pageUpdatedAsOf}$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/review",data:data,global:false,success:function(responseText){var response=$("<div/>").html(responseText);var newUpdatedSinceDate=$.trim(response.find("#updatedSince").text());$("#optionsUpdatedSince").text(newUpdatedSinceDate);response.find("#reviewUpdates > li").each(function(){var existing=$("#review_"+getId(this));if(existing.length){if(updateDetails){updateReview(this,existing,true)}return }var newReview=$(this).hide().removeClass("active").addClass("waitForRefresh");Page.addReview(newReview)});response.find("#reviewCommentUpdates > li").each(function(){if($("#"+$(this).attr("id")).length){return }var reviewId=$.trim($(this).find("> .commentOnReview").text());console.log("checking for reviewId "+reviewId);var newReviewComment=$(this);$(newReviewComment).filter(".reviewComment").hide().removeClass("active").addClass("waitForRefresh");var comments=$("#review_"+reviewId+" > .inlineReviewComments");if($(comments).find(">.reviewCommentCtr").length){$(newReviewComment).insertBefore($(comments).find(">.reviewCommentCtr"))}else{if($(comments).find(">.reviewCommentReply").length){$(newReviewComment).insertBefore($(comments).find(">.reviewCommentReply"))}else{$(comments).append(newReviewComment)}}});Page.showHiddenReviewsForCurrentOption();Decision.updateVisibleUpdateItems();$("#refreshOptionsLink").hideNearbyWaitIcon();optionReviewsInProgress=""},error:function(){optionReviewsInProgress="";$("#refreshOptionsLink").hideNearbyWaitIcon()}})};var optionReviewsInProgress;$("#refreshOptionsLink").click(function(){if(optionReviewsInProgress){return }optionReviewsInProgress=true;$("#refreshOptionsLink").replaceWithWaitIcon("refreshing...");var currOptId=$("#optionTabs > li.selected").length?getId($("#optionTabs > li.selected")):"";var requestUpdates=(Decision.countOptionDetailsToRefreshNotOnPage(currOptId)>0);if(requestUpdates){Review.updateReviews()}else{Page.showHiddenReviewsForCurrentOption();Decision.updateVisibleUpdateItems();$("#refreshOptionsLink").hideNearbyWaitIcon();optionReviewsInProgress=""}return false});var showHideReviewButtons=function(){var usingGood=$(this).is("#goodReviewText");if(usingGood){if($("#goodReviewMediaTrigger").is(".active")&&$("#goodReviewMedia").val()){return }}else{if($("#badReviewMediaTrigger").is(".active")&&$("#badReviewMedia").val()){return }}var form=$(this).closest("form");if($(this).val()||form.is(".focus")){form.children(".reviewFormComponents, .charcounter").show()}else{form.children(".reviewFormComponents, .charcounter").hide();if(usingGood){$("#goodReviewMediaTrigger.active").trigger("click")}else{$("#badReviewMediaTrigger.active").trigger("click")}}};$("#goodReviewMedia, #badReviewMedia").blur(showHideReviewButtons);$("#goodReviewText, #badReviewText").autogrow({minHeight:30}).each(showHideReviewButtons).bind("keydown keyup focus blur",showHideReviewButtons);$("#goodReviewForm").hover(function(){$("#goodReviewForm").addClass("focus")},function(){$("#goodReviewForm").removeClass("focus")});$("#badReviewForm").hover(function(){$("#badReviewForm").addClass("focus")},function(){$("#badReviewForm").removeClass("focus")});$("#goodReviewForm, #badReviewForm").submit(function(){var form=this;return $(this).ajaxPostForm("decision/review/showAndScores.jsp",$(this).find("div.reviewFormComponents > .buttonBar"),{waitingMessage:"adding...",success:function(responseText){parseShowReviewAndScoresResponse(responseText);var textarea=$(form).removeClass("focus").find(">div.field-container > textarea");textarea.val("").triggerHandler("recheck");textarea.triggerHandler("blur");$(form).find("> div.reviewFormComponents > .reviewMedia > a.active").trigger("click");Decision.updateScoresAndActivity();var updatedAttrs=$(form).find("> div.reviewFormComponents > .reviewAttributes > .addInlineAttribute").hide();if($(updatedAttrs).find("> .inlineAttributeId").val()||$(updatedAttrs).find("> .inlineAttributeText").val()){$(updatedAttrs).find("> .inlineAttributeId").val("");$(updatedAttrs).find("> .inlineAttributeText").val("");Decision.updateAttributes();$("#badAddAnotherAttrTrigger, #goodAddAnotherAttrTrigger").next().attr("selected",true)}}})});$("#goodReviewForm .overlabel, #badReviewForm .overlabel, #addToOptions .overlabel, #addToAttributes .overlabel, #headerAddToOptions .overlabel").hideLabelOnEnter();$("#goodReviewForm, #badReviewForm").listen("click",".cancelLink",function(){if(!$(this).parent().is(".reviewButtons")){return false}var form=$(this).closest("form").removeClass("focus");$(this).closest("form").find("> div.reviewFormComponents > .reviewMedia > a.active").trigger("click");$(this).closest("form").find("> div.reviewFormComponents > .reviewAttributes > .addInlineAttribute").hide().find("input").val("");if($(form).is("#goodReviewForm")){$("#goodReviewText").val("");$("#goodReviewText").triggerHandler("recheck");$("#goodReviewText").triggerHandler("blur");$("#goodReviewText").each(showHideReviewButtons)}else{$("#badReviewText").val("");$("#badReviewText").triggerHandler("recheck");$("#badReviewText").triggerHandler("blur");$("#badReviewText").each(showHideReviewButtons)}$("#badAddAnotherAttrTrigger, #goodAddAnotherAttrTrigger").next().attr("selected",true);return false});$("#goodReviewText").maxChars(150,$("#goodReviewForm > span.charcounter > span.chars"));$("#badReviewText").maxChars(150,$("#badReviewForm > span.charcounter > span.chars"));$("#goodReviewMediaTrigger, #badReviewMediaTrigger").click(function(){if(!$(this).is(".active")){$(this).addClass("active").closest("form").addClass("focus").find("> div.reviewFormComponents > .reviewMediaAddition").show();$(this).text("Cancel adding link/media")}else{$(this).removeClass("active").closest("form").find("> div.reviewFormComponents > .reviewMediaAddition").hide().find("> div.field-container > textarea").val("");$(this).closest("form.newReviewForm").find(">div.reviewFormComponents > div.reviewMediaAddition > div.previewMedia").html("");$(this).text("Add a link, picture or video")}if(!this.activatedAutogrow){if($(this).is("#goodReviewMediaTrigger")){$("#goodReviewMedia").autogrow({minHeight:18})}else{$("#badReviewMedia").autogrow({minHeight:18})}}return false});$("#goodReviewList, #badReviewList").listen("click",".reviewMediaImageLink",function(){if(!this.inited){$(this).fancybox({overlayShow:false,itemArray:$(this),showTitle:false}).click()}return false});$("#goodReviewForm, #badReviewForm").listen("click",".initialRateReviewLabel",function(){var val=$.trim($(this).find(">.ratingValue").text());$(this).closest(".initialReviewRateCtr").find("> .initialRateReviewInput").val(val);$(this).addClass("selected").siblings().removeClass("selected");return false});var youtube=/(?:<\>]+href=\")?(?:http:\/\/)?(?:www|[a-z]{2})\.youtube\.com\/[^"#[]*?(?:&|&amp;|\/|\?|;|\%3F|\%2F)(?:video_id=|v(?:\/|=|\%3D|\%2F))([\w-]{11})[^"]*(?:\"[^\<\>]*>)?[^\<\>]*/img;var youtube_embed=/<object [^>]*><param name="movie" value="http:\/\/www\.youtube\.com\/v\/(\w{11}?)[^"]*">.*?<\/object>/img;var youtube_url="http://www.youtube.com/watch?v={1}";var google_video=/(?:<\>]+href=\")?(?:http:\/\/)?video.google.(com|com?\.[a-z]{2}|[a-z]{2})\/(?:videoplay|url|googleplayer\.swf)\?[^"]*?docid=([\w\-]{1,20})(?:[^"]+)?[^"]*(?:\"[^\<\>]*?>)?[^\<\>]*/img;var google_embed=/<embed [^>]*src="(?:http:\/\/)?video.google.(com|com?\.[a-z]{2}|[a-z]{2})\/(?:videoplay|url|googleplayer\.swf)\?[^"]*?docid=([\w\-]{1,20})(?:[^"]+)?[^"]*"[^>]*?>\s<\/embed>/;var google_url="http://video.google.{1}/googleplayer.swf?docId={2}";var vimeo=/(?:http:\/\/)?(?:www\.)?vimeo\.com\/(\d{1,12}).*/img;var vimeo_embed=/<object [^>]*><param name="movie" value="http:\/\/vimeo\.com\/moogaloop\.swf\?clip_id=(\d{1,12})[^"]*">.*?<\/object>.*/img;var vimeo_url="http://www.vimeo.com/{1}";var image_url_regex=/^(?:http:|https:)?\/\/(?:www\.)?.+\.(png|gif|jpg)$/i;var maxwidth=$("#goodPreviewMedia").css("maxWidth").replace("px","")*1;var maxHeight=$("#goodPreviewMedia").css("maxHeight").replace("px","")*1;$("#goodReviewMedia, #badReviewMedia").bind("paste blur",function(){var media=$(this).val();media=media.replace(/<[\s\/]*script\b[^>]*>([^>]*)<\/script>/igm,"$1");try{var width=parseInt(media.replace(/.*width="(\d+).*"/im,"$1"))}catch(e){}try{var height=parseInt(media.replace(/.*height="(\d+).*"/im,"$1"))}catch(e){}if(isNaN(width)){width=""}if(isNaN(height)){height=""}if(width||height){var ratio;if(height>width){if(height>maxheight){ratio=maxheight/height;width=width*ratio}}else{if(width>maxwidth){ratio=maxwidth/width;width=maxwidth;height=height*ratio}}media=media.replace(/width="\d+"/igm,'width="'+width+'"');media=media.replace(/height="\d+"/igm,'height="'+height+'"')}image_url_regex.lastIndex=0;if(media.indexOf("youtube")!=-1||media.indexOf("video.google")!=-1||media.indexOf("vimeo")!=-1){media=getObjectMedia(this,media)}else{if(image_url_regex.exec(media)){media='<img src="'+media+'" class="userGenerated"/>'}}if(media){$(this).closest("form.newReviewForm").find("> div.reviewFormComponents > div.reviewMediaAddition > div.previewMedia").html(media)}});var getObjectMedia=function(textarea,media){youtube_embed.lastIndex=0,youtube.lastIndex=0;var results="";results=youtube.exec(media)||youtube_embed.exec(media);if(results){var url=youtube_url.replace("{1}",results[1]);$(textarea).val(url).focus().keypress();return'<object width="315" height="255"> 				<param name="movie" value="http://www.youtube.com/v/'+results[1]+'"></param>				<param name="wmode" value="transparent"></param>				<param name="allowFullScreen" value="true"></param>				<param name="allowscriptaccess" value="sameDomain"></param>				<embed src="http://www.youtube.com/v/'+results[1]+'" type="application/x-shockwave-flash" wmode="transparent" width="315" height="255" allowfullscreen="true" allowscriptaccess="never"></embed>			</object>'}google_video.lastIndex=0,google_embed.lastIndex=0;results=google_video.exec(media)||google_embed.exec(media);if(results){var url=google_url.replace("{1}",results[1]).replace("{2}",results[2]);$(textarea).val(url).focus().keypress();return'<embed style="width:315px; height:255px;" id="VideoPlayback" wmode="opaque" type="application/x-shockwave-flash" 				src="http://video.google.'+results[1]+"/googleplayer.swf?docId="+results[2]+'&hl=en" flashvars=""> </embed>'}vimeo.lastIndex=0,vimeo_embed.lastIndex=0;results=vimeo.exec(media)||vimeo_embed.exec(media);if(results){var url=vimeo_url.replace("{1}",results[1]);$(textarea).val(url).focus().keypress();return'<object width="315" height="255"> 				<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+results[1]+'&server=vimeo.com&show_title=1&amp;show_byline=1&show_portrait=0&color=&fullscreen=1"></param>				<param name="wmode" value="transparent"></param>				<param name="allowFullScreen" value="true"></param>				<param name="allowscriptaccess" value="sameDomain"></param>				<embed src="http://vimeo.com/moogaloop.swf?clip_id='+results[1]+'&server=vimeo.com&show_title=1&amp;show_byline=1&show_portrait=0&color=&fullscreen=1"					type="application/x-shockwave-flash" wmode="transparent" width="315" height="255"></embed>			</object>'}};var parseShowReviewAndScoresResponse=function(responseText,updateContents){var response=$("<div/>").html(responseText);var dataResponse=$.trim($(response).find("#scores").text());if(!dataResponse){return }var data=eval("("+dataResponse+")");Page.parseScores(data);$(response).find("li.reviewItem").each(function(){var existing=$("li#review_"+getId(this));var elem;if(existing.length){elem=this;updateReview(this,existing,updateContents)}else{elem=Page.addReview(this)}$(elem).show()})};var updateReview=function(updatedReview,existing,updateContents){if(updateContents){$(existing).attr("class",$(updatedReview).attr("class"));$(existing).find("> .reviewContents > .reviewText").replaceWith($(updatedReview).find("> .reviewContents > .reviewText"));$(existing).find("> .reviewContents > .reviewAttribute").replaceWith($(updatedReview).find("> .reviewContents > .reviewAttribute"))}$(existing).find("> .reviewContents > .reviewActions > .reviewActionsCtr > .reviewRatings").replaceWith($(updatedReview).find("> .reviewContents > .reviewActions > .reviewActionsCtr > .reviewRatings"));$(existing).find("> .reviewScores").replaceWith($(updatedReview).find("> .reviewScores").highlight());$(existing).addClass("hasRating")};$("#goodReviewList, #badReviewList").listen("click",".reviewRateButton",function(){if($(this).closest("form").find(".waitCursor").length||$(this).is(".selected")){return false}var val=$.trim($(this).find(">.importanceRatingValue").text());$(this).closest("form").find("> .importanceRatingInput").val(val);$(this).siblings().removeClass("selected");return $(this).ajaxPostForm("decision/review/showAndScores.jsp",$(this).closest("a"),{waitingMessage:"",success:function(responseText){parseShowReviewAndScoresResponse(responseText)}})});$("#goodReviewList, #badReviewList").listen("click",".waitCursor",function(){return false});$("#goodReviews, #badReviews").listen("click","a.removeReviewButton",function(){return $(this).ajaxPostForm("headers",this,{success:function(responseText,form){var li=$(form).closest("li");if(!li.length){return }li.remove();Decision.updateScoresAndActivity()},waitingMessage:"removing..."})}).listen("click","a.junkReviewButton",function(){return $(this).ajaxPostForm("headers",this,{success:function(responseText,form){var li=$(form).closest("li");if(!li.length){return }li.remove();Decision.updateScoresAndActivity()},waitingMessage:"marking as junk...",data:{junk:"true"}})}).listen("click","a.showSublineLink",function(){$(this).closest("li.reviewItem").toggleClass("more");return false});$("#reviews").listen("click",".rateReviewTrigger",function(){return false});var showHideCommentButtons=function(){var form=$(this).closest("form");if($(this).val()||form.is(".focus")){form.children(".commentButtons").show()}else{form.children(".commentButtons").hide()}};$("#reviews").listen("click",".commentOnReviewLink, .replyToReviewCommentLink",function(){var reviewComments=$(this).closest("li.reviewItem").find("> ul.inlineReviewComments");if(!reviewComments.get(0).initedForm){var reviewId=getId($(this).closest("li.reviewItem"));var newForm=$("#reviewReplyForm").clone().attr("id","reviewReplyForm_"+reviewId);newForm.wrap("<li class='reviewCommentCtr'></li>");var inputField=$(newForm).find("> div.newCommentCtr > textarea");inputField.attr("id","replyToReviewTextarea_"+reviewId);inputField.prev("label.overlabel").attr("for","replyToReviewTextarea_"+reviewId);newForm.closest("li").hide().appendTo($(this).closest("li.reviewItem").find("> ul.inlineReviewComments")).fadeIn();newForm.find("> input.replyToReviewInput").val(reviewId);$(inputField).autogrow({minHeight:30}).maxChars(250,"> .buttonBar > span.charcounter > span.chars").prev("label.overlabel").hideLabelOnEnter();$(inputField).bind("paste keyup keydown focus blur",function(){$(this).each(showHideCommentButtons)}).each(showHideCommentButtons);$(newForm).submit(function(){return $(this).ajaxPostForm("show",$(newForm).find("> .buttonBar > .buttons"),{waitingMessage:"adding...",success:function(responseText,form){var li=$("<div></div>").html(responseText).find("> li.reviewComment").hide();li.insertBefore($(form).closest("li"));li.slideDown().highlight(1000);$(form).closest("li.reviewCommentCtr").hide();$(form).find("> div.newCommentCtr > textarea").val("").each(showHideCommentButtons).triggerHandler("blur")}})});reviewComments.get(0).initedForm=true}$(this).closest("li.reviewItem").addClass("hideHoverBox");$(this).closest("li.reviewItem").find("> ul.inlineReviewComments > li.reviewCommentCtr").show().find(">form").show().find("> div.newCommentCtr > textarea").focus();$(reviewComments).find("> li.reviewCommentReply").remove();return false}).listen("click",".deleteCommentLink",function(){return $(this).ajaxPostForm("headers",this,{success:function(responseText,form){$(form).closest("li.reviewComment").slideUp(function(){$(this).remove()})}});return false}).listen("click",".cancelReviewCommentLink",function(){$(this).closest("li.reviewCommentCtr").hide().find("> form > div.newCommentCtr > textarea").val("");return false}).listen("blur",".commentOnReviewText",function(){$(this).closest("li.reviewItem").removeClass("hideHoverBox")}).listen("click",".showMoreCommentsLink",function(){$(this).closest("ul").children(".reviewComment.overflow").hide().removeClass("overflow").fadeIn("slow");$(this).closest("li.showMoreCtr").remove();return false}).listen("click",".editReviewLink",function(){$("#editReviewBlockCtr").show().overlay(true,function(){$("#closeEditReviewLink").trigger("click")});$("#editReviewForm").replaceWithWaitIcon("loading");$.ajax({type:"GET",url:$(this).attr("href"),data:{respondWithView:"edit"},error:function(xhr,textStatus){if(!xhr){return }if(xhr.status==302){return }CrowdMind.parseErrorMessages(xhr.responseText);$("#editReviewForm").hideNearbyWaitIcon()},success:function(responseText){var response=$("<div/>").append(responseText);$("#editReviewForm").hideNearbyWaitIcon();$("#editReviewForm").replaceWith($(response).find("#editReviewForm"));$("#editReviewText").maxChars(150,$("#editReviewForm > .editReviewTextBlock > span.charcounter > span.chars"));$("#editReviewText").autogrow({minHeight:30})}});return false});$("#editReviewBlock").listen("click",".cancelLink",function(){$("#closeEditReviewLink").trigger("click");return false});$("#editReviewBlock").listen("click",".submitEditReviewButton",function(){return $(this).closest("form").ajaxPostForm("decision/review/showAndScores.jsp",$("#editReviewForm > .buttonBar"),{waitingMessage:"saving...",success:function(responseText){parseShowReviewAndScoresResponse(responseText,true);$("#closeEditReviewLink").trigger("click")}})});$("#closeEditReviewLink").click(function(){$("#editReviewBlockCtr").hide().overlay(false);return false})});var Decision={},Comment=Comment||{},Page=Page||{};$(function(){$(window).unload(function(){for(var K in Decision){K=""}Decision=""});function B(K){return parseInt($(K).attr("id").replace(/.+_(.+)/,"$1"))}Decision.updateDetails={};Decision.updateDetails.comments=[];Decision.updateDetails.options={reviews:[],comments:[]};Decision.updateVisibleUpdateItems=function(){Page.updateOptionRefreshLinks();Comment.updateCommentLinks();if($("#floatingNotificationBar > a.show").length){$("#floatingNotificationBarWrapper").fadeIn()}else{$("#floatingNotificationBarWrapper").fadeOut()}};$("#sharePageLink").click(function(){$("#sharingBlock").show().overlay(true,function(){$("#closeShareLink").trigger("click")});if($("#helpSharingContent textarea").length){$("#helpSharingContent textarea").get(0).select()}if($("#inviteGuestsForm").length){var K=$("#inviteGuestsForm").get(0);if(!K.inited){K.inited=true;$("#cancelGuestInvites").click(function(){$("#guestUserEmails").val("");$("#closeShareLink").trigger("click");return false});$("#inviteGuestsForm").submit(function(){return $(this).ajaxPostForm("headers",$("#inviteGuestsForm > .buttonBar"),{waitingMessage:"sending invites...",success:function(M,L){$("#guestUserEmails").val("");$("#closeShareLink").trigger("click")}})});$("#guestUserEmailsLabel").hideLabelOnEnter()}}return false});$("#closeShareLink").click(function(){$("#sharingBlock").hide().overlay(false);return false});$("#guestContributors").listen("click",".deleteGuestButton",function(){return $(this).closest("form").ajaxPostForm("headers",this,{success:function(L,K){$(K).closest("li.guest").remove();if(!$("#guestContributors > li").length){$("#manageCurrentGuestsHeader").hide()}}})});var D,J;Decision.updateScoresAndActivity=function(){if(D){return }D=true;$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/score",data:{respondWithView:"json"},cache:false,global:false,dataType:"json",success:function(M){Page.parseScores(M);$.each(M.reviews,function(N,O){$("li#review_"+O.id+"> div.reviewScores > .count").updateAndHighlightIfChanged(O.crowdScore)});$("#commentsCountBox > .count").updateAndHighlightIfChanged(M.comments);Comment.showHideTabCounts();D=""},error:function(){D=""}});if(J){return }J=true;var L={respondWithView:"decision/activity/list"};var K=$.trim($("#activityLastUpdated").text());if(K){L.modifiedSince=K}$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/activity",data:L,global:false,success:function(N){var M=$("<div/>").html(N);$("#activityLastUpdated").text(M.find("#activityLastUpdated").text());var O=M.find("#decisionActivities > li.activity").filter(function(){return !($("#decisionActivity_"+B(this)).length)});$(O).hide().prependTo("#decisionActivities").slideDown(600,function(){$(this).highlight()});J=""},error:function(){J=""}})};var I=function(K){$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/help/"+K,data:{respondWithView:"updates"},cache:false,global:false,success:function(M){var L=$("<div/>").html(M).find("> li.decisionHelperDetails");if($("#"+$(L).attr("id")).length){$(L).replaceAll("#"+$(L).attr("id")).blink()}else{$(L).appendTo("#decisionHelpersList").blink()}$("#decisionHelpersBox.empty").hide().removeClass("empty").slideDown();$(L).find("> img.profileImage").hover(function(){$(this).closest("li").addClass("active")},function(){$(this).closest("li").removeClass("active")})}})};var C=function(L){if(!L.data){return }var M=L.data;var K=parseInt($.trim($("#currentUserId").text()));if(M.updater){I(M.updater)}if(K==M.updater){return }if(M.updateType=="newOption"||M.updateType=="newOptionDetails"){Page.updateOptions()}if(M.updateType=="newAttribute"){Decision.updateAttributes()}if(M.updateType=="changedDecisionDetails"){Decision.updateDecisionDetails()}if(M.updateType=="decisionTypeChanged"){CrowdMind.addErrorMessage(M.message)}if(M.updateType=="removeOption"||M.updateType=="mergedAndRemovedOption"){$("#optionTab_"+M.optionId).addClass("deleted").not(".overflow").blink();$("#headerOption_"+M.optionId).addClass("deleted").blink();$("#optionOverflowTab_"+optionId).addClass("deleted")}if(M.updateType=="mergedAndRemovedOption"){Review.updateReviews()}if(M.updateType=="removeAttribute"){$("#decisionAttribute_"+M.attributeId).addClass("deleted").blink()}if(M.updateType=="removeReview"){$("#review_"+M.reviewId).addClass("deleted").blink();Decision.removePendingReview(M.reviewId)}if(M.updateType=="removeComment"){$("#comment_"+M.commentId).addClass("deleted").blink();Decision.updateDetails.comments.remove("#comment_"+M.commentId)}if(M.updateType=="removeReviewComment"){$("#reviewComment_"+M.reviewCommentId).addClass("deleted").blink();Decision.removePendingReviewComment(M.reviewCommentId)}if(M.updateType=="newReview"){if(!$("#review_"+M.reviewId).length){Decision.updateDetails.options.reviews.push({optionId:M.optionId,domID:"#review_"+M.reviewId});if(!("#optionTab_"+M.optionId).length){Page.updateOptions()}}}if(M.updateType=="updatedReview"){Review.updateReviews(true)}if(M.updateType=="newReviewComment"){if(!$("#reviewComment_"+M.reviewCommentId).length){Decision.updateDetails.options.comments.push({optionId:M.optionId,domID:"#reviewComment_"+M.reviewCommentId})}}if(M.updateType=="newComment"||M.updateType=="newCommentReply"){if(!$("#comment_"+M.commentId).length){Decision.updateDetails.comments.push("#comment_"+M.commentId)}}Decision.updateVisibleUpdateItems();if(M.updateType=="newReviewRating"||M.updateType=="newOptionRating"||M.updateType=="newReview"||M.updateType=="removeReview"||M.updateType=="removeAttribute"){Decision.updateScoresAndActivity()}};Decision.showHideReasonRefreshLinks=function(K,L,M){if(K&&L){$("#refreshOptionsBar").addClass("both")}else{$("#refreshOptionsBar").removeClass("both")}if(K+L>1){$("#refreshOptionsBar").addClass("plural")}else{$("#refreshOptionsBar").removeClass("plural")}if(K){$("#refreshOptionsBar > .comments").show().find("> .count").text(K);if(K>1){$("#refreshOptionsBar > .comments").addClass("plural")}}else{$("#refreshOptionsBar > .comments").hide().find("> .count").text(0);$("#refreshOptionsBar > .comments").removeClass("plural")}if(L){$("#refreshOptionsBar > .reasons").show().find("> .count").text(L);if(L>1){$("#refreshOptionsBar > .reasons").addClass("plural")}}else{$("#refreshOptionsBar > .reasons").hide().find("> .count").text(0);$("#refreshOptionsBar > .reasons").removeClass("plural")}if(K||L){$("#refreshOptionsBar").slideDown();$(M).show().addClass("show")}else{$("#refreshOptionsBar").removeClass("plural both").hide();$(M).hide().removeClass("show")}};Decision.countReasonsToRefresh=function(L){var M=0;if(Decision.updateDetails.options.reviews){for(var K=0;K<Decision.updateDetails.options.reviews.length;K++){if(Decision.updateDetails.options.reviews[K].optionId==L){M++}}}return M};Decision.countOptionDetailsToRefreshNotOnPage=function(M){var L=0;if(Decision.updateDetails.options.reviews){for(var K=0;K<Decision.updateDetails.options.reviews.length;K++){if(!$(Decision.updateDetails.options.reviews[K].domID).length&&(!M||Decision.updateDetails.options.reviews[K].optionId==M)){L++}}}if(Decision.updateDetails.options.comments){for(var K=0;K<Decision.updateDetails.options.comments.length;K++){if(!$(Decision.updateDetails.options.comments[K].domID).length&&(!M||Decision.updateDetails.options.comments[K].optionId==M)){L++}}}return L};Decision.countReasonCommentsToRefresh=function(L){var M=0;if(Decision.updateDetails.options.comments){for(var K=0;K<Decision.updateDetails.options.comments.length;K++){if(Decision.updateDetails.options.comments[K].optionId==L){M++}}}return M};Decision.removePendingReview=function(K){if(Decision.updateDetails.options.reviews){Decision.updateDetails.options.reviews=$.map(Decision.updateDetails.options.reviews,function(M,L){if(M.domID=="#review_"+K){return null}return M})}};Decision.removePendingReviewComment=function(K){if(Decision.updateDetails.options.comments){Decision.updateDetails.options.comments=$.map(Decision.updateDetails.options.comments,function(M,L){if(M.domID=="#reviewComment_"+K){return null}return M})}};Decision.getOptionsWithUpdatedDetails=function(){var L=[];if(Decision.updateDetails.options.reviews){for(var K=0;K<Decision.updateDetails.options.reviews.length;K++){if(L.indexOf(Decision.updateDetails.options.reviews[K].optionId)==-1){L.push(Decision.updateDetails.options.reviews[K].optionId)}}}if(Decision.updateDetails.options.comments){for(var K=0;K<Decision.updateDetails.options.comments.length;K++){if(L.indexOf(Decision.updateDetails.options.comments[K].optionId)==-1){L.push(Decision.updateDetails.options.comments[K].optionId)}}}return L};Decision.refreshOptionUpdateDetails=function(){var K=[];if(Decision.updateDetails.options.reviews){for(var M=0;M<Decision.updateDetails.options.reviews.length;M++){if(!$(Decision.updateDetails.options.reviews[M].domID).length||$(Decision.updateDetails.options.reviews[M].domID).is(".waitForRefresh")){K.push(Decision.updateDetails.options.reviews[M])}}}Decision.updateDetails.options.reviews=K;var L=[];if(Decision.updateDetails.options.comments){for(var M=0;M<Decision.updateDetails.options.comments.length;M++){if(!$(Decision.updateDetails.options.comments[M].domID).length||$(Decision.updateDetails.options.comments[M].domID).is(".waitForRefresh")){L.push(Decision.updateDetails.options.comments[M])}}}Decision.updateDetails.options.comments=L};$.addPushNotifications($.trim($("#baseCometServiceUrl").text()),"/activity/decision/"+$.trim($("#decisionId").text()),$.trim($("#currentUserId").text()),this,C);$("#floatingNotificationBar").listen("click","a",function(){if($(this).is("#newCommentsShortcut")){window.scrollTo(0,$("#refreshCommentsBar").offset().top)}else{if($(this).is("#newReviewsShortcut")){window.scrollTo(0,$("#reviews").offset().top-250)}else{var K=$(this).attr("id").replace(/newOption(\d+)Shortcut/,"$1");$("#optionTab_"+K).trigger("click");window.scrollTo(0,$("#reviews").offset().top-250)}}return false});$("#decisionHelpersList").find(" > li > img.profileImage").hover(function(){$(this).closest("li").addClass("active")},function(){$(this).closest("li").removeClass("active")});$("#attributesTrigger").click(function(){$("#addNewAttributeText").focus();$("#addNewAttributeText").highlight(1500);return false});$("#optionPicksCtr").listen("click",".optionPickButton",function(){if($(this).closest("form").is(".userPick")){return false}if($("#optionPicksCtr").is(".saving")){return false}$("#optionPicksCtr").addClass("saving");return $(this).ajaxPostForm("json",this,{waitIconId:"#waitCursor16",dataType:"json",success:function(L,K){$("#headerOptionList > .headerOption > form.userPick").removeClass("userPick");Page.parseScores(L,function(M,N){if(M==L.options.length-1){$("#optionPicksCtr").removeClass("saving");$("#afterPollMessage").fadeIn("slow",function(){$(this).highlight(1000)})}});$(K).addClass("userPick");$("#afterPollMessage > .optionName").text($(K).find(".optionPickName").text());Page.afterVote(B($(K).closest("li.headerOption")))},error:function(L,M){$("#optionPicksCtr").removeClass("saving");if(L.statusText){var K=L.statusText.replace(/\[(.*)\]/,"$1");CrowdMind.addErrorMessage(K)}}})});Decision.updateDecisionDetails=function(){$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/setup/get",data:{respondWithView:"show"},global:false,success:function(L){var K=$("<div/>").html(L);$("#decisionQuestion").text($(K).find("#decisionQuestion").text());$("#decisionDetailsPara").html($(K).find("#decisionDetailsPara"))}})};var G=false;Decision.updateAttributes=function(){if(G){return }G=true;$.ajax({type:"GET",url:"/decision/"+$.trim($("#decisionId").text())+"/attribute",data:{respondWithView:"list"},global:false,success:function(K){$("<div/>").html(K).find("> li.decisionAttribute").each(function(){var M=B(this);if(!$("li#decisionAttribute_"+M).removeClass("deleted").length){$("#addToAttributes").before(this);$("li#decisionAttribute_"+M).highlight(1000);var L=$(this).find(">span.attrName").text();$("#reviews > div > form.newReviewForm > div.reviewFormComponents > div.reviewAttributes > select").each(function(){var N=$("<option></option>").appendTo(this);N.attr("id","reviewAttribute_"+M).attr("value",M).text(L)});$("#addAttrsInstruction").addClass("completed")}});$("#reviews > div > form.newReviewForm > div.reviewFormComponents > div.reviewAttributes > select").sortChildren();G=""},error:function(){G=""}})};var E=function(){var K=$(this).closest("form");if($(this).val()||K.is(".focus")){K.children(".attributeButtons, #attributeSuggestions").show()}else{K.children(".attributeButtons, #attributeSuggestions").hide()}};$("#addNewAttributeText").keyup(E).focus(E).each(E);$("#showAttributeFormButton").click(function(){$("#addNewAttributeText").parent().show().end().keyup().focus();$(this).hide();return false});var H=false;$("#addToAttributes").find(">form").submit(function(){var K=this;return $(this).ajaxPostForm("decision/attribute/show.jsp",$("#addToAttributes").find(" >form >.buttonBar"),{waitingMessage:"adding...",beforeSend:function(){$(K).addClass("submitting")},success:function(M){var L=$("<div/>").html(M);$(L).find("li.decisionAttribute").each(function(){var O=B(this),N=$(this).find(">span.attrName").text();if($("li#decisionAttribute_"+O).length){$("li#decisionAttribute_"+O).highlight()}else{$("#addToAttributes").before(this);$("#reviews > div > form.newReviewForm > div.reviewFormComponents > div.reviewAttributes > select").each(function(){var P=$("<option></option>").appendTo(this);P.attr("id","reviewAttribute_"+O).attr("value",O).text(N)})}if($("#decisionInstructions").length){$("#decisionInstructions").find("ul > li:eq(1) > .instruction").addClass("complete")}});$("#addAttrsInstruction").addClass("completed");$("#reviews > div > form.newReviewForm > div.reviewFormComponents > div.reviewAttributes > select").sortChildren();$("#addNewAttributeText").val("").focus();$("#addExistingAttributeId").val("");$(K).removeClass("submitting")},error:function(){$(K).removeClass("submitting")}})}).find("> .attributeButtons > .cancelLink").click(function(){$("#addNewAttributeText").each(function(){$(this).val("");$(this).triggerHandler("recheck");$(this).triggerHandler("blur")});$(this).closest("form").find(" > div.attributeButtons").hide().end();$("#attributeSuggestionList").hide();$("#addExistingAttributeId").val("");return false});if($.trim($("#autocompleteAttributes").text())=="true"){$("#addToAttributes > form").suggestPanel($.trim($("#addToAttributes > form >span.suggestionUrl").text()),$("#attributeSuggestionList"),{dont_remove_child:"a.closeLink",disable_submit:false,completion_field:"#addNewAttributeText",on_submit:function(K,M,L){$("#attributeSuggestionList").hide();$("#addNewAttributeText").val(L.text());$("#addExistingAttributeId").val(M);$(K).submit()},on_nodatafound:function(){$("#addExistingAttributeId").val("")},on_datafound:function(K){if($(K).is(".submitting")||H){return false}$("#addExistingAttributeId").val("")}});$("#goodReviewForm").suggestPanel($.trim($("#addToAttributes > form >span.suggestionUrl").text()),$("#goodInlineAttributeSuggestionList"),{dont_remove_child:"a.closeLink",disable_submit:false,completion_field:"#goodInlineAttributeText",on_submit:function(K,M,L){$("#goodInlineAttributeSuggestionList").hide();$("#goodInlineAttributeText").val(L.text());$("#goodInlineAttributeId").val(M)},on_nodatafound:function(){$("#goodInlineAttributeId").val("")},on_datafound:function(K){$("#goodInlineAttributeId").val("")}});$("#badReviewForm").suggestPanel($.trim($("#addToAttributes > form >span.suggestionUrl").text()),$("#badInlineAttributeSuggestionList"),{dont_remove_child:"a.closeLink",disable_submit:false,completion_field:"#badInlineAttributeText",on_submit:function(K,M,L){$("#badInlineAttributeSuggestionList").hide();$("#badInlineAttributeText").val(L.text());$("#badInlineAttributeId").val(M)},on_nodatafound:function(){$("#badInlineAttributeId").val("")},on_datafound:function(K){$("#badInlineAttributeId").val("")}})}$("#goodReviewAttributeSelect, #badReviewAttributeSelect").bind("change click",function(){if($(this).find(">option:selected").is("#goodAddAnotherAttrTrigger, #badAddAnotherAttrTrigger")){if($(this).closest(".reviewAttributes").find("> .addInlineAttribute").is(":hidden")){$(this).closest(".reviewAttributes").find("> .addInlineAttribute").show().find("> .inlineAttributeText").focus()}}else{$(this).closest(".reviewAttributes").find("> .addInlineAttribute").hide().children(".inlineAttributeId, .inlineAttributeText").val("")}});$("#goodInlineAttributeSuggestionList, #badInlineAttributeSuggestionList").find("> a.closeLink").click(function(){$(this).closest("ul").hide();$(this).closest(".addInlineAttribute").find("> .inlineAttributeId").val("");return false});$("#attributeSuggestionList > a.closeLink").click(function(){$("#addExistingAttributeId").val("");$("#attributeSuggestionList").hide();return false});var A=false;$("#addToAttributes").hover(function(){A=true},function(){A=false;F()});var F=function(){if(!A&&H){$("#attributeSuggestions").hide();$("#attributeSuggestionList").hide()}};$("#addNewAttributeText").blur(function(){H=true;F()});$("#editAttributesLink").click(function(){if($("#attributesList").is(".editMode")){$("#attributesList").removeClass("editMode");$(this).text("edit criteria")}else{$("#attributesList").addClass("editMode");$(this).text("done editing")}return false});$("#addNewAttributeText").focus(function(){H=false});$("#attributesList").listen("click",".deleteImageButton",function(){return $(this).ajaxPostForm("headers",this,{success:function(N,L){var K=$(L).closest("li");var M=B(K);if(!K.length){return }K.remove();$("#reviews > div > form.newReviewForm > div.reviewFormComponents > div.reviewAttributes > select > option[value="+M+"]").remove();$("#reviews > div.reviewBox > ul.reviewList > li.reviewItem").filter(".reviewForAttribute_"+M).remove()}})});$("#highlightShare").click(function(){$("#getHelpLinks").children().highlight(1500);return false});$("#closeInstructions").click(function(){$("#decisionInstructions").fadeOut("fast");return false});$("#moreActivityLi").click(function(){$("#showMoreActivityLink").replaceWithWaitIcon("loading...");$.ajax({type:"get",url:$("#showMoreActivityLink").attr("href"),data:{respondWithView:"decision/activity/list"},success:function(M){var K=$("<div/>").html(M);$("#moreActivityLi").before("<li class='refreshLine'>&nbsp;</li>");K.find("#decisionActivities > li.activity").filter(function(){return !$("#decisionActivity_"+B(this)).length}).hide().insertBefore("#moreActivityLi").fadeIn();var L=K.find("#showMoreActivityLink");if(L.length){$("#showMoreActivityLink").hideNearbyWaitIcon();$("#showMoreActivityLink").attr("href",$(L).attr("href"))}else{$("#moreActivityLi").hide()}},error:function(){$("#showMoreActivityLink").hideNearbyWaitIcon()},global:false});return false});$("#decisionDetailsBox").listen("click","#showMoreDetails",function(){$("#decisionPartialDetails").hide();$("#decisionDetails").show();return false});$("#decisionDetailsBox").listen("click","#showLessDetails",function(){$("#decisionPartialDetails").show();$("#decisionDetails").hide();return false})});