$(function(){function E(I){if(!$(I).attr("id")){return""}return parseInt($(I).attr("id").replace(/.+_(.+)/,"$1"))}$("#categoryLinks").listen("click","a",function(){var I=$(this).attr("href");$("#categoryLinks li").removeClass("selected");$(this).parents("li").addClass("selected");$("#browsePageLoadingIcon").show();var J=$(this).closest("li").attr("id");if($("#decisionsCtrFor_"+J).length){$("#decisionListsBlock").children().not("#startDecisionContainer").hide();$("#decisionsCtrFor_"+J).fadeIn();$("#browsePageLoadingIcon").fadeOut();return false}$.ajax({type:"GET",url:I,data:{respondWithView:"/browse/decision/list"},global:false,success:function(L){var K=$("<div></div>").append(L);$("#decisionListsBlock").children().not("#startDecisionContainer").hide();K.find(">div.decisionListCtr").hide().appendTo("#decisionListsBlock").fadeIn();$("#browsePageLoadingIcon").fadeOut()},error:function(){$("#browsePageLoadingIcon").fadeOut()}});return false});var G=false;var A="";var B=function(){if(D){clearTimeout(D)}var I=$("#decisionQuestion").val();if(G||A==I){return }A=I;$("#browsePageLoadingIcon").show();$.ajax({type:"GET",url:"/browse/category/find",data:{q:$("#decisionQuestion").val(),respondWithView:"/browse/decision/list"},global:false,success:function(K){var J=$("<div></div>").append(K);$("#decisionListsBlock").children().not("#startDecisionContainer").hide();J.find(">div.decisionListCtr").appendTo("#decisionListsBlock");$("#browsePageLoadingIcon").fadeOut()},error:function(){$("#browsePageLoadingIcon").fadeOut()}})};var D;var F=function(){if(D){clearTimeout(D)}var K=$("#decisionQuestion").val();var J=K.length;var L=0;if(!J){G=true;A="";return }else{G=false}var I=false;I=Math.abs(K.length-A.length)>4;I|=K.charAt(K.length-1)==" ";if(I){B()}else{D=setTimeout(B,1000)}};$("#decisionQuestionOverlabel").hideLabelOnEnter();$("#decisionQuestion").maxChars(150,$("#decisionForm > div.buttonBar > span.charcounter > span.chars"));$("#decisionForm").submit(function(){var I=$("#waitCursor16White").clone();I.attr("id","").show().find(">.message").text("Starting new Question...");$("#decisionStartButton").hide().before(I)});$("#decisionQuestion").bind("keydown focus",function(){$("#decisionForm").addClass("active")});$("#decisionQuestion").bind("keyup paste",F);$("#decisionQuestion").bind("blur",function(){$("#decisionForm").removeClass("active")});$("#decisionContainer").listen("click","li.showMoreLink, a.showMoreLinkTrigger",function(){$(this).hide().closest("ul").find("li.overflow").show();return false});var H=$("#decisionListsBlock > .decisionListCtr:first:visible");if(H.length){var C=$(H).attr("id").replace(/decisionsCtrFor_(.*)/,"$1");$("#categoryLinks li").removeClass("selected");if(C){$("#"+C).addClass("selected").parents("li").addClass("selected")}}});