/* Copyright (c) 2008 Akatoo Inc. */

function addEvent(C,B,A){if(C.addEventListener){C.addEventListener(B,A,false);EventCache.add(C,B,A)}else{if(C.attachEvent){C["e"+B+A]=A;C[B+A]=function(){C["e"+B+A](window.event)};C.attachEvent("on"+B,C[B+A]);EventCache.add(C,B,A)}else{C["on"+B]=C["e"+B+A]}}}var EventCache=function(){var A=[];return{listEvents:A,add:function(B,D,C){A.push(arguments)},flush:function(){var B,C;for(B=A.length-1;B>=0;B=B-1){C=A[B];if(C[0].removeEventListener){C[0].removeEventListener(C[1],C[2],C[3])}if(C[1].substring(0,2)!="on"){C[1]="on"+C[1]}if(C[0].detachEvent){C[0].detachEvent(C[1],C[2])}C[0][C[1]]=null}}}}();addEvent(window,"unload",EventCache.flush);function $(A){return document.getElementById(A)}function stopEventPropagation(A){if(!A){A=window.event}A.cancelBubble=true;if(A.stopPropagation){A.stopPropagation()}}function preventEventDefault(A){if(!A){A=window.event}if(A.preventDefault){A.preventDefault()}else{A.returnValue=false}}Function.prototype.bind=function(){var B=[],D=arguments[0],C=this,A;for(A=1;A<arguments.length;++A){B.push(arguments[A])}return function(){for(var E=0;E<arguments.length;++E){B.push(arguments[E])}return C.apply(D,B)}};function focusFirstEmptyAfterPageLoads(){var A=arguments;addEvent(window,"load",function(){focusFields(A)})}function focusFirstEmpty(){var A=arguments;focusFields(A)}function focusFields(B){var A=B.length,D,C,E;for(D=0;D<A;D++){C=null;E=$(B[D]);if(null!=E){if(E.style.display!="none"&&E.style.visibility!="hidden"){if("text"==E.type||"password"==E.type){C=E.value}else{if("textarea"==E.type){C=E.innerHTML}}if(null!=C){if(""==C){try{E.focus()}catch(E){}break}}}}}}function focusAfterPageLoads(A){addEvent(window,"load",function(){try{$(A).focus()}catch(B){}})};function AjaxActivityRenderer(){this._signature=0;this._elements=[]}AjaxActivityRenderer.prototype.start=function(C){this._elements.push(C);YAHOO.util.Dom.addClass(C,"ajax-activity-pending");var B=++this._signature,D=this,A=function(){if(B==D._signature){YAHOO.util.Dom.replaceClass(D._elements,"ajax-activity-pending","ajax-activity")}};window.setTimeout(A,500)};AjaxActivityRenderer.prototype.stop=function(){++this._signature;YAHOO.util.Dom.removeClass(this._elements,"ajax-activity-pending|ajax-activity");this._elements=[]};function StarRating(A,C,I,B,O,J,G){this.id=A;this.numStars=C;this.onChangeFn=I||null;this.onChangeFnData=B||null;this.scope=O||null;this.descriptionID=J;this.descriptionList=G;var N=document.getElementById(A);var H="";var F;var D=document.createElement("span");D.className="stars-js";var L=this.getValue();var K='<img src="images/blank.gif" style="width:8px" alt=""/>';var M='<img src="images/blank.gif" style="width:14px" alt=""/>';for(F=0;F<=C*2;++F){a=document.createElement("a");a.href="javascript:void(0)";a.id=A+"_"+F;addEvent(a,"mouseover",this.onSelectStar.bind(this,F));addEvent(a,"focus",this.onSelectStar.bind(this,F));addEvent(a,"click",this.onClickStar.bind(this,F));if(F>0){a.innerHTML=K;var E=a.firstChild;if(F%2==1){E.className=(F<=L?"star-left-on":"star-left-off")}else{E.className=(F<=L?"star-right-on":"star-right-off")}}else{a.innerHTML=M;var E=a.firstChild;E.className="remove"}D.appendChild(a)}N.appendChild(D);desc=document.createElement("span");desc.id=A+"_description";desc.className="rating-description";N.appendChild(desc);addEvent(N,"mouseout",this.onDeselect.bind(this,false));addEvent(N,"blur",this.onDeselect.bind(this,false));addEvent(N,"mousemove",this.onMouseMove.bind(this))}StarRating.prototype.hoverSelection=null;StarRating.prototype.isFlashing=false;StarRating.prototype.isEnabled=true;StarRating.prototype.getValue=function(){return this._getInputElem().value};StarRating.prototype.setValue=function(B){var A=this.getValue();this._getInputElem().value=B;this.updateStars();if(B>0){this.showRemoveIcon(true)}this.flash(1);if(B!=A){if(this.onChangeFn){if(this.scope){this.onChangeFn.call(this.scope,B,this.onChangeFnData)}else{this.onChangeFn(B,this.onChangeFnData)}}}};StarRating.prototype.setEnabled=function(A){this.isEnabled=A};StarRating.prototype.flash=function(A){if(A==5){return }this.isFlashing=((A&1)==1);this.updateStars();var B=this;++A;setTimeout(function(){B.flash(A)},100)};StarRating.prototype._getInputElem=function(){return $(this.id+"_sel")};StarRating.prototype._getLinkElem=function(A){return $(this.id+"_"+A)};StarRating.prototype.onMouseMove=function(A){if(this.isEnabled){this.updateStars()}};StarRating.prototype.setDescription=function(A){desc=document.getElementById(this.descriptionID);desc.innerHTML=A};StarRating.prototype.onSelectStar=function(A,B){if(this.isEnabled){this.hoverSelection=A;if(A>=1){this.setDescription(this.descriptionList[A-1])}if(this.getValue()>0){this.showRemoveIcon(true);if(A==0){this.setDescription("Cancel Rating")}}this.updateStars()}preventEventDefault(B)};StarRating.prototype.onDeselect=function(){if(this.isEnabled){this.hoverSelection=null;this.showRemoveIcon(false);this.setDescription("");this.updateStars()}};StarRating.prototype.updateStars=function(){var B;if(this.hoverSelection!=null){B=this.hoverSelection}else{B=this.getValue()}for(var A=1;A<=this.numStars*2;++A){if(this.tracking||this.isFlashing){continue}if(A%2==1){this._getLinkElem(A).firstChild.className=(A<=B?"star-left-on":"star-left-off")}else{this._getLinkElem(A).firstChild.className=(A<=B?"star-right-on":"star-right-off")}}};StarRating.prototype.onClickStar=function(A,B){if(this.isEnabled){this.setValue(A)}preventEventDefault(B)};StarRating.prototype.showRemoveIcon=function(A){var B=$(this.id+"_0");B.className=A?"visible":""};function AnswerRatingControl(E,B,C,A){var D=new Array("Not Helpful","Not Helpful","Somewhat Helpful","Somewhat Helpful","Helpful","Helpful","Very Helpful","Very Helpful","Extremely Helpful","Extremely Helpful");StarRating.call(this,E,B,this._onChange,C,this,A,D)}AnswerRatingControl.prototype=StarRating.prototype;AnswerRatingControl.prototype._ajax_activity=new AjaxActivityRenderer();AnswerRatingControl.prototype._onChange=function(B,C){B=B/2;var A="answer_id="+C+"&rating="+B,D={success:this._onSuccess,failure:this._onFailure,scope:this,argument:{numStars:B,answer_id:C}};YAHOO.util.Connect.asyncRequest("POST","/ajax/rate.answer.html",D,A);this._ajax_activity.start(this.id);this.setEnabled(false)};AnswerRatingControl.prototype._onSuccess=function(A){var C=false,D,E,B;if(A.responseText!==undefined){D=YAHOO.lang.JSON.parse(A.responseText);if(D.is_success){E="answer-"+A.argument.answer_id+"-rating-section";YAHOO.util.Dom.removeClass(E,"multiple-ratings|single-rating|no-rating|user-rated|not-user-rated");YAHOO.util.Dom.addClass(E,(A.argument.numStars>0?"user-rated":"not-user-rated"));if(D.TotalRatings>1){YAHOO.util.Dom.addClass(E,"multiple-ratings")}else{if(D.TotalRatings==1){YAHOO.util.Dom.addClass(E,"single-rating")}else{YAHOO.util.Dom.addClass(E,"no-rating")}}B=document.getElementById("answer-"+A.argument.answer_id+"-rate-counter");if(B){while(B.hasChildNodes()){B.removeChild(B.firstChild)}B.appendChild(document.createTextNode(D.TotalRatings))}this._ajax_activity.stop();this.setEnabled(true);C=true}}if(!C){this._onFailure(A)}};AnswerRatingControl.prototype._onFailure=function(A){document.getElementById("rate_form_answer_id").value=A.argument.answer_id;document.getElementById("rate_form_rating").value=A.argument.numStars;document.getElementById("rate_form").submit()};var page_message_box_container_id=null;var page_message_box=null;function init_page_message_box(A){page_message_box_container_id=A}function remove_page_message_box(){if(page_message_box!==null){page_message_box.hide();page_message_box.destroy();page_message_box=null}}function display_page_message_box(A,E,F,D,C,B){remove_page_message_box();if(!C){C="300px"}if(!B){B=remove_page_message_box}page_message_box=new YAHOO.widget.SimpleDialog(A,{width:C,fixedcenter:true,visible:false,draggable:false,close:true,text:E,icon:D,modal:true,constraintoviewport:true,buttons:[{text:"OK",handler:B}]});page_message_box.setHeader(F);if(page_message_box_container_id!==null){page_message_box.render(page_message_box_container_id)}else{page_message_box.render(document.body)}page_message_box.show()}function display_ajax_error(B,A){display_page_message_box("error_msgbox_id","<span id='error_msg'>"+B+"</span>","Action Failed.",YAHOO.widget.SimpleDialog.ICON_BLOCK,A)}function display_page_confirm_dialog(F,H,E,D,A,I,C,G,B){remove_page_message_box();if(!B){B="300px"}if(!I){I=remove_page_message_box}if(!G){G=remove_page_message_box}page_message_box=new YAHOO.widget.SimpleDialog(F,{width:B,fixedcenter:true,visible:false,modal:true,constraintoviewport:true,draggable:false,text:H,icon:D,buttons:[{text:A,handler:I},{text:C,handler:G,isDefault:true}]});page_message_box.setHeader(E);if(page_message_box_container_id!==null){page_message_box.render(page_message_box_container_id)}else{page_message_box.render(document.body)}page_message_box.show()};function set_menu_link_enabled(B,A){if(A){YAHOO.util.Dom.removeClass(B,"disabled-anchor")}else{YAHOO.util.Dom.addClass(B,"disabled-anchor")}}function is_menu_link_enabled(A){return !YAHOO.util.Dom.hasClass(A,"disabled-anchor")}function set_menu_link_ajax_activity(B,A){if(A){YAHOO.util.Dom.addClass(B,"ajax-activity")}else{YAHOO.util.Dom.removeClass(B,"ajax-activity")}}function show_menu_link_menu(B,A){if(is_menu_link_enabled(B)){var C=new YAHOO.widget.Menu("menucontainer",{context:[B,"tl","bl"],constraintoviewport:false});C.addItems(A);C.subscribe("show",C.focus);C.subscribe("hide",function(){C.hide();window.setTimeout(function(){C.destroy()},20)});C.render("m"+B);C.show()}};function cancel_deferred_ajax_activity_indicator(A){if(A.ajax_activity_timer){window.clearTimeout(A.ajax_activity_timer);A.ajax_activity_timer=false}}function submit_flag_object_request_completed(A){set_menu_link_enabled(A.argument.flag_request_param.container_id,true);set_menu_link_ajax_activity(A.argument.flag_request_param.container_id,false);cancel_deferred_ajax_activity_indicator(A.argument.flag_request_param)}function set_flag_link_text(A,B){var C=document.getElementById(A);while(C.firstChild){C.removeChild(C.firstChild)}C.appendChild(document.createTextNode(B))}function submit_flag_object_request_success(A){submit_flag_object_request_completed(A);if(A.responseText!==undefined){var B=YAHOO.lang.JSON.parse(A.responseText);if(B.is_error){handle_flag_object_ajax_error(B,A.argument.flag_request_param)}else{set_flag_link_text(A.argument.flag_request_param.container_id,A.argument.flag_request_param.flag_type.FlagName);set_menu_link_enabled(A.argument.flag_request_param.container_id,false);display_flag_object_completed()}}}function submit_flag_object_request_failure(A){submit_flag_object_request_completed(A);display_ajax_error("Operation failed.")}function submit_flag_relogin_failure(A){display_ajax_error(A.argument.error_message)}function submit_flag_relogin_success(A){var C=true,B;if(A.responseText!==undefined){B=YAHOO.lang.JSON.parse(A.responseText);if(B.redirect_url){window.location=B.redirect_url;C=false}}if(C){submit_flag_relogin_failure(A)}}function handle_flag_object_ajax_error(A,C){if(A.redirect_url){if(A.is_relogin){var D={success:submit_flag_relogin_success,failure:submit_flag_relogin_failure,argument:{error_message:A.error_message}},B="relogin_url="+encodeURIComponent(C.relogin_url)+"&object_id="+C.object_id+"&flag_type_id="+C.flag_type.FlagTypeID;YAHOO.util.Connect.asyncRequest("POST","/ajax/flag.exception.html",D,B)}else{window.location=A.redirect_url}}else{display_ajax_error(A.error_message)}}function display_flag_object_completed(){display_page_message_box("flag_completed_msgbox_id","<span id='flag_success_msg'>Thank you for flagging this content.<br /> The akatoo team will look at this content shortly and take appropriate action.</span>","Action Completed.",YAHOO.widget.SimpleDialog.ICON_INFO)}function create_flag_ajax_activity_handler(A){return function(){A.ajax_activity_timer=false;set_menu_link_ajax_activity(A.container_id,true)}}function submit_flag_object_request(B){set_menu_link_enabled(B.container_id,false);cancel_deferred_ajax_activity_indicator(B);B.ajax_activity_timer=window.setTimeout(create_flag_ajax_activity_handler(B),300);var C={success:submit_flag_object_request_success,failure:submit_flag_object_request_failure,argument:{flag_request_param:B}},A="object_id="+B.object_id+"&flag_type_id="+B.flag_type.FlagTypeID;YAHOO.util.Connect.asyncRequest("POST","/ajax/flag.object.html",C,A)}function on_flag_menu_item_click(C,A,B){YAHOO.util.Event.preventDefault(A);submit_flag_object_request(B)}function create_flag_object_menu_items(D){var E,B,A,C;if(D.can_flag&&D.flag_types){E=new Array(D.flag_types.length+1);for(B=0;B<D.flag_types.length;++B){A=D.flag_types[B];C={flag_type:A,can_flag:D.can_flag,object_id:D.object_id,relogin_url:D.relogin_url,container_id:D.container_id};E[B]={text:A.FlagName,value:A.FlagTypeID,id:"flagmenu-"+A.FlagTypeID,classname:"flag-severity-"+A.FlagSeverity,onclick:{fn:on_flag_menu_item_click,obj:C}}}E[B]={text:"What is this?",url:"/help/flagging.html",classname:"whats-this"}}else{E=[{text:"Sorry, your flagging limit has been exceeded."}]}return E}function create_flag_link(L,K,F,I,D,C){var B=null,H=false,M,G,J,A,E;if(I){for(M=0;M<I.length&&!H;++M){G=I[M];if(D==G.FlagTypeID){B=G.FlagName;H=true}}}if(H){set_flag_link_text(F,B);set_menu_link_enabled(F,false)}A={flag_types:I,can_flag:L,object_id:K,relogin_url:C,container_id:F};E=function(N){YAHOO.util.Event.preventDefault(N);J=create_flag_object_menu_items(A);show_menu_link_menu(F,J)};YAHOO.util.Event.addListener(F,"click",E)};function synchNonProfit(){synchNonProfit2("")}function synchNonProfit2(B){var C=document.getElementById("answer_non_profit"+B);var A=document.getElementById("answer_chk_donate"+B);if(C&&A){C.disabled=!A.checked}}function show_answer_div(){var A=document.getElementById("answer_text");if(A){try{A.focus()}catch(B){}}}function do_delete(A){var B=document.getElementById("delete_answer_id");if(B){B.setAttribute("value",A)}YAHOO.akatoo.app.delete_dialog.show();return false}function init_delete_dialog(B){var A=function(){window.beforeunload=null;this.submit()};var C=function(){this.cancel()};YAHOO.akatoo.app.delete_dialog=new YAHOO.widget.Dialog(B,{width:"36em",fixedcenter:true,visible:false,modal:true,constraintoviewport:true,postmethod:"form",hideaftersubmit:true,buttons:[{text:"Yes",handler:A,isDefault:true},{text:"No",handler:C}]});YAHOO.akatoo.app.delete_dialog.render();YAHOO.util.Dom.removeClass(B,"nodisplay")}function show_edit_control(A){answer_display=document.getElementById("answer_display_"+A);answer_edit=document.getElementById("answer_edit_"+A);YAHOO.util.Dom.removeClass(answer_display,"displayed_answer");YAHOO.util.Dom.addClass(answer_display,"hidden_answer");YAHOO.util.Dom.removeClass(answer_edit,"hidden_answer");YAHOO.util.Dom.addClass(answer_edit,"displayed_answer")}function show_replace_dialog(C){remove_page_message_box();var B=function(){remove_page_message_box();if(C!=null){document.forms["edit_form"+C].action.value="replace_answer";document.forms["edit_form"+C].submit()}};var A=function(){remove_page_message_box()};display_page_confirm_dialog("warning_dialog","You've changed your answer substantially.  If you post these changes, users\nwho have already rated this answer will be able to rate it again.  (Any rating\npoints gained or lost for your old answer will still contribute to your IKU.)\nAre you sure you want to replace your old answer with this one?","Replace Answer",YAHOO.widget.SimpleDialog.ICON_INFO,"Yes, replace my answer",B,"No, keep my old answer",A,"600px");return false}function handle_ajax_error(A){if(A.redirect_url){window.location=A.redirect_url}else{display_ajax_error(A.error_message)}}function compare_answer_request_success(A){if(A.responseText!==undefined){answer_id=A.argument.answer_id;document.getElementById("edit_answer_text"+answer_id).disabled=false;var B=YAHOO.lang.JSON.parse(A.responseText);if(B.is_error){handle_ajax_error(B)}else{if(B.is_similar==1){document.forms["edit_form"+answer_id].submit()}else{show_replace_dialog(answer_id)}}}}function try_edit_answer(B){var E=document.getElementById("edit_answer_text"+B);E.disabled=true;var A="new_answer="+E.value+"&answer_id="+B;var D={success:compare_answer_request_success,failure:submit_flag_object_request_failure,argument:{answer_id:B}};var C=YAHOO.util.Connect.asyncRequest("POST","/ajax/compare.answer.html",D,A)}function create_change_answer_menu_items(A){return[{text:"Delete answer",id:"flagmenu-4",classname:"flag-severity-delete",onclick:{fn:function(){do_delete(A)}}},{text:"Edit answer",id:"flagmenu-edit",onclick:{fn:function(){show_edit_control(A)}},classname:"flag_severity_edit"},{text:"What is this?",url:"/help/changing.html",classname:"whats-this"}]}function create_edit_answer_link(C,B){var D=function(F){YAHOO.util.Event.preventDefault(F);var E=create_change_answer_menu_items(B);show_menu_link_menu(C,E)};YAHOO.util.Event.addListener(C,"click",D);synchNonProfit2(B);var A=function(){synchNonProfit2(B)};YAHOO.util.Event.addListener("answer_chk_donate"+B,"click",A)}function init_recategorize_dialog(B){var A=function(){window.beforeunload=null;this.submit()};var C=function(){this.cancel()};YAHOO.akatoo.app.recategorize_dialog=new YAHOO.widget.Dialog(B,{width:"36em",fixedcenter:true,visible:false,modal:true,constraintoviewport:true,postmethod:"form",hideaftersubmit:true,buttons:[{text:"Recategorize",handler:A,isDefault:true},{text:"Cancel",handler:C}]});YAHOO.akatoo.app.recategorize_dialog.render();YAHOO.util.Dom.removeClass(B,"nodisplay")}function show_recategorize_dialog(){YAHOO.akatoo.app.recategorize_dialog.show();return false};function toggle_signing(A){if(A=="Sign Up"){YAHOO.util.Dom.addClass("inline_sign_up","visible_question");YAHOO.util.Dom.removeClass("inline_sign_up","hidden_question");YAHOO.util.Dom.addClass("inline_sign_in","hidden_question");YAHOO.util.Dom.removeClass("inline_sign_in","visible_question");YAHOO.util.Dom.addClass("inline_anon","hidden_question");YAHOO.util.Dom.removeClass("inline_anon","visible_question")}else{if(A=="Sign In"){YAHOO.util.Dom.addClass("inline_sign_up","hidden_question");YAHOO.util.Dom.removeClass("inline_sign_up","visible_question");YAHOO.util.Dom.addClass("inline_sign_in","visible_question");YAHOO.util.Dom.removeClass("inline_sign_in","hidden_question");YAHOO.util.Dom.addClass("inline_anon","hidden_question");YAHOO.util.Dom.removeClass("inline_anon","visible_question")}else{if(A=="anon"){YAHOO.util.Dom.addClass("inline_sign_up","hidden_question");YAHOO.util.Dom.removeClass("inline_sign_up","visible_question");YAHOO.util.Dom.addClass("inline_sign_in","hidden_question");YAHOO.util.Dom.removeClass("inline_sign_in","visible_question");YAHOO.util.Dom.addClass("inline_anon","visible_question");YAHOO.util.Dom.removeClass("inline_anon","hidden_question")}}}};dates={_month_names:["???","Jan.","Feb.","Mar.","Apr.","May.","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."],_getMonthNameShort:function(A){var B=A.getMonth()+1;if(B<=0||B>this._month_names.length){B=0}return this._month_names[B]},formatMDY:function(F,A){var C=document.getElementById(F),D,G,E,B,H,I;if(C){D=new Date(A*1000);while(C.hasChildNodes()){C.removeChild(C.firstChild)}G=this._getMonthNameShort(D);I=D.getDate();C.appendChild(document.createTextNode(G+" "+I));switch(I){case 1:E="st";break;case 2:E="nd";break;case 3:E="rd";break;case 21:E="st";break;case 22:E="nd";break;case 23:E="rd";break;case 31:E="st";break;default:E="th";break}B=document.createElement("sup");B.appendChild(document.createTextNode(E));C.appendChild(B);H=D.getFullYear();C.appendChild(document.createTextNode(", "+H))}return C},deferFormatMDY:function(A,B){YAHOO.util.Event.onContentReady(A,function(){this.formatMDY(A,B)},this,true)},formatShortMDY:function(B,E){var F=document.getElementById(B),C,G,A,D;if(F){C=new Date(E*1000);while(F.hasChildNodes()){F.removeChild(F.firstChild)}G=C.getMonth()+1;if(G<10){G="0"+G}A=C.getDate();if(A<10){A="0"+A}D=C.getFullYear();F.appendChild(document.createTextNode(G+"."+A+"."+D))}},deferFormatShortMDY:function(A,B){YAHOO.util.Event.onContentReady(A,function(){this.formatShortMDY(A,B)},this,true)}};question_page_model={QUESTION_RATED_EVENT:new YAHOO.util.CustomEvent("question rated",this,true,YAHOO.util.CustomEvent.FLAT)};function update_stars(G,B,E){var D=document.getElementById(G);if(D){var C=D.style.width.replace(/^(\d+).*$/,"$1"),A=C*E/B,F=document.getElementById(G+"-scale");if(F){F.style.width=A+"px"}}};function QuestionRatingInfo(B,A){this._id=B;A.subscribe(this._onRated,this,true)}QuestionRatingInfo.prototype._onRated=function(A){var B="no-rating";if(A.CommunityQuestionRatingTypeID){B="has-rating-type-"+A.CommunityQuestionRatingTypeID;if(A.ShowCommunityRating){B+=" has-rating"}}YAHOO.util.Dom.removeClass(this._id,"has-rating-type-(?:[0-9]+)|has-rating|no-rating");YAHOO.util.Dom.addClass(this._id,B);update_stars(this._id+"-stars",5,A.CommunityQuestionRating)};var subcategory_cache=[],pending_subcategory_request_cache=[],last_requested_category_id,category_selector_change_event;function init_category_selection(C,B){subcategory_cache=C;category_selector_change_event=new YAHOO.util.CustomEvent("category selector change");category_selector_change_event.signature=YAHOO.util.CustomEvent.FLAT;for(var A=0;A<B;++A){YAHOO.util.Event.addListener(get_category_combo_id(A),"change",on_category_selected,A)}}function subscribe_category_change(B,A){category_selector_change_event.subscribe(B,A)}function get_category_combo_id(A){return"category_"+A}function on_category_selected(K,C){var B=document.getElementById(get_category_combo_id(C)),N=B.selectedIndex,E=B.options[N].value,H=B.options[N].getAttribute("has_subcategory"),M=B.parentNode,D,A,I,G,F,J,L;while(B.nextSibling){M.removeChild(B.nextSibling)}if(E&&E!="0"&&H&&H!="0"){D=document.createElement("span");D.innerHTML="&rarr;";D.className="combo_sep";M.appendChild(D);A=subcategory_cache[E];if(A){render_subcategories(A,C+1)}else{D=document.createElement("span");D.setAttribute("id","category_loading");I=document.createTextNode("Loading...");D.appendChild(I);M.appendChild(D);send_request_get_subcategories(E,C+1)}}G=E;F=C;while(G==0&&--F>=0){J=document.getElementById(get_category_combo_id(F));L=J.selectedIndex;G=J.options[L].value}category_selector_change_event.fire(G)}function remove_category_loading(B){var D=document.getElementById("category_loading"),C,A;if(D){C=D.parentNode;if(B){while(D.childNodes[0]){D.removeChild(D.childNodes[0])}A=document.createTextNode(B);D.appendChild(A)}else{C.removeChild(D)}}}function append_category_combo_item(E,D,F,C){var B=document.createElement("option"),A;B.setAttribute("value",D);B.setAttribute("has_subcategory",C);A=document.createTextNode(F);B.appendChild(A);E.appendChild(B)}function render_subcategories(G,B){var C=document.getElementById("category_list"),E=document.createElement("select"),F=get_category_combo_id(B),A,D;E.setAttribute("id",F);E.setAttribute("name",F);append_category_combo_item(E,0,"<Optional Subcategory>","0");for(A=0;A<G.length;++A){D=G[A];append_category_combo_item(E,D.CategoryID,D.Name,D.HasSubcategories)}YAHOO.util.Event.addListener(E,"change",on_category_selected,B);C.appendChild(E)}function send_request_get_subcategories_success(A){if(A.responseText!==undefined){var B=YAHOO.lang.JSON.parse(A.responseText),D,C;if(!B.is_success){send_request_get_subcategories_failure(A)}else{D=B.nodes;C=A.argument.category_id;subcategory_cache[C]=D;if(C==last_requested_category_id){last_requested_category_id=0;pending_subcategory_request_cache.splice(C,1);remove_category_loading();render_subcategories(D,A.argument.category_level)}}}}function send_request_get_subcategories_failure(A){if(A.argument.category_id==last_requested_category_id){last_requested_category_id=0;pending_subcategory_request_cache.splice(A.argument.category_id,1);remove_category_loading("Failed!")}}function send_request_get_subcategories(C,B){last_requested_category_id=C;if(!pending_subcategory_request_cache[C]){pending_subcategory_request_cache[C]=C;var A="category_id="+C,D={success:send_request_get_subcategories_success,failure:send_request_get_subcategories_failure,argument:{category_level:B,category_id:C}};YAHOO.util.Connect.asyncRequest("POST","/ajax/category.info.html",D,A)}};function QuestionRatingControl(B,D,C,G,F,E,A,H){var I=new Array("Trivial","Trivial","Simplistic","Simplistic","Reasonable","Reasonable","Interesting","Interesting","Insightful","Insightful");this._id=B;this._has_rating_types=E;this._selected_rating_type_id=F;this._selected_rating=G;this._question_id=C;this._event=A;if(this._has_rating_types.length==0){this._stars=null}else{this._stars=new StarRating(B+"-stars",D,this._onStarChange,null,this,H,I)}YAHOO.util.Event.addListener(B,"click",this._onClick,this,true)}QuestionRatingControl.prototype._ajax_activity=new AjaxActivityRenderer();QuestionRatingControl.prototype._signature=1;QuestionRatingControl.prototype._onClick=function(E){var C=YAHOO.util.Event.getTarget(E),D,F,B=false,A;D=C.id.match(new RegExp(this._id+"-type-(\\d+)"));if(D!=null){this._selected_rating_type_id=D[1];if(this._has_rating_types.length>0){B=false;for(F=0;F<this._has_rating_types.length&&!B;++F){B=this._has_rating_types[F]==this._selected_rating_type_id}A=this._id+"-stars-container";if(B){YAHOO.util.Dom.removeClass(A,"nodisplay")}else{YAHOO.util.Dom.addClass(A,"nodisplay")}}this._update(B)}};QuestionRatingControl.prototype._onStarChange=function(A){this._selected_rating=A/2;this._update(true)};QuestionRatingControl.prototype._enableStars=function(A){if(this._stars){this._stars.setEnabled(A)}};QuestionRatingControl.prototype._update=function(B){var A="question_id="+this._question_id+"&rating_type_id="+this._selected_rating_type_id,C={success:this._onSuccess,failure:this._onFailure,scope:this,argument:{signature:++this._signature,rating_type_id:this._selected_rating_type_id,rating:0}};if(B&&this._selected_rating){A+="&rating="+this._selected_rating;C.argument.rating=this._selected_rating}YAHOO.util.Connect.asyncRequest("POST","/ajax/rate.question.html",C,A);this._enableStars(false);this._ajax_activity.start(this._id)};QuestionRatingControl.prototype._updateUI=function(A){if(A==this._signature){++this._signature;this._ajax_activity.stop();this._enableStars(true)}};QuestionRatingControl.prototype._onSuccess=function(A){if(A.responseText!==undefined){this._updateUI(A.argument.signature);var B=YAHOO.lang.JSON.parse(A.responseText);if(!B.is_success){this._onFailure(A)}else{this._event.fire(B)}}else{this._onFailure(A)}};QuestionRatingControl.prototype._onFailure=function(A){document.getElementById("rate_form_action").value="rate_question";document.getElementById("rate_form_rating").value=A.argument.rating;document.getElementById("rate_form_rating_type_id").value=A.argument.rating_type_id;document.getElementById("rate_form").submit()};

