<!--{<*
 * 查看问题模板
 * create time: 2011-5-7 上午10:09:06
 * @version $Id: view.tpl 221 2012-11-25 08:01:48Z liqt $
 * @author LiQintao
*>}-->

<script type="text/javascript">
function concern_question(current)
{
	var q_id = current.attr("question");
	$.get("", {m: "module_qa_question.ui_question.concern", q_id: q_id}, function (msg) {
		load_question_score(q_id);
		load_question_concern(q_id);

		$("#feedback-concerned").append(msg);
        $("#feedback-concerned").fadeIn();
        $("#feedback-concerned").fadeOut(2000, function(){
           $("#feedback-concerned").empty();
           show_concerned_info(q_id);
        });
	});
}

function unconcern_question(current)
{
	var q_id = current.attr("question");
	$.get("", {m: "module_qa_question.ui_question.unconcern", q_id: q_id}, function (msg) {
		load_question_concern(q_id);

		$("#feedback-concerned").append(msg);
        $("#feedback-concerned").fadeIn();
        $("#feedback-concerned").fadeOut(2000, function(){
           $("#feedback-concerned").empty();
           show_concerned_info(q_id);
        });
	});
}

function show_concerned_info(q_id)
{
	$.get("", {m: "module_qa_question.ui_question.check_concern_status", q_id: q_id}, function (data) {
		if (data)// 已关注
		{
			$('.text-concerned').show();
			$('.concern-question').hide();
			$('.unconcern-question').show();
		}
		else
		{
			$('.text-concerned').hide();
			$('.concern-question').show();
			$('.unconcern-question').hide();
		}
	});
}

function load_question_score(q_id)
{
	$.get("", {m: "module_qa_question.ui_question.get_score", q_id: q_id}, function (data) {
		$(".question_score").text(data);
	});
}

function load_question_concern(q_id)
{
	$.get("", {m: "module_qa_question.ui_question.get_concern", q_id: q_id}, function (data) {
		$(".question_concern").text(data);
	});
}

function vote_answer(current)
{
	var a_id = current.attr("answer");
	$.get("", {m: "module_qa_answer.ui_answer.vote", a_id: a_id}, function (msg) {
		load_answer_score(a_id);

		$(".feedback-vote-answer[answer='"+a_id+"']").append(msg);
		$(".feedback-vote-answer[answer='"+a_id+"']").fadeIn();
		$(".feedback-vote-answer[answer='"+a_id+"']").fadeOut(2000, function(){
			$(".feedback-vote-answer[answer='"+a_id+"']").empty();
        });
	});
}

function load_answer_score(a_id)
{
	$.get("", {m: "module_qa_answer.ui_answer.get_score", a_id: a_id}, function (data) {
		$(".answer-score[answer='"+a_id+"']").text(data);
	});
}

function check_submit_answer(editor)
{
	$("#form-post-answer").submit(function () {
		if (editor.getSource().length < 1)
		{
			alert('答案内容不能为空。');
			return false;
		}
		else
		{
			// 防止重复提交
			$("#btn_submit").clone().insertAfter($("#btn_submit")).attr("disabled","true");
			$("#btn_submit").hide();
		}
	});
}

$(function(){
	load_system_info();
	show_concerned_info('{<$q_id>}');
	var editor = load_xh_editor('a_content', 300);
	check_submit_answer(editor);
	$("#input_search").focus();

	$('.link-answer').click(function(){
{<if $flag_login>}
		editor.focus();// 回答输入焦点,ie不支持
{</if>}
	});
	
	$('.concern-question').click(function(e){
		e.preventDefault();
		concern_question($(this));
	});
	
	$('.unconcern-question').click(function(e){
		e.preventDefault();
		unconcern_question($(this));
	});
	
	$('.vote_answer').click(function(e){
		e.preventDefault();
		vote_answer($(this));
	});
});
</script>

