$(document).ready(function(){if($("#Elm").attr("id")){$.tabs("#Elm");io_more_load(GET_BASE_URL+"/topic/ajax/question_list/topic_id-"+TOPIC_ID,$("#all-more"),$("#c_all_list"));io_more_load(GET_BASE_URL+"/topic/ajax/question_list/type-best__topic_id-"+TOPIC_ID,$("#io_best_question_more"),$("#c_best_question_list"));io_more_load(GET_BASE_URL+"/question/ajax/discuss/answer_count-0__topic_id-"+TOPIC_ID,$("#noanswer-more"),$("#c_noanswer_list"),1);io_more_load(GET_BASE_URL+"/topic/ajax/question_list/type-favorite__topic_title-"+encodeURIComponent(TOPIC_TITLE),$("#fav-more"),$("#c_favorite_list"),0,function(){if($("#c_favorite_list a").attr("id")){$("#tny-favorite").show()}})}if($("#focususers").attr("id")){$.get(GET_BASE_URL+"/topic/ajax/get_focususers/topic_id-"+TOPIC_ID,function(data){$.each(data,function(i,d){$("#focususers").append('<a href="'+d.url+'" class="imgUser"><img src="'+d.avatar_file+'" class="umsg" data-message="&uid='+d.uid+'&card=user"  /></a>')})},"json")}if($("#topic_pic_uploader").attr("id")){init_img_uploader(GET_BASE_URL+"/topic/ajax/upload_topic_pic/topic_id-"+TOPIC_ID,"topic_pic",$("#topic_pic_uploader"),$("#uploading_status"),$("#topic_pic"))}});$.editor_topic_x=function(flg){$(flg).hide();$("#editor_input_handle").removeClass("tny-hide");$("#PublicTopic >a").each(function(index,element){var flgs=$(this);if(flgs.find("em").length>0){flgs.addClass("rel pd").find("em").show()}else{$("<em/>").addClass("handle abs").attr("title","Delete").attr("onclick","$.delete_topicx(this,event)").html("×").appendTo(flgs.addClass("rel pd"))}})};$.establish_topicx=function(){if($("#editor_input").val()=="Creating add related topic..."||$.trim($("#editor_input").val()).length==0){$("#tips_err").show().html("Subject can not be empty!");$("#editor_input").val("").focus();return}else{if($.trim($("#editor_input").val()).length==1){$("#tips_err").show().html("Please enter two or more related topic!");$("#editor_input").val("").focus();return}else{$.ajax({type:"POST",url:GET_BASE_URL+"/topic/ajax/save_related_topic/topic_id-"+TOPIC_ID,data:"topic_title="+$.trim($("#editor_input").val()),dataType:"json",success:function(s){if(s.rsm!=null){$("<a/>").addClass("glotopic umsg").attr("data-message","&uid="+s.rsm.related_id+"&card=topic").html($.trim($("#editor_input").val())).attr("href",GET_BASE_URL+"/topic/"+s.rsm.related_id).appendTo($("#PublicTopic"));$.exit_topic()}if(s.errno==-1){$("#tips_err").show().html(s.err)}}})}}};$.delete_topicx=function(flg,e){var uid=$(flg).parents("a").attr("data-message").split("&")[1].split("uid=")[1];if(e){e.preventDefault();e.stopPropagation();$(flg).parents("a").hide("slow",function(){$.ajax({type:"GET",url:GET_BASE_URL+"/topic/ajax/remove_related_topic/related_id-"+uid+"__topic_id-"+TOPIC_ID,dataType:"json",success:function(s){$(this).remove();$("#tips_err").show().html("Topic deleted successfully!");setTimeout(function(){$("#tips_err").hide("slow").html("")},1000)}})})}};$.exit_topic=function(){$("#editor_input_handle").addClass("tny-hide");$("#editor_topicBtns").show();$("#editor_input").val("").focus();$("#PublicTopic >a").each(function(index,element){var flg=$(this);if(flg.find("em").length>0){flg.removeClass("rel pd").find("em").hide()}})};