/* Taken with modification from Alfred's "Pica". */

var instances = new Object();


// For JS and DOM.
function Lang(){
	
	// Browser
	
		/*public*/ this.isIE = function(){
			return this.findBrowserName("MSIE");
		}
		
		/*public*/ this.isIE7OrNewer = function(){
			return (
				this.findBrowserName("MSIE 7") ||
				this.findBrowserName("MSIE 8") ||
				this.findBrowserName("MSIE 9") );
		}
		
		/*public*/ this.isIE8 = function(){
			return this.findBrowserName("MSIE 8");
		}
		
		/*public*/ this.isIE7 = function(){
			return this.findBrowserName("MSIE 7");
		}
		
		/*public*/ this.isIE6 = function(){
			return this.findBrowserName("MSIE 6");
		}
		
		/*public*/ this.isIE6OrOlder = function(){
			return (
				this.findBrowserName("MSIE 6") ||
				this.findBrowserName("MSIE 5") ||
				this.findBrowserName("MSIE 4") );
		}
		
		/*public*/ this.isFirefox = function(){
			return this.findBrowserName("Firefox");
		}
		
		/*public*/ this.isSafari = function(){
			return this.findBrowserName("Safari") &&
				 ! this.findBrowserName("Chrome") ;
		}
		
		/*public*/ this.isChrome = function(){
			return this.findBrowserName("Chrome");
		}
		
		/*private*/ this.findBrowserName = function(/*string*/ text){
			var nav = navigator.userAgent ;
			return -1 != nav.indexOf( text ) ;
		}
		
	// Window
	
		/*public*/ this.getWindowWidth = function(){
			return window.innerWidth ? 
				window.innerWidth : 
				document.body.clientWidth ;
		}
		
		/*public*/ this.getWindowHeight = function(){
			return window.innerHeight ? 
				window.innerHeight : 
				document.body.clientHeight ;
		}
		
		/*public*/ this.getWindowScrollY = function(){
			var out = 0;
			if( lang.isIE() ){
				//document.compatMode;
				//out = document.documentElement.scrollTop;
				out = lang.b().scrollTop;
			}
			else out = lang.w().scrollY;
			return out;
		}
		
		/*public*/ this.getWindowScrollX = function(){
			var out = 0;
			if( lang.isIE() ){
				//document.compatMode;
				//out = lang.d().documentElement.scrollLeft; 
				out = lang.b().scrollLeft;
			}
			else out = lang.w().scrollX;
			return out;
		}
		
		/*public*/ this.center = function(/*Element*/ e){
			
			var wx = lang.getWindowScrollX();
			var wy = lang.getWindowScrollY();
			var ww = lang.getWindowWidth();
			var wh = lang.getWindowHeight();
			var ew = lang.getW( e );
			var eh = lang.getH( e );
			if( lang.isIE() ){
				// caution: may need to change if
				// not in IE Quirks mode.
				lang.setL( e, wx + ((ww-ew)/2) );
				lang.setT( e, wy + ((wh-eh)/2) );
			}
			else{
				lang.setL( e, wx + ((ww-ew)/2) );
				lang.setT( e, wy + ((wh-eh)/2) );
			}
		}
	
	// Common Elements.
	
		/*public*/ this.w = function(){ 
			return window; 
		}
		
		/*public*/ this.d = function(){ 
			return document; 
		}
		
		/*public*/ this.b = function(){ 
			return this.d().body; 
		}
		
		/*public*/ this.e = function( /*string*/ id ){ 
			var e = this.d().getElementById(id);
			if( !e ){
				var elms = this.d().getElementsByName(id);
				if( elms )
					if( elms.length )
						e = elms[0];
			}
			
			return e;
		}

	// Element ID's.
		
		/*private*/ this.defaultID = 0;
		
		/*public*/ this.id = function( /*Element*/ e ){ 
			if( e ){
				if( ! e.id ) 
					e.id = "ELEMENT" + (lang.defaultID++) ;
				return e.id;
			}
			return null;
		}
		
		/*public*/ this.getIDIndex = function( /*string*/ id, /*int*/ pos ){
			var a = 0;
			for(var p=0; p<=pos; p++){
				a = id.indexOf("[", a);
				if( -1 == a ) return -1;
				a += 1;
			}
			var b = id.indexOf("]", a);
			return lang.int( id.substr(a, b-a) );
		}
		
	// Creating new elements.
	
		/*public*/ this.newElement = function( /*string*/ tag ){ 
			return this.d().createElement(tag); 
		}
		
		/*public*/ this.newDiv	= function(){
			return this.newElement("div"); 
		}
		
		/*public*/ this.newScript = function(){ 
			return this.newElement("script"); 
		}
		
		/*public*/ this.newStyle = function(){ 
			return this.newElement("style"); 
		}
		
		/*public*/ this.newStyleSheet = function(){ 
			return this.newElement("styleSheet"); 
		}
		
		/*public*/ this.newLink = function(){ 
			return this.newElement("link"); 
		}
		
		/*public*/ this.newImg = function(){
			return this.newElement("img"); 
		}
	
	// Text
	
		/*public*/ this.setText	= function( /*Element*/ e, /*string*/ text ){ 
			var tag = e.tagName.toUpperCase();
			if( 	 tag == "INPUT" 	){ e.value = text; }
			else if( tag == "IMG"   	){ e.src   = text; }
			else if( tag == "TEXTAREA"	){ e.value = text; e.innerHTML = text; } // For Firefox & IE.
			else /*last attempt*/		 { e.innerHTML = text; }			
		}
		
		/*public*/ this.getText	= function( /*Element*/ e ){
			var tag = e.tagName.toUpperCase();
			if( 	 tag == "INPUT" 	){ 
				var t = e.type;
				if( "checkbox" == t ){
					if( e.checked ) return "on";
					else return "off";
				}
				else{
					return e.value;
				}
			}
			else if( tag == "IMG"   	){ return e.src; }
			else if( tag == "TEXTAREA"	){ return e.value ? e.value : e.innerHTML ; } // For Firefox & IE.
			else /*last attempt*/		 { return e.innerHTML; }
		}
		
	// Read / ReadWrite
	
		/*public*/ this.setRead = function( /*Element*/ e ){
			if( this.isIE() )
				 e.readOnly = true;
			else e.readOnly = "yes";
		}
		
		/*public*/ this.setReadWrite = function( /*Element*/ e ){
			if( this.isIE() )
				 e.readOnly = false;
			else e.readOnly = "";
		}
	
	// Checked
	
		/*public*/ this.setChecked = function( /*Element*/ e ){
			e.checked = true;
		}
		
		/*public*/ this.setUnChecked = function( /*Element*/ e ){	
			e.checked = false;
		}
		
		/*public*/ this.isChecked = function( /*Element*/ e ){
			return ( "yes"==e.check || true==e.checked );
		}
		
	// Visibility
	
		// Fixies IE visibility problems.
		/*public*/ this.show = function( /*Element*/ e, /*int*/ msBegin ){ 
			var id = lang.id(e);
			if( ! lang.isShown(e) ){
				if( msBegin )
					setTimeout( "lang.setL(lang.e('"+id+"'), lang.getL(lang.e('"+id+"')) + 10000);", msBegin);
				else
					lang.setL(e, lang.getL(e) + 10000 );
			}
		}
		
		/*public*/ this.hide = function( /*Element*/ e, /*int*/ msBegin ){ 
			var id = lang.id(e);
			if( lang.isShown(e) ){
				if( msBegin )
					setTimeout( "lang.setL(lang.e('"+id+"'), lang.getL(lang.e('"+id+"')) - 10000);", msBegin);
				else
					lang.setL(e, lang.getL(e) - 10000 );
			}
		}
		
		/*public*/ this.isShown = function( /*Element*/ e ){
			return ( -1000 < lang.getL(e) ) ;
		}
		
	// Opacity
	
		/*public*/ this.setOpacity = function( /*Element*/ e, /*float*/ alpha ){ 
			e.style.opacity=alpha; 
			e.style.filter = "alpha(opacity = " + 
				(alpha*100) + ")"; 
		}
		
		/*public*/ this.getOpacity = function( /*Element*/ e ){ 
			var o = e.style.opacity ? 
				e.style.opacity : e.style.filter ;
			if( !o ) o = -1;
			return this.float(o); 
		}
		
		/*public*/ this.fade = function( /*Element*/ e, /*float*/ alphaFrom, /*float*/ alphaTo, /*int*/ msBegin ){
			var id = lang.id(e);
			if( ! msBegin ) msBegin = 0;
			setTimeout("lang.fadeStep(lang.e('"+id+"'), "+alphaFrom+", "+alphaTo+");", msBegin);
		}
		
		/*private*/ this.fadeStep = function( /*Element*/ e, /*float*/ alphaFrom, /*float*/ alphaTo){
			if( e ){
				var id = lang.id(e);
				var ms = 100;
				var dt = alphaTo - alphaFrom;
				if( dt ){
					var a = alphaFrom ;
					if( alphaFrom < alphaTo ){
						
						a += 0.1;
						
						if( alphaTo < a ) a = alphaTo;
					}
					else{
						a -= 0.1;
						if( a > alphaFrom ) a = alphaFrom;
					}
					lang.setOpacity(e, a);
					if( a!=alphaFrom && a!=alphaTo ){
						alphaFrom = a;
						setTimeout("lang.fadeStep(lang.e('"+id+"'), "+alphaFrom+", "+alphaTo+");", 25);
					}
					else{ // Hack to fix an IE opacity bug
						if( 1 == lang.getOpacity(e) )
							if( e.style.filter )
								e.style.filter = "";
					}
				}
			}
		}
	
	// Event Handling.
	
		/*public*/ this.onEvent = function( /*Element*/ e, /*string*/ evt, /*Function*/ f ){ 
			// Hook 'em up!
			if( null != e && undefined != e ){
				if( e.addEventListener )
					 e.addEventListener(evt, f, false); 
				else e.attachEvent( "on" + evt, f );
			}
		}
		
		/*public*/ this.onLoad = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'load', f); 
		}
		
		/*public*/ this.onClick = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'click', f); 
		}	
		
		/*public*/ this.onDblClick = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'dblclick', f); 
		}	
		
		/*public*/ this.onMouseOver = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'mouseover', f); 
		}	
		
		/*public*/ this.onMouseOut = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'mouseout', f); 
		}	
		
		/*public*/ this.onMouseDown = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'mousedown', f); 
		}	
		
		/*public*/ this.onMouseUp = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'mouseup', f); 
		}	
		
		/*public*/ this.onFocus = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'focus', f); 
		}	
		
		/*public*/ this.onBlur = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'blur', f); 
		}
		
		/*public*/ this.onKeyDown = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'keydown', f); 
		}
		
		/*public*/ this.onKeyUp = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'keyup', f);
		}
		
		/*public*/ this.onType = function( /*Element*/ e, /*Function*/ f ){ 
			this.onEvent(e, 'keyup', f);
		}
		
		/*public*/ this.onChange = function( /*Element*/ e, /*Function*/ f ){
			this.onEvent(e, 'change', f);
		}
		
		/*public*/ this.onScroll = function( /*Element*/ e, /*Function*/ f ){
			this.onEvent(e, 'scroll', f);
		}
		
		/*public*/ this.target = function( /*Event*/   v ){ 
			return (v.target ? v.target : v.srcElement) ; 
		}
		
		// To revisit.
		/*public*/ this.originalTarget = function( /*Event*/ v ){
			return (v.originalTarget ? v.originalTarget : v.srcElement) ; 
		}
		
	// Casts.
	
		/*public*/ this.int = function( /*string*/ txt ){ 
			return parseInt(txt, 10); 
		}
		
		/*public*/ this.float = function( /*string*/ txt ){ 
			return parseFloat(txt, 10); 
		}
	
	// Positioning.
	
		/*public*/ this.getL = function( /*Element*/ e ){ 
			return this.int( e.style.left 	); 
		}
		
		/*public*/ this.getR = function( /*Element*/ e ){ 
			return this.int( e.style.right ); 
		}
		
		/*public*/ this.getT = function( /*Element*/ e ){ 
			return this.int( e.style.top 	); 
		}
		
		/*public*/ this.getB = function( /*Element*/ e ){ 
			return this.int( e.style.bottom ); 
		}
		
		/*public*/ this.getW = function( /*Element*/ e ){ 
			return this.int( e.style.width 	); 
		}
		
		/*public*/ this.getH = function( /*Element*/ e ){ 
			return this.int( e.style.height 	); 
		}
		
		/*public*/ this.getScreenL = function(/*Element*/ e){
			var l=0;
			while(true){
				if( null==e || undefined==e ) break;
				l+=e.offsetLeft;
				e = e.offsetParent;
			}
			return l;
		}
		
		/*public*/ this.getScreenT = function(/*Element*/ e){
			var t=0;
			while(true){
				if( null==e || undefined==e ) break;
				t+=e.offsetTop;
				e = e.offsetParent;
			}
			return t;
		}
		
		/*public*/ this.getViewportL = function(/*Element*/ e){
			var l=0;
			while(true){
				if( null==e || undefined==e ) break;
				l+=(e.offsetLeft-e.scrollLeft);
				e = e.offsetParent;
			}
			return l;
		}
		
		/*public*/ this.getViewportT = function(/*Element*/ e){
			var t=0;
			while(true){
				if( null==e || undefined==e ) break;
				t+=(e.offsetTop-e.scrollTop);
				e = e.offsetParent;
			}
			return t;
		}
		
		/*public*/ this.setL = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.left = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.left = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
		
		/*public*/ this.setR = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.right = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.right = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
		
		/*public*/ this.setT = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.top = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.top = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
		
		/*public*/ this.setB = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.bottom = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.botttom = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
		
		/*public*/ this.setW = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.width = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.width = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
			
		/*public*/ this.setH = function( /*Element*/ e, /*int*/ px, /*int*/ msBegin ){ 
			if( ! msBegin ){
				e.style.height = px + "px"; 
			}
			else{
				var id = lang.id( e );
				var js = "lang.e('" + id + "').style.height = \"" + px + "px\";" ;
				setTimeout( js, msBegin );
			}
		}
		
		/*public*/ this.centerWithRespectTo = function( /*Element*/ toCenter, /*Element*/ withRespectTo ){
			var a = toCenter;
			var b = withRespectTo;
			
			var aL = lang.getL( a );
			var aT = lang.getT( a );
			var aW = lang.getW( a );
			var aH = lang.getH( a );
			
			var bL = lang.getL( b );
			var bT = lang.getT( b );
			var bW = lang.getW( b );
			var bH = lang.getH( b );
			
			lang.setL( a, bL + ((bW - aW)/2) );
			lang.setT( a, bT + ((bH - aH)/2) );
			lang.setW( a, aW );
			lang.setH( a, aH );
		}
		
	// Math.
	
		/*public*/ this.min	= function( /*number*/ lhs, /*number*/ rhs ){ 
			return Math.min( lhs, rhs ); 
		}
		
		/*public*/ this.max	= function( /*number*/ lhs, /*number*/ rhs ){ 
			return Math.max( lhs, rhs ); 
		}
		
		/*public*/ this.floor = function( /*number*/ n ){
			return Math.floor(n);
		}
		
		/*public*/ this.ceil = function( /*number*/ n ){
			return Math.ceil(n);
		}
		
		/*public*/ this.round = function( /*number*/ n ){ 
			return Math.round(n); 
		}
		
		/*public*/ this.abs	= function( /*number*/ n ){ 
			return Math.abs(n); 
		}
		
		/*public*/ this.pow = function( /*number*/ n, /*int*/ power ){
			return Math.pow(n, power);
		}
		
	// String
	
		/*public*/ this.replaceCaseSensitive = function( /*string*/ s, /*string*/ toReplace, /*string*/ replaceWith){
			return this.replace( s, toReplace, replaceWith, true );
		}
		
		/*public*/ this.replaceCaseInsensitive = function( /*string*/ s, /*string*/ toReplace, /*string*/ replaceWith){
			return this.replace( s, toReplace, replaceWith, false );
		}
		
		/*public*/ this.replace = function( /*string*/ s, /*string*/ toReplace, /*string*/ replaceWith, /*bool*/ caseSensitive){
			
			var f = caseSensitive ? "g" : "gi" ;
			if( this.isIE() ){
				var re = new RegExp( toReplace, f );
			 	s = s.replace(re, replaceWith);
			 	delete re;
		 	}
		 	else if( this.isFirefox() ){
			 	s = s.replace(toReplace, replaceWith, f);
		 	}
		 	else{
			 	var bef = s; var aft = s;
			 	for( var i=0; i<500; i++){
				 	bef = aft;
			 		aft = bef.replace( toReplace, replaceWith );
			 		if( bef == aft ) break;
		 		}
			 	s = aft;
		 	}
		 	return s;
		}
		
		/*public*/ this.strLeft = function( /*string*/ s, /*int*/ chars ){
			return s.substr(0, chars);
		}
		
		/*public*/ this.strRight = function( /*string*/ s, /*int*/ chars ){
			var l = this.strLength(s);
			var s = this.max( l-chars, 0 );
			return s.substr(s);
		}
		
		/*public*/ this.strLength = function( /*string*/ s ){
			return s.length;
		}
		
		/*public*/ this.strMid = function( /*string*/ s, /*int*/ start, /*int*/ chars ){
			if( chars ) return s.substr(start, chars);
			else return s.substr(start);
		}
		
		/*public*/ this.strToUpper = function(/*string*/ s){
			return s.toUpperCase();
		}
		
		/*public*/ this.strToLower = function(/*string*/ s){
			return s.toLowerCase();
		}
		
	// Ajax.
	
		/*public*/ this.sendAjax = function(/*string*/ method, /*string*/ url, /*Object*/ params, /*function*/ clbSuccess, /*function*/ clbFailure){
			var req = this.getAjaxRequest();
			req.onreadystatechange = function(){ 
			    if (req.readyState == 4) {
			        if (req.status == 200) {
			            if( clbSuccess ) clbSuccess(req.responseText);
			        } else {
				        //alert("There was a problem retrieving the XML data:\n" + req.statusText + "/" + req.responseText);
				        if( clbFailure ) clbFailure(req.responseText);
			            
			        }
			    }
			};			
			
			var body = "";
			for( key in params ){
				var val = params[key];
				if( body ) body += "&";
				body += key + "=" + encodeURI(val) ;
			}
			req.open("POST", url + "?" + body, true); // true means asynch, false means synch
			req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			req.send(body);
		}
		
		/*private*/ this.getAjaxRequest = function(){
			var req = null;
			if( this.isIE() ){
				try{ req = new ActiveXObject("Msxml2.XMLHTTP"); }
				catch(e){
				    try{ req =new ActiveXObject("Microsoft.XMLHTTP"); }
				    catch(e){}
				}
			}
			else{
				try{ req = new XMLHttpRequest(); }
				catch(e){}
			}
			return req;
		}
		
	// Date And Time.
		
		/*public*/ this.now = function(){
			var now = new Date();
			var nowMs = now.getTime();
			delete now;
			return nowMs;
		}
	
	// MsgBox
	
		/*public*/ this.msgBox = function( /*string*/ s0, /*string*/ s1, /*string*/ s2, /*string*/ s3, /*string*/ s4, /*string*/ s5, /*string*/ s6, /*string*/ s7, /*string*/ s8, /*string*/ s9 ){
			alert( "[" + s0 + "]\n[" + s1 + "]\n[" + s2 + "]\n[" + s3 + "]\n[" + s4 + "]\n[" + s5 + "]\n[" + s6 + "]\n[" + s7 + "]\n[" + s8 + "]\n[" + s9 + "]" ); 
		}
	
	/*public*/ this.trash = function( /*string*/ objectPath ){}
}
var lang = new Lang();