{<include file=$header_tpl>}
	<div id="question-title" class="span-24">
		<h3>{<$q_title|escape:'html'>}</h3>
		
		<!-- JiaThis Button BEGIN -->
{<if $smarty.const.FLAG_ENABLE_JIATHIS == 1>}
		<div id="ckepop" style="margin-left:500px;">
			<span class="jiathis_txt">分享到：</span>
			<a class="jiathis_button_tsina"></a>
			<a class="jiathis_button_tqq"></a>
			<a class="jiathis_button_renren"></a>
			<a class="jiathis_button_qzone"></a>
			<a class="jiathis_button_kaixin001"></a>
			<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
		</div>
		<script type="text/javascript">
		var jiathis_config = {
    		title:"{<$q_title>} 看看解答：",
    		appkey:{
		        "tsina": "2853487719",
		        "tqq":"32f94afc2d174f02a049d4f356d70e2c"
		    },
		    ralateuid:{
		        "tsina":"2287920300"
		    }
    	};
		</script>
		<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js" charset="utf-8"></script>
		<!-- JiaThis Button END -->
{</if>}		
	</div>
    <div class="span-17 border">
    	<div id="question-main">
	    	<div id="top-info">
	    		<span class="color-concerned text-concerned" style="display:none;font-weight:bold;">已关注</span>
	    		<a class="concern-question" href="#" question="{<$q_id>}" style="display:none;"><span>+</span>我要关注</a>
	    		<a class="unconcern-question" href="#" question="{<$q_id>}" style="display:none;">取消关注</a>
	    		<a class="link-answer" href="#answer" question="{<$q_id>}">我来回答</a>
	    		<span id="feedback-concerned"></span>
	    		
	    		{<$link_edit_question>}
	    		{<$link_delete_question>}
	    		
	    		<span style="float:right;" {<if $q_lastedit_time>}title="最近由 {<$q_lastedit_id>} 更新于 {<$q_lastedit_time>}"{</if>}>
	    			<span class="author">{<$q_owner_id>}</span>
	    			<span style="color:#101F78;padding:0 1px;">({<$owner_score>}分)</span>
	    			 @ {<$q_ask_time>}
	    		</span>
	    		
	    	</div>
	    	
	        <div id="content">
	        	{<$q_content>}
	        </div>
	        
	        <div id="tags" class="color-tag" title="问题标签">
	        	[
{<section name=i loop=$tag_list start=0>}
				<span title="{<$tag_list[i].t_description>}">
					<a href="{<$tag_list[i].link>}">{<$tag_list[i].name>}</a>
				</span>
{</section>}
				]
	        </div>
	        
	        <div id="answer-header">
	        	<h3>{<$q_answer_quantity>}个答案</h3>
	        	<div id="answer-sort">
	        		<a href="{<$link_answer_sort_by_time>}" {<if $flag_answer_sort_newest>}class="active"{</if>}>按时间排序</a>
	        		<a href="{<$link_answer_sort_by_score>}" {<if $flag_answer_sort_score>}class="active"{</if>}>按得分排序</a>
	        	</div>
	        </div>
	        
	        <div id="answer-index">
{<section name=i loop=$data_list_answer start=0>}
				<a name="{<$data_list_answer[i].a_sn>}"></a>
	    		<div class="answer-item{<if ($smarty.section.i.index is even)>} odd{</if>}">
	    			<div class="top-info">
	    				<span class="answer-score color-score" answer="{<$data_list_answer[i].a_id>}">{<$data_list_answer[i].a_score>}</span>分
	            		<a class="vote_answer" answer="{<$data_list_answer[i].a_id>}" href="#">对我有用</a>
	            		<span class="feedback-vote-answer" answer="{<$data_list_answer[i].a_id>}"></span>
	            		{<$data_list_answer[i].link_edit>}
	            		{<$data_list_answer[i].link_delete>}
	            		
	            		<span style="float:right;" {<if $data_list_answer[i].a_lastedit_time>}title="最近由 {<$data_list_answer[i].a_lastedit_id>} 更新于 {<$data_list_answer[i].a_lastedit_time>}"{</if>}>
	            			<span class="author">{<$data_list_answer[i].a_owner_id>}</span>
	            			<span style="color:#101F78;padding:0 1px;">({<$data_list_answer[i].owner_score>}分)</span>
	            			 @ {<$data_list_answer[i].a_answer_time>}
	            		</span>
	    			</div>
	    			<div class="content">
	    				{<$data_list_answer[i].a_content>}
	    			</div>
	    		</div>
{<sectionelse>}
	    		<div class="no-answer">
	    			暂无答案。
	    		</div>
{</section>}
        	</div>
		
