var upDesc="Vote up, if it's clear and useful (Click again to undo)";var dnDesc="Vote down, if it's unclear or not useful (Click again to undo)";var yes="Yes";var no="No";var wait="Processing...";var reported="Reported";var chrLft="{0} characters left.";var addCmt="Add comment";var closeCmt="Close Comment Box";var comment="Comment";var save="Save";function updateCmt(b){var a=$("#cmtEdit-"+b).parent().parent().prev();a.html(a.find("textarea").val().replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/\n/gi,"<br />"))}var attachment={name:document.title,href:location.href};function fbPubAsk(){if(document.cookie.indexOf("fb"+qid)>-1){document.cookie="fb"+qid+"=; path=/; expires=Fri, 31 Dec 1999 23:59:59 GMT;";try{FB.ensureInit(function(){FB.Connect.streamPublish("",attachment,null,null,"",function(b,c){if(b!="null"&&b!=null){$.get("/core/postedfacebook?qid="+qid)}})})}catch(a){}}}$("body").ready(function(){$.each(vts,function(){var h=$(".vote input[value="+this.a+"]");if(this.m==1){h.prevAll(".voteUp").addClass("voteUpC")}else{h.prevAll(".voteDn").addClass("voteDnC")}});var b=$("#AnswerDetail");b.focus(function(){b.css("height","190px")});function g(j,h,i){if(j==1){i.text(parseInt(i.text())-1);h.toggleClass("voteUpC")}else{i.text(parseInt(i.text())+1);h.toggleClass("voteDnC")}}function e(o,n,i){var k;var p;var h=$(i);if(n){k=h.next();p=parseInt(k.text());if(h.hasClass("voteUpC")){p--}else{p++}h.toggleClass("voteUpC");var l=h.nextAll("div[class$=voteDnC]");if(l.length>0){l.removeClass("voteDnC");p++}k.text(p)}else{k=h.prev();p=parseInt(k.text());if(h.hasClass("voteDnC")){p++}else{p--}h.toggleClass("voteDnC");var m=h.prevAll("div[class$=voteUpC]");if(m.length>0){m.removeClass("voteUpC");p--}k.text(p)}$.post("/core/vote",{q:qid,a:o,m:n,r:(new Date()).getTime()},function(q){if(q){switch(q.d.n){case 0:g(n,h,k);modal(0,null);break;case 6:g(n,h,k);modal(2,q.d.v);break}}},"json");var j=k.nextAll("input")}var d=$("div[class^=voteUp]");var f=$("div[class^=voteDn]");var a=$("div[class^=voteBest]");d.attr("title",upDesc);f.attr("title",dnDesc);function c(h){return $(h).nextAll("input").val()}$(".btnShare").click(function(){modal(1,null,null,"/info/sharedialog");return false});d.live("click",function(){e(c(this),true,this)});f.live("click",function(){e(c(this),false,this)});if(qo==0){a.css("cursor","default")}a.live("click",function(){var j=$(this);if(qo==1){var i="voteBestC";var h=j.hasClass(i);$("div[class^=voteBest]").removeClass(i);if(!h){j.addClass(i)}$.get("/core/setbest",{q:qid,a:c(j),m:j.hasClass("voteBestC"),r:(new Date()).getTime()})}});$("a[id^=rpt]").live("click",function(){cfm(this,function(i){var h=i.attr("id").split("-");var j=0;aid=h[1];if(h.length==3){j=h[2]}i.next("span").text(wait);$.post("/core/report",{qid:qid,aid:aid,cid:j,r:(new Date()).getTime()},function(k){if(k.ok==1){switch(k.d.n){case 0:i.next("span").remove();i.show();modal(0,null);break;case 6:i.next("span").remove();i.show();modal(2,k.d.v);break;default:i.next("span").text(reported);break}}},"json")});return false});$("a[id^=cmtEdit]").live("click",function(){var h=$(this).parent().parent().prev();if(h.find("p").length==0){var k=/<br>/gi;var i=h.html().replace(k,"\n");var j=$(this).attr("id").replace("cmtEdit-","");h.html('<form method="post" action="/core/editcomment?CommentId='+j+'"><p><textarea name="CommentDetail" style="width:529px;height:70px;margin-bottom:6px">'+i+'</textarea></p><p><span class="btn"><input class="sbmt" value="'+save+'" type="submit"></span></p></form>');h.find("textarea").lc(900,chrLft,".btn")}return false});$("a[id^=cmtDel]").live("click",function(){cfm(this,function(h){var i=h.attr("id").replace("cmtDel-","");h.next("span").text(wait);$.post("/core/deletecomment",{c:i,r:(new Date()).getTime()},function(k){if(k.ok==1){switch(k.d.n){case 0:h.next("span").remove();h.show();modal(0,null);break;case 6:h.next("span").remove();h.show();modal(2,k.d.v);break;default:h.closest("div .cmt").slideUp(300);break}}},"json")});return false});$(".cmt").live("mouseover",function(){$(this).find(".cmtCtt").addClass("cmtCttFlip");$(this).find(".cmtBar").show()});$(".cmt").live("mouseout",function(){$(this).find(".cmtCtt").removeClass("cmtCttFlip");$(this).find(".cmtBar").hide()});$("#col1 a[id^=cmtAdd-]").live("click",function(){var i=$(this).attr("id").replace("cmtAdd-","");var h=$("#frm-"+i);if(h.length==0){$(this).text(closeCmt);$(this).parent().after('<form id="frm-'+i+'" class="cmtForm" method="post" action="/core/postcomment?QuesId='+qid+"&AnswerId="+i+'"><p><textarea name="CommentDetail"></textarea></p><div class="ctnBtn"><span class="btn"><input type="submit" class="sbmt" value="'+comment+'" /></span></div></form>');$("#frm-"+i+" textarea").lc(900,chrLft,".btn")}else{$(this).text(addCmt);h.remove()}return false});$("#col1 a[id^=cmtAll-]").live("click",function(){var h=$(this).attr("id").replace("cmtAll-","");$(this).replaceWith('<span id="cmtWait-'+h+'" class="loadingMini"></span>');$.get("/core/morecomments?qid="+qid+"&aid="+h,function(i){$("#cmtList-"+h).append(i);$("#cmtWait-"+h).remove()});return false})});function popup(d,e,a,c){var h=$(window).width();var b=$(window).height();var g=h/2-e/2;var f=b/2-a/2;window.open(d,"PopWin","toolbar=0,scrollbars="+c+",location=1,statusbar=1,menubar=0,resizable=1,width="+e+",height="+a+",left="+g+",top ="+f,false)}$(function(){$("#containShare a").live("click",function(){var a=$(this).attr("id").split("-");var b=$(this).attr("href");if(b.indexOf("#")>-1){popup("http://www.addthis.com/bookmark.php?pub=concisemedia&v=250&source=tbx-250&s="+a[0]+"&url="+encodeURI($("link[rel=canonical]").attr("href")),a[1],a[2],a[3])}else{popup($.fmt(b,encodeURI($("link[rel=canonical]").attr("href"))),a[1],a[2],a[3])}$("#btnClose").trigger("click");return false})});