function AnimationSequence(/*string*/ eid, /*string*/ f){
	/*public*/ this.elementID = null;
	/*public*/ this.facet = ""; 		// L,T,W,H
	
	// Specifies the travelling path.
	/*public*/ this.deltaPx = -1;
	/*public*/ this.deltaMs = -1;
	/*public*/ this.curve 	= "";
	
	// Decided at runtime.
	/*public*/ this.startPx = -1;
	/*public*/ this.startMs = -1;
	
	// Implicit constructor.
	this.construct = function(){
		this.elementID = eid;
		this.facet = f;
	}
	this.construct();
	
	/*public*/ this.setTravellingPath = function(/*int*/ deltaPx, /*int*/ deltaMs, /*string*/ curve){
		this.deltaPx = deltaPx;
		this.deltaMs = deltaMs;
		this.curve 	 = curve;
	}
	
	/*public*/ this.startFrame = function(){
		var e = lang.e(this.elementID);
		if( 	"L" == this.facet ) this.startPx = lang.getL( e );
		else if("R" == this.facet ) this.startPx = lang.getR( e );
		else if("T" == this.facet ) this.startPx = lang.getT( e );
		else if("B" == this.facet ) this.startPx = lang.getB( e );
		else if("W" == this.facet ) this.startPx = lang.getW( e );
		else if("H" == this.facet ) this.startPx = lang.getH( e );
		this.startMs = lang.now();
	}
	
	/*public*/ this.drawFrame = function(){
		if( 	 "linear" 	 == this.curve ) return this.computeLinear();
		else if( "quadratic" == this.curve ) return this.computeQuadratic();
		else if( "cubic"	 == this.curve ) return this.computeCubic();
		else return this.computeLinear();
	}
	
	
	/*private*/ this.computeLinear = function(){
		var per = (lang.now() - this.startMs) / this.deltaMs;
		if( per < 0 ) per = 0;
		if( 1 < per ) per = 1;
		
		var px = lang.round( (per * this.deltaPx) + this.startPx );
		var e = lang.e(this.elementID);
		if( 	"L" == this.facet ) lang.setL( e, px );
		else if("R" == this.facet ) lang.setR( e, px );
		else if("T" == this.facet ) lang.setT( e, px );
		else if("B" == this.facet ) lang.setB( e, px );
		else if("W" == this.facet ) lang.setW( e, px );
		else if("H" == this.facet ) lang.setH( e, px );
		return (per != 1) ;
	}
	
	/*private*/ this.computeQuadratic = function(){
		var now = lang.now();
		var per = (now - this.startMs) / this.deltaMs;
		if( per < 0 ) per = 0;
		if( 1 < per ) per = 1;
		
		// Two quadratic formulas spliced together:
		// Left formula if a normal quadratic: y = a(x^2);
		// Right formula is an upside-down quadratic: y = -a((x-dx)^2) + dy
		
		// You really just have to trust me on this one...
		var dy = this.deltaPx;
		var dx = this.deltaMs;
		var a = (dy/2) / lang.pow( (dx/2), 2 ) ;
		
		var x = per * dx;
		var y = null;
		if( x < (dx/2) ) 		// Left formula.
			y = a*lang.pow(x, 2) ;
		else 					// Right formula.
			y = ( (-1*a)*lang.pow(x-dx,2) ) + dy ;
		
		var px = lang.round(y) + this.startPx;
		var e = lang.e(this.elementID);
		if( 	"L" == this.facet ) lang.setL( e, px );
		else if("R" == this.facet ) lang.setR( e, px );
		else if("T" == this.facet ) lang.setT( e, px );
		else if("B" == this.facet ) lang.setB( e, px );
		else if("W" == this.facet ) lang.setW( e, px );
		else if("H" == this.facet ) lang.setH( e, px );
		return (per != 1);
	}
	
	/*private*/ this.computeCubic = function(){
		
		var now = lang.now();
		var per = (now - this.startMs) / this.deltaMs;
		if( per < 0 ) per = 0;
		if( 1 < per ) per = 1;
		
		// Two cubic formulas spliced together:
		// Left formula if a normal cubic: y = a(x^3)
		// Right formula is an upside-down cubic: y = -a((x-dx)^3) + dy
		
		// You really just have to trust me on this one...
		var dy = this.deltaPx;
		var dx = this.deltaMs;
		var a = (dy/2) / lang.pow(dx/2, 3);
		
		var x = per * dx;
		var y = null;
		if( x < (dx/2) ) 		// Left formula.
			y = a*lang.pow(x, 3) ;
		else 					// Right formula.
			y = ( a*lang.pow(x-dx,3) ) + dy ;
		
		var px = lang.round(y) + this.startPx;
		var e = lang.e(this.elementID);
		if( 	"L" == this.facet ) lang.setL( e, px );
		else if("R" == this.facet ) lang.setR( e, px );
		else if("T" == this.facet ) lang.setT( e, px );
		else if("B" == this.facet ) lang.setB( e, px );
		else if("W" == this.facet ) lang.setW( e, px );
		else if("H" == this.facet ) lang.setH( e, px );
		return (per != 1);
	}
}