{<if $q_answer_quantity > 5>}
	        <div class="pages">
				答案分页：{<$index_split_pages>}
			</div>
			<hr>
{</if>}
		
			<div id="post-answer">
	    		<form id="form-post-answer" method="post" action="{<$url_answer>}">
	    			<fieldset>
	    				<legend>我的回答</legend>
	    				<a name="answer"></a>
{<if !$flag_login>}
    					<p>请<a href="{<$link_login>}">登录</a>或者<a href="{<$link_register>}" target="_blank">免费注册</a>后再进行回答。</p>
{</if>}
{<if $flag_login>}
    					<p>{<$a_content>}</p>
    					<p>{<$btn_submit>}</p>
{</if>}
	    			</fieldset>
	        	</form>
	    	</div>
	    </div>
    </div>
    
    <div class="span-7 last" id="sidebar">
    	<div class="module">
    		<div class="item">
				<span style="">[得分]</span>
				<span class="color-score" style="font-size:2.4em;font-weight:bold;">{<$q_score>}</span>
			</div>
			<div class="item">
				<span style="">[答案]</span>
				<span class="color-answer" style="font-size:1.1em;font-weight:bold;">{<$q_answer_quantity>}</span>
			</div>
			<div  class="item">
				<span style="">[关注]</span>
				<span class="color-concerned" style="font-size:1.1em;font-weight:bold;">{<$q_concerned>}</span>
			</div>
			<div  class="item">
				<span style="">[浏览]</span>
				<span class="color-views" style="font-size:1.1em;font-weight:bold;">{<$q_views>}</span>
			</div>
    	</div>
    	
    	<div id="tags" class="module">
    		<h5>所属标签</h5>
    		<ul>
{<section name=i loop=$tag_list start=0>}
				<li>
					<a href="{<$tag_list[i].link>}" title="{<$tag_list[i].t_description>}">{<$tag_list[i].name>}</a>
					<span style="font-weight:bold;color:#444;" title="标签 {<$tag_list[i].t_name>} 拥有的问题总数为 {<$tag_list[i].question_quantity>} 个">× {<$tag_list[i].question_quantity>}</span>
				</li>
{</section>}
			</ul>
		</div>
		
{<if $smarty.const.FLAG_ENABLE_ADSENSE == 1>}
		<div class="module">
			<div style="padding-left: 3px;">
	        	<script type="text/javascript"><!--
	            google_ad_client = "ca-pub-3547787795244750";
	            /* 右边栏广告 */
	            google_ad_slot = "3246311279";
	            google_ad_width = 250;
	            google_ad_height = 250;
	            //-->
	            </script>
	            <script type="text/javascript"
	            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
	            </script>
	        </div>
	    </div>
{</if>}
		
		<div class="module">
    		<h5>相关问题</h5>
			<ul>
{<section name=i loop=$question_relation_list start=0>}
		<li>
			<a href="{<$question_relation_list[i].link>}" title="{<$question_relation_list[i].q_title>}">{<$question_relation_list[i].title>}</a>
		</li>
{</section>}
			</ul>
		</div>
		
		<div id="hot" class="module">
			<h5>热点问题</h5>
			<ul>
{<section name=i loop=$question_most_concerned_list start=0>}
        		<li>
        			<a href="{<$question_most_concerned_list[i].link>}" title="{<$question_most_concerned_list[i].q_title>}">{<$question_most_concerned_list[i].title>}</a>
        		</li>
{</section>}
			</ul>
		</div>

		<div id="need" class="module">
			<h5>急需解答</h5>
			<ul>
{<section name=i loop=$question_most_need_answer_list start=0>}
        		<li>
        			<a href="{<$question_most_need_answer_list[i].link>}" title="{<$question_most_need_answer_list[i].q_title>}">{<$question_most_need_answer_list[i].title>}</a>
        		</li>
{</section>}
			</ul>
		</div>

		<div id="random" class="module">
			<h5>随机问题</h5>
			<ul>
{<section name=i loop=$question_random_list start=0>}
        		<li>
        			<a href="{<$question_random_list[i].link>}" title="{<$question_random_list[i].q_title>}">{<$question_random_list[i].title>}</a>
        		</li>
{</section>}
			</ul>
		</div>
    </div>

{<include file=$footer_tpl>}