function AnimationSubject(){
	/*public*/ this.elementID = null;
	/*public*/ this.sequences = new Array();
	/*public*/ this.callback  = null;
	
	/*public*/ this.getSequence = function(/*string*/ facet){
		return this.sequences[facet];
	}
	
	/*public*/ this.addSequence = function(/*string*/ facet){
		var seq = new AnimationSequence( this.elementID, facet );
		this.sequences.push(seq);
		return seq;
	}
	
	/*public*/ this.clearSequences = function(){
		for( s in this.sequences ){
			for( m in this.sequences[s] )
				delete m;
			delete this.sequences[s];
		}
		delete this.sequences;
		this.sequences = new Array();
	}
	
	/*public*/ this.hasSequences = function(){
		return (i.sequences != 0) ;
	}
	
	/*public*/ this.addCallback = function(/*Object*/ clb){
		this.callback = clb;
	}
	
	// TODO:
	/*public*/ this.arrangeSequences = function(){}
	
	/*public*/ this.runSequences = function(/*int*/ msStartAnimation){
		if( ! msStartAnimation ) msStartAnimation = ani.msSequenceInterval;
		setTimeout( "ani.subjects['" + this.elementID + "'].runSequencesNow();", msStartAnimation);
	}
	
	/*private*/ this.runSequencesNow = function(){
		for( s in this.sequences )
			this.sequences[s].startFrame();
		setTimeout( "ani.subjects['" + this.elementID + "'].sequences_onTimer();" , 0);
	}
	
	/*public*/ this.sequences_onTimer = function(){
		var poll = false;
		for( s in this.sequences ){
			if( this.sequences[s].drawFrame() )
				poll = true;
		}
		
		if( poll ){
			var si = ani.msSequenceInterval;
			setTimeout( "ani.subjects['" + this.elementID + "'].sequences_onTimer();" , si);
		}
		else{
			if( this.callback )
				this.callback();
		}
	}
}




function Animation(){
	/*public*/ this.subjects = new Object();
	/*private*/ this.msSequenceInterval = 25;
	
	/*public*/ this.addSubject = function(/*Element*/ e){
		var sub = new AnimationSubject();
		var id = lang.id(e);
		sub.elementID = id;
		this.subjects[ id ] = sub;
		return sub;
	}
	
	/*public*/ this.getSubject = function(/*Element*/ e){
		var id = lang.id(e);
		if( this.subjects[id] )
			return this.subjects[id];
		else return null;
	}
	
	/*public*/ this.existSubject = function(/*Element*/ e){
		var id = lang.id(e);
		var sub = this.getSubject(e);
		if( ! sub ) sub = this.addSubject(e);
		return sub;
	}
	
	/*public*/ this.removeSubject = function(/*Element*/ e){
		var id = lang.id(e);
		if( this.getSubject(e) )
			lang.trash("ani.subjects." + id );
	}
	
	// Simple animations.
	
		/*public*/ this.runSingleSequence = function( /*Element*/ e, /*string*/ facet, /*int*/ deltaPx, /*int*/ deltaMs, /*string*/ curve, /*Object*/ callback, /*int*/ msStartAnimation){
			var sub = ani.existSubject( e );
			sub.clearSequences();
			var seq = sub.addSequence( facet );
			seq.setTravellingPath( deltaPx, deltaMs, curve);
			sub.addCallback(callback);
			sub.runSequences(msStartAnimation);
		}
		
		/*public*/ this.appearFrom = function( /*Element*/ toAppear, /*Element*/ from, /*int*/ deltaMs, /*string*/ curve, /*Object*/ callback, /*int*/ msStartAnimation ){
			var a = toAppear;
			var f = from;
			
			lang.show( a );
			a.style.overflow = "hidden";
			
			var aL = lang.getL(a);
			var aT = lang.getT(a);
			var aW = lang.getW(a);
			var aH = lang.getH(a);
			
			var fL = lang.getL(f);
			var fT = lang.getT(f);
			var fW = lang.getW(f);
			var fH = lang.getH(f);
			
			var cL = fL + (fW/2);
			var cT = fT + (fH/2);
			
			lang.setL( a, cL );
			lang.setT( a, cT );
			lang.setW( a, 0  );
			lang.setH( a, 0  );
			
			var sub = ani.existSubject( a );
			
			var seq = sub.addSequence( "L" );
			seq.setTravellingPath( aL-cL, deltaMs, curve );
			
			seq = sub.addSequence( "T" );
			seq.setTravellingPath( aT-cT, deltaMs, curve );
			
			seq = sub.addSequence( "W" );
			seq.setTravellingPath( aW, deltaMs, curve );
			
			seq = sub.addSequence( "H" );
			seq.setTravellingPath( aH, deltaMs, curve );
			
			sub.addCallback( callback );
			sub.runSequences( msStartAnimation );
		}
		
		/*public*/ this.disappearInto = function( /*Element*/ toDisappear, /*Element*/ into, /*int*/ deltaMs, /*string*/ curve, /*Object*/ callback, /*int*/ msStartAnimation ){
			var d = toDisappear;
			var i = into;
			
			lang.show( d );
			d.style.overflow = "hidden";
			
			var dL = lang.getL(d);		// toDisappear.
			var dT = lang.getT(d);
			var dW = lang.getW(d);
			var dH = lang.getH(d);
			
			var iL = lang.getL(i);		// into.
			var iT = lang.getT(i);
			var iW = lang.getW(i);
			var iH = lang.getH(i);
			
			var cL = iL + (iW/2);
			var cT = iT + (iH/2);
			
			var sub = ani.existSubject( d );
			var seq = sub.addSequence( "L" );
			seq.setTravellingPath( -(dL-cL), deltaMs, curve );
			
			seq = sub.addSequence( "T" );
			seq.setTravellingPath( -(dT-cT), deltaMs, curve );
			
			seq = sub.addSequence( "W" );
			seq.setTravellingPath( -dW, deltaMs, curve );
			
			seq = sub.addSequence( "H" );
			seq.setTravellingPath( -dH, deltaMs, curve );
			
			// HACK: Defer callback until after onDisappear().
			sub.addCallback( null ); 
			this.disappearCallback = callback;
			sub.runSequences( msStartAnimation );
			setTimeout( "ani.onDisappear( lang.e('" + lang.id(d) + "'), " + dL + ", " + dT + ", " + dW + ", " + dH + ");" , deltaMs+250 );
		}
		
		this.disappearCallback = null;
		
		/*public*/ this.onDisappear = function( /*Element*/ disappeared, /*int*/ l, /*int*/ t, /*int*/ w, /*int*/ h, /*Object*/ callback ){
			var d = disappeared;
			lang.show( d );
			lang.setL( d, l );
			lang.setT( d, t );
			lang.setW( d, w );
			lang.setH( d, h );
			lang.hide( d );
			if( this.disappearCallback )
				this.disappearCallback();
		}
		
}
var ani = new Animation();




function Timer(){
	/*public*/ this.timerID    	  = -1;
	/*public*/ this.callback   	  = null;
	/*public*/ this.msInterval 	  = -1;
	/*public*/ this.msLastStarted = -1;
	/*public*/ this.isStarted  	  = false;
	/*public*/ this.pollID		  = -1;
}




function Timers(){
	/*public*/ this.timers = new Array();
	
	/*public*/ this.addTimer = function(/*Object*/ callback, /*int*/ msInterval){
		var t = new Timer();
		var tid = this.timers.length;
		t.timerID = tid;
		t.callback = callback;
		t.msInterval = msInterval;
		this.timers[tid] = t;
		return tid;
	}
	
	/*private*/ this.isTimerReady = function(/*int*/ timerID){
		var out = false;
		var t = this.timers[timerID];
		if( t ){
			if( -1 	 != t.timerID 	 &&
				null != t.callback   &&
				-1 	 != t.msInterval ){
				out = true;
			}
		}
		return out;
	}
	
	/*public*/ this.getTimer = function(/*int*/ timerID ){
		var out = null;
		if( this.isTimerReady(timerID) )
			out = this.timers[timerID] ;
		return out;
	}
	
	/*public*/ this.start = function(/*int*/ timerID){
		var out = false;
		var t = this.getTimer(timerID);
		if( t ){
			if( ! t.isStarted ){
				t.isStarted = true;
				t.msLastStarted = lang.now();
				this.pollAfterMs( t.timerID, ++t.pollID, t.msInterval );
				out = true;
			}
		}
		return out;
	}
	
	/*public*/ this.stop  = function(/*int*/ timerID){
		var out = false;
		var t = this.getTimer(timerID);
		if( t ){
			if( t.isStarted ){
				t.isStarted = false;
				out = true;
			}
		}
		return out;
	}
	
	/*public*/ this.isStarted = function(/*int*/ timerID){
		var out = false;
		var t = this.getTimer(timerID);
		if( t ) out = t.isStarted;
		return out;
	}
	
	/*private*/ this.poll = function(/*int*/ timerID, /*int*/ pollID){
		var out = false;
		var t = this.getTimer(timerID);
		if( t ){
			if( pollID == t.pollID ){
				if( t.isStarted ){
					t.callback( timerID );
					this.pollAfterMs( timerID, pollID, t.msInterval );
				}
			}
		}
		return out;
	}
	
	/*private*/ this.pollAfterMs = function( /*int*/ timerID, /*int*/ pollID, /*int*/ ms ){
		setTimeout("timers.poll(" + timerID + ", " + pollID + ");", ms );
	}
	
	/*public*/ this.getElapsed = function(/*int*/ timerID){
		var out = -1;
		var t = this.getTimer(timerID);
		if( t ) out = lang.now() - t.msLastStarted ;
		return out;
	}
}
var timers = new Timers();




// For pica-style controls
function Control(){
	
	/*public*/ this.ieWrappingLinkFix = function(/*Element*/ parent ){
		if( lang.isIE() ){
			var a = this.getWrappingLink(parent);
			if( a && parent ){
				parent.style.cursor = "pointer";
				lang.onEvent( parent, "click", function(){control.onLinkClick(a)} );
			}
		}
	}
	
	/*private*/ this.getWrappingLink = function(/*Element*/ parent){
		var out = null;
		var p = parent;
		for(var i=0; i<4; i++){
			if( !p ) break;
			if( "A" == p.tagName ){
				out = p;
				break;
			}
			p = p.parentNode;
		}
		return out;
	}
	
	/*private*/ this.onLinkClick = function(/*Element*/ a){
		window.location = a.href;
	}
}
var control = new Control();function onReAskYes(){logClick("Clicked Yes");lang.e("divReasking").style.display="none";lang.e("divSigningUp").style.display="block";lang.e("divWasUseful").style.display="none";lang.e("email").focus();if(window.survey instanceof Object){window.survey.hide()}}function onReAskNo(){logClick("Clicked No");lang.e("divReasking").style.display="block";lang.e("divSigningUp").style.display="none";lang.e("divWasUseful").style.display="none";onRephrase();if(window.survey instanceof Object){window.survey.hide()}}function onRephrase(){lang.e("divWhatToDo").style.display="none";lang.e("divRephrase").style.display="block"}function onAskDifferent(){lang.e("divWhatToDo").style.display="none";lang.e("divAskDifferent").style.display="block"}var paneState="READY";function onSignUpClick(B){if("READY"==paneState){var C=lang.e("btnNext");var A=lang.getText(C);if("sign up"==A){showPleaseConfirm()}else{if("submit"==A){var D=lang.e("signup_form");D.submit()}}}}function showPleaseConfirm(){var E=lang.e("divSignUpPane0");var D=lang.e("divSignUpPane1");D.style.visibility="visible";var B=lang.getL(E);var A=lang.getL(D);var C=B-A;paneState="";ani.runSingleSequence(E,"L",C,500,"cubic",null,0);ani.runSingleSequence(D,"L",C,500,"cubic",onPleaseConfirmShow,0)}function showThanksForYourFeedback(){var E=lang.e("divSignUpPane0");var D=lang.e("divSignUpPane1");E.style.visibility="visible";var B=lang.getL(E);var A=lang.getL(D);var C=A-B;paneState="";ani.runSingleSequence(E,"L",C,500,"cubic",null,0);ani.runSingleSequence(D,"L",C,500,"cubic",onThanksForYourFeedbackShow,0)}function onPleaseConfirmShow(){lang.e("confirm_password").focus();var A=lang.e("btnNext");lang.setText(A,"submit");var C=lang.e("divSignUpPane0");C.style.visibility="hidden";var B=lang.e("btnBack");B.style.visibility="visible";paneState="READY"}function onThanksForYourFeedbackShow(){lang.e("email").focus();var A=lang.e("btnNext");lang.setText(A,"sign up");var D=lang.e("divSignUpPane0");var C=lang.e("divSignUpPane1");C.style.visibility="hidden";var B=lang.e("btnBack");B.style.visibility="hidden";paneState="READY"}function onBackClick(A){if("READY"==paneState){showThanksForYourFeedback()}}function logClick(A){var B="text="+A;cb={success:onAjaxSucceed,failure:onAjaxFail};YAHOO.util.Connect.asyncRequest("POST","/ajax/log.click.html",cb,B)}function onAjaxSucceed(A){}function onAjaxFail(A){};YAHOO.namespace("akatoo.layout");YAHOO.akatoo.layout.RECTANGLE_CORNER={nw:"nw",ne:"ne",sw:"sw",se:"se"};YAHOO.akatoo.layout.positionCalloutInViewPort=function(P,O,S,V,K,I,E,T,N,L,U,D){var A=function(X,a,Y,W){var Z=new YAHOO.util.Region(a,X+Y,a+W,X);return Z};var R=function(X,Y,W){return{corner:X,smallRect:Y,bigRect:W}};var C=A(P,O,S,V);var F=[R(YAHOO.akatoo.layout.RECTANGLE_CORNER.nw,A(K,I,E,T),A(K+E-1,I-N,U,D)),R(YAHOO.akatoo.layout.RECTANGLE_CORNER.sw,A(K,I-T,E,T),A(K+E-1,I+L-D,U,D)),R(YAHOO.akatoo.layout.RECTANGLE_CORNER.ne,A(K-E,I,E,T),A(K-E-U+1,I-N,U,D)),R(YAHOO.akatoo.layout.RECTANGLE_CORNER.se,A(K-E,I-T,E,T),A(K-E-U+1,I+L-D,U,D))];var Q=-1;var B=0;for(var H=0;H<F.length;++H){var M=F[H].bigRect;if(C.contains(M)){Q=H;break}var G=C.intersect(M);if(G){var J=G.getArea();if(Q==-1||J>B){Q=H;B=J}}}if(Q==-1){Q=0}return F[Q]};function UserExpertiseKey(A,B){this.user_id=A;this.category_id=B}UserExpertiseKey.prototype.toString=function(){return this.user_id+":"+this.category_id};UserExpertiseKey.prototype.equals=function(A){return this.user_id==A.user_id&&this.category_id==A.category_id};var user_expertise_cache={_cache:{},get:function(E,G,H,F,A){var D=this._cache[E];if(D){if(D.is_pending){G.call(F,A)}else{H.call(F,A,D.result)}}else{D={is_pending:true};this._cache[E]=D;var B="user_id="+E.user_id+"&category_id="+E.category_id;var I={success:this._onSuccess,failure:this._onFailure,scope:user_expertise_cache,argument:{user_key:E,on_call_completed_cb:H,cb_parameter:A,cb_scope:F}};var C=YAHOO.util.Connect.asyncRequest("POST","/ajax/user.expertise.html",I,B);G.call(F,A)}},_onSuccess:function(A){if(A.responseText!==undefined){var B=YAHOO.lang.JSON.parse(A.responseText);this._cacheResult(A,B)}else{this._onFailure(A)}},_onFailure:function(A){this._cacheResult(A,{is_success:false})},_cacheResult:function(A,C){var B=A.argument.user_key;var D=this._cache[B];D.is_pending=false;D.result=C;this._cache[B]=D;A.argument.on_call_completed_cb.call(A.argument.cb_scope,A.argument.cb_parameter,D.result)}};var user_callout_handler={_callout_id:null,_pointer_id:null,_callout:null,_pointer:null,_user_map:{},_active_element_id:null,_pending_element_id:null,_signature:0,_ajax_activity:new AjaxActivityRenderer(),init:function(A){this._callout_id=A;this._pointer_id=A+"-pointer";YAHOO.util.Event.addListener(document.body,"mouseover",this._handleMouseOver,this,true)},addUserElement:function(A,D,B,H,E,G,F,C){this._user_map[A]={user_key:new UserExpertiseKey(B,D),username:H,avatar_id:E,avatar_width:G,avatar_height:F,user_global_points_balance:C,is_render_activity:false}},_handleMouseOver:function(C){var A=YAHOO.util.Event.getTarget(C);while(A!=document.body){var B=A.id;if(B){if(this._user_map[B]){this._queueUpdate(B);return }if(B==this._callout_id||B==this._pointer_id){if(this._active_element_id){this._queueUpdate(this._active_element_id)}return }}A=A.parentNode}this._queueUpdate(null)},_queueUpdate:function(A){if(this._pending_element_id!=A){this._pending_element_id=A;var C=this;var B=++this._signature;window.setTimeout(function(){if(B==C._signature){C._handleUpdate()}},800)}},_handleUpdate:function(){if(this._pending_element_id===null){this._hideCallout()}else{this._showCallout(this._pending_element_id)}},_hideCallout:function(){if(this._active_element_id!==null){this._callout.hide();this._pointer.hide();this._active_element_id=null}},_getUserInfo:function(A){return this._user_map[A]},_showCallout:function(B){if(!this._callout){this._callout=this._createOverlay(this._callout_id,435);this._pointer=this._createOverlay(this._pointer_id,30)}var F,E;var C=this._getUserInfo(B);if(this._active_element_id===null){F=true;E=true}else{F=this._active_element_id!=B;var A=this._getUserInfo(this._active_element_id).user_key;E=!A.equals(C.user_key)}if(F){if(E){this._renderElementText(this._callout_id+"-username",C.username);this._renderElementText(this._callout_id+"-IKU-value",C.user_global_points_balance);var D=document.getElementById(this._callout_id+"-avatar");if(D){D.src="/img.html?eid="+C.avatar_id;D.height=C.avatar_height;D.width=C.avatar_width}this._active_element_id=B;user_expertise_cache.get(C.user_key,this._onUserExpertisePending,this._handleUserExpertiseCompleted,this,B)}this._doLayout(B);this._pointer.bringToTop();this._pointer.show();this._callout.show()}this._active_element_id=B},_handleUserExpertiseCompleted:function(B,A){if(this._active_element_id==B){if(!A.is_success){this._renderUserExpertiseMessage("Operation failed.",false)}else{this._renderTotalQuestionsAsked(A.TotalQuestionsAsked);this._renderTotalAnswered(A.TotalAnswersGiven);this._renderRating(A.UserCommunityRating);this._renderUserLevel(A.UserLevelID,B);if(A.expertise.length>0){var D=this._removeExpertiseTableRows();if(D){var F=A.expertise.length;if(A.scale&&F>5){F=5}for(var H=0;H<F;++H){var E=document.createElement("tr");var G=document.createElement("td");G.className="expertise_catname";var C=this._createCategoryLink(A.expertise[H].CategoryID,this._callout_id+"-expertise"+H+"-category",A.expertise[H].CategoryShortPath,A.expertise[H].CategoryFullPath);G.appendChild(C);E.appendChild(G);G=document.createElement("td");G.id=this._callout_id+"-expertise"+H+"-points-balance";G.appendChild(document.createTextNode(A.expertise[H].CategoryPointsBalance));E.appendChild(G);G=document.createElement("td");G.id=this._callout_id+"-expertise"+H+"-rated-answers";G.appendChild(document.createTextNode(A.expertise[H].NumAnswers));E.appendChild(G);G=document.createElement("td");G.id=this._callout_id+"-expertise"+H+"-nonflagged-question-count";G.appendChild(document.createTextNode(A.expertise[H].NonFlaggedQuestionCount));E.appendChild(G);D.appendChild(E)}}if(!A.scale){this._showRelativitySection(false)}else{this._renderRelativitySection(A.scale,B);this._showRelativitySection(true)}}else{this._renderUserExpertiseMessage("No data recorded yet.",false)}this._doLayout(this._active_element_id)}}},_createCategoryLink:function(D,B,C,E){var A=document.createElement("a");A.id=B;A.href="/category.html?category_id="+D;A.title=E;A.appendChild(document.createTextNode(C));return A},_renderRelativitySection:function(E,A){var C=E.PercentageCurrent;if(1<C){C=0.05}var B=lang.replaceCaseSensitive(this._callout_id,"-","_")+"_IKUScale";instances[B].setLimits(0,1);instances[B].setRange(E.PercentageDownside,E.PercentageUpside);instances[B].setPointer(C);instances[B].refresh();var D=instances[B].parent;if(lang.isIE6()){lang.fade(D,0,1)}this._renderElementText(this._callout_id+"-IKU_scale_current",E.CategoryPointsBalance);this._renderRelativitySectionTitle(E);this._adjustIKUBoxPosition(instances[B])},_adjustIKUBoxPosition:function(D){var B=this._callout_id+"-iku-box";var C=lang.e(B);if(lang.isIE6()){lang.fade(C,0,1,0)}var A=D.getPointerLPx();A-=60;A=lang.max(A,7);lang.setL(C,A)},_showRelativitySection:function(B){var A=this._callout_id+"-IKU-relativity";if(B){YAHOO.util.Dom.removeClass(A,"nodisplay")}else{YAHOO.util.Dom.addClass(A,"nodisplay")}},_onUserExpertisePending:function(A){this._renderTotalQuestionsAsked("");this._renderTotalAnswered("");this._renderUserExpertiseMessage("Loading, please wait...",true);this._renderRating(0);this._showRelativitySection(false)},_renderRating:function(A){update_stars(this._callout_id+"-average-score",5,A)},_renderRelativitySectionTitle:function(C){var B=this._removeAllChildren(this._callout_id+"-IKU-relativity_title");if(B){var A=this._createCategoryLink(C.CategoryID,this._callout_id+"-relativity-category-link",C.CategoryName,C.CategoryFullPath);B.appendChild(A)}},_renderUserLevel:function(B,A){var E=this._getUserInfo(A);var D=E.user_global_points_balance.replace(",","","g");var C=lang.replaceCaseSensitive(this._callout_id,"-","_")+"_IKULightBulb";instances[C].setIKU(D);instances[C].refresh()},_renderTotalQuestionsAsked:function(A){this._renderElementText(this._callout_id+"-total_questions_asked",A)},_renderTotalAnswered:function(A){this._renderElementText(this._callout_id+"-total_answered",A)},_removeAllChildren:function(A){var B=document.getElementById(A);if(B){while(B.hasChildNodes()){B.removeChild(B.firstChild)}}return B},_renderElementText:function(A,C){var B=this._removeAllChildren(A);if(B){B.appendChild(document.createTextNode(C))}},_removeExpertiseTableRows:function(){return this._removeAllChildren(this._callout_id+"-expertise-container")},_renderUserExpertiseMessage:function(E,C){var B=this._removeExpertiseTableRows();if(B){var A=this._callout_id+"-expertise-usr-msg";var D=document.createElement("tr");var F=document.createElement("td");F.id=A;F.colSpan=99;F.appendChild(document.createTextNode(E));D.appendChild(F);B.appendChild(D);if(C){this._ajax_activity.start(A)}else{this._ajax_activity.stop()}}},_createOverlay:function(A,B){var C=new YAHOO.widget.Overlay(A,{visible:false,width:B+"px"});C.render();YAHOO.util.Dom.removeClass(A,"nodisplay");return C},_doLayout:function(A){var C=document.getElementById(A);var E=YAHOO.util.Dom.getXY(A);var B=YAHOO.akatoo.layout.positionCalloutInViewPort(YAHOO.util.Dom.getDocumentScrollLeft(),YAHOO.util.Dom.getDocumentScrollTop(),YAHOO.util.Dom.getViewportWidth(),YAHOO.util.Dom.getViewportHeight(),Math.round(E[0]+C.offsetWidth/2),Math.round(E[1]+C.offsetHeight/2),this._pointer.element.offsetWidth,this._pointer.element.offsetHeight,this._pointer.element.offsetHeight+10,10,this._callout.element.offsetWidth,this._callout.element.offsetHeight);this._pointer.cfg.setProperty("xy",B.smallRect);this._callout.cfg.setProperty("xy",B.bigRect);var D="callout-pointer-"+B.corner;if(!YAHOO.util.Dom.hasClass(this._pointer.element,D)){YAHOO.util.Dom.removeClass(this._pointer.element,"callout-pointer-(?:nw|sw|ne|se)");YAHOO.util.Dom.addClass(this._pointer.element,D)}}};/* Copyright (c) 2008 Akatoo, Inc. */

function IKUScale(){
	// Id.
	this.id 		= "";
	
	// Elements.
	this.rainbow	= null;
	this.blur		= null;
	this.solid		= null;
	this.pointer 	= null;
	this.parent 	= null;
	
	// State.
	this.min 	= -1;
	this.val	= -1;
	this.max	= -1;
	this.rngMin = -1;
	this.rngMax = -1;
	this.pointerWidth 	= -1;
	this.parentWidth 	= -1;
	this.pointerHeight 	= -1;
	this.parentHeight 	= -1;
	
	// An explicit constructor.
	
	
	
	
		/*public*/ this.construct = function(/*string*/ id){
			this.id 		= id;
			
			this.rainbow = new IKUBarLayer();
			this.rainbow.construct( id + ".rainbow" );
			
			this.blur = new IKUBarLayer();
			this.blur.construct( id + ".blur" );
			
			this.solid = new IKUBarLayer();
			this.solid.construct( id + ".solid" );
			
			this.pointer 		= lang.e( id + ".pointer" );
			this.pointerWidth 	= lang.getW( this.pointer );
			this.pointerHeight 	= lang.getH( this.pointer );
			
			this.parent 		= this.pointer.parentNode;
			this.parentWidth 	= lang.getW( this.parent );
			this.parentHeight 	= lang.getH( this.parent );
			
			// IE hack.
			control.ieWrappingLinkFix( this.parent );
		}
		
		
		
		
	// Events.
	
	
	
	
		/*public*/ this.onRainbowViewerClick = function(/*Element*/ a){
			window.location = a.href;
		}
		
		/*public*/ this.onBlurViewerClick = function(/*Element*/ a){
			window.location = a.href;
		}
		
		/*public*/ this.onSolidViewerClick = function(/*Element*/ a){
			window.location = a.href;
		}
		
		
		
		
	/*public*/ this.setLimits = function(/*float*/ min, /*float*/ max){
		this.min = lang.float( min );
		this.max = lang.float( max );
	}
	
	/*public*/ this.setPointer = function(/*float*/ val){
		this.val = lang.float( val );
	}
	
	/*public*/ this.setRange = function(/*float*/ min, /*float*/ max){
		this.rngMin = lang.float(min);
		this.rngMax = lang.float(max);
		// TODO: fix the limits if need be.
		if( this.rngMin < this.min ) this.min = this.rngMin;
		if( this.max < this.rngMax ) this.max = this.rngMax;
	}
	
	/*public*/ this.refresh = function(){
		if( this.min 	!= -1 &&
			this.rngMin != -1 &&
			this.val	!= -1 &&
			this.rngMax != -1 &&
			this.max	!= -1 ){
			if( this.min 	<= this.rngMin 	&&
				this.rngMin <= this.val 	&&
				this.val 	<= this.rngMax  &&
				this.rngMax	<= this.max 	){
				this.showLayers();
				this.redraw();
			}
			else{ this.hideLayers(); }
		}
	}
	
	/*private*/ this.showLayers = function(){
		lang.show( this.rainbow.viewer );
		lang.show( this.blur.viewer );
		lang.show( this.solid.viewer );
	}
	
	/*private*/ this.hideLayers = function(){
		lang.hide( this.rainbow.viewer );
		lang.hide( this.blur.viewer );
		lang.hide( this.solid.viewer );
	}
	
	/*private*/ this.redraw = function(){
		this.fitLayersToParent();
		this.positionLayers();
		this.positionPointer();
	}
	
	/*private*/ this.fitLayersToParent = function(){
		this.rainbow.fitToParent(this.parentWidth);
		this.blur.fitToParent	(this.parentWidth);
		this.solid.fitToParent	(this.parentWidth);
	}
	
	/*private*/ this.positionLayers = function(){
		this.positionLayer( this.blur, 		this.min, 	 this.rngMin );
		this.positionLayer( this.rainbow, 	this.rngMin, this.rngMax );
		this.positionLayer( this.solid, 	this.rngMax, this.max );	
	}
	
	/*private*/ this.positionLayer = function(/*IKUBarLayer*/ layer, /*int*/ from, /*int*/ to ){
		layer.view(
			this.toPx(from),
			this.toPx(to));
	}
	
	/*private*/ this.positionPointer = function(){
		lang.setL( this.pointer, 
			this.toPx(this.val) -
			( this.pointerWidth / 2 ) );
			
		lang.setT( this.pointer, 
			this.parentHeight - 
			this.pointerHeight - 1 );
	}
	
	// Returns the px position of the pointer
	/*public*/ this.getPointerLPx = function(){
		var pl = lang.getL( this.pointer ) ;
		pl += ( this.pointerWidth / 2 ) ;
		return pl ;
	}
	
	// Get the px for a number on the scale.
	/*private*/ this.toPx = function(/*int*/ num){
		var px = (num - this.min) / (this.max-this.min) ;
		px *= this.parentWidth;
		return px;
	}
	
}




function IKUBarLayer(){
	// Elements.
	this.viewer 	= null;
	this.bar		= null;
	this.left		= null;
	this.center		= null;
	this.right		= null;
	
	// An explicit constructor.
	/*public*/ this.construct = function(/*string*/ id){
		this.viewer = lang.e( id + ".viewer" );
		this.bar 	= lang.e( id + ".bar" );
		this.left	= lang.e( id + ".left" );
		this.center	= lang.e( id + ".center" );
		this.right	= lang.e( id + ".right" );
	}
	
	/*public*/ this.fitToParent = function(/*int*/ parentWidth){
		var pw = parentWidth;
		var lw = lang.getW( this.left );
		var rw = lang.getW( this.right );
		
		lang.setL( this.viewer, 0);
		lang.setW( this.viewer, pw);
		lang.setL( this.left, 0 );
		lang.setL( this.center, lw );
		lang.setW( this.center, pw-lw-rw );
		lang.setL( this.right, pw-rw );
	}
	
	
	
	/*public*/ this.view = function(/*int*/ fromPx, /*int*/ toPx){
		lang.setL( this.bar, -fromPx );
		lang.setL( this.viewer, fromPx );
		lang.setW( this.viewer, toPx - fromPx );
	}
}/* Copyright (c) 2008 Akatoo, Inc. */

function IKULightBulb(){
	// Id.
	this.id 			= "";
	
	// Elements.
	this.imgLShade0	= null;
	this.imgRShade0	= null;
	this.imgLShade1	= null;
	this.imgRShade1	= null;
	this.parent		= null;
	
	// State.
	this.IKU			= 100;
	this.colors 		= new Array();
	this.leftColor		= null;					//
	this.rightColor		= null;
	this.roundRobin		= new Array();
	
	
	/*public*/ this.construct = function(/*string*/ id){
		this.id = id;
		this.imgLShade0 = lang.e( id + ".lShade0" );
		this.imgRShade0 = lang.e( id + ".rShade0" );
		this.imgLShade1 = lang.e( id + ".lShade1" );
		this.imgRShade1 = lang.e( id + ".rShade1" );
		this.parent 	= this.imgLShade0.parentNode;
		
		this.roundRobin[0] = { left: this.imgLShade0, right: this.imgRShade0 };
		this.roundRobin[1] = { left: this.imgLShade1, right: this.imgRShade1 };

		// IE hack.
		control.ieWrappingLinkFix( this.parent );
		
		instances[id] = this;
	}
	
	/*public*/ this.addColor = function(/*int*/ IKU, /*string*/ color){
		var o = new Object();
		o.IKU = IKU;
		o.color = color;
		this.colors.push(o);
	}
	
	/*public*/ this.setIKU = function(/*float*/ IKU){
		this.IKU = lang.float( IKU );
	}
	
	/*public*/ this.refresh = function(/*bool*/ fade){
		if( null == fade ) fade = true;
		this.leftColor = null;
		this.rightColor = null;
		for( i in this.colors ){
			var c = this.colors[i];
			if( c.IKU <= this.IKU )
				this.leftColor = c;
		
			if( null == this.rightColor ){
				if( this.IKU < c.IKU ){
					this.rightColor = c;
					break;
				}
			}
		}
		this.refreshImages(fade);
	}
	
	/*private*/ this.refreshImages = function(/*bool*/ fade){
		var l = this.leftColor;
		var r = this.rightColor;
		
		if( null != l && null != r ){
			var a = this.IKU - l.IKU ;
			var b = r.IKU - this.IKU ;
			var c = r.IKU - l.IKU ;
			var rightOpacity = lang.float(a/c);
			
			this.roundRobinDown();
			this.setImageSrc();
			this.changeImages(rightOpacity, fade);
		}
	}
	
	/*private*/ this.roundRobinDown = function(){
		var rr = this.roundRobin;
		if( rr ){
			var top = rr[0];
			for( var i=1; i<rr.length; i++)
				rr[i-1] = rr[i];
			rr[i-1] = top;
		}
	}
	
	/*private*/ this.setImageSrc = function(){
		this.roundRobin[0].left.src  = "/images/controls/IKULightBulb/" + this.leftColor.color ;
		this.roundRobin[0].right.src = "/images/controls/IKULightBulb/" + this.rightColor.color ;
	}
	
	/*private*/ this.changeImages = function(/*int*/ rightOpacity, /*bool*/ fade ){
		if( lang.isIE6() ) fade = false;
		if( fade ){
			r0 = lang.getOpacity(this.roundRobin[0].right);
			r1 = lang.getOpacity(this.roundRobin[1].right);
			lang.fade( this.roundRobin[0].left, 0.0, 1.0 );
			lang.fade( this.roundRobin[0].right, r0, rightOpacity );
			lang.fade( this.roundRobin[1].left, 1.0, 0.0 );
			lang.fade( this.roundRobin[1].right, r1, 0.0 );
		}
		else{
			lang.setOpacity( this.roundRobin[0].left, 1.0 );
			lang.setOpacity( this.roundRobin[0].right, rightOpacity );
			lang.setOpacity( this.roundRobin[1].left, 0.0 );
			lang.setOpacity( this.roundRobin[1].right, 0.0 );
		}
	}
	
}
