{include file="$gentemplates/$header_tpl"}
	<h2>{$lang.answers.menu.my_q}</h2>
	{include file="$gentemplates/answ_menu.tpl"}
	<input type="button" onclick="location.href='{$file_name}?sel=my_q';" value="{$lang.answers.menu.my_q}">
	<input type="button" onclick="location.href='{$file_name}?sel=my_a';" value="{$lang.answers.menu.my_a}">

	<p style="margin: 10px 0;">
		<input type="radio" {if $form.open_sort}checked="checked"{/if} onclick="location.href='{$file_name}?sel=my_q&filter=open&page=1';"/> {$lang.answers.opened_qs}&nbsp;&nbsp;
		<input type="radio" {if $form.closed_sort}checked="checked"{/if} onclick="location.href='{$file_name}?sel=my_q&filter=closed&page=1';"/> {$lang.answers.closed_qs}&nbsp;&nbsp;
    </p>
	
	{include file="$gentemplates/pagination_top.tpl"}
	
	<div class="qa_main">
		{foreach name=q from=$questions item=item}
		<div style="margin-bottom: 10px;">
			<div id="tr_q{$item.id}" class="overflowhidden">
				<span class="text_head">{$lang.answers.asked}:</span> {if !$item.life_time}{$lang.answers.asked_now}{else}{$item.life_time} {$lang.answers.ago}{/if}&nbsp;|&nbsp;
				<span class="text_head">{$lang.answers.count_answers}:</span> {$item.answers_count}
				{if $item.is_open == '0'}
					&nbsp;|&nbsp;
					<span class="text_head">{$lang.answers.closed}:</span> {if !$item.closed_time}{$lang.answers.asked_now}{else}{$item.closed_time} {$lang.answers.ago}{/if}
				{/if}
				<br />
				<p>
					<span class="text_head">{$lang.answers.question}:</span> {$item.text}
				</p>
				<span class="text_head">{$lang.answers.details}:</span> 
				<div class="wysiwyg_content">{$item.details}</div><br />
				<span class="text_head">{$lang.answers.in}:</span> {$item.path}<br />
				{if $item.is_open == '0'}
					<span class="text_head">{$lang.answers.best_answer}:</span> <span class="wysiwyg_content">{$item.best_answer_text}</span>
				{/if}
			
				{if $item.answers_count > '0'}
				<div id="show_answers_{$item.id}" class="search_form_hide_show">
					<div class="hide_line_text" id="show_link_{$item.id}" onclick="viewAnswers('{$item.id}'); return false;" style="cursor: pointer;" >
						{$lang.answers.show_answers}
						<ins id="show_image_{$item.id}" class="show_search_form sub_icon" title="{$lang.button.show_search_form}">&nbsp;</ins>
					</div>
				</div>                    
                <div id="hide_answers_{$item.id}" class="search_form_hide_show" style="display: none;">
					<div class="hide_line_text" id="hide_link_{$item.id}" onclick="cropAnswers('{$item.id}'); return false;" style="cursor: pointer;" >
						{$lang.answers.hide_answers}
						<ins id="hide_image_{$item.id}" class="hide_search_form sub_icon" title="{$lang.button.hide_search_form}">&nbsp;</ins>
					</div>
				
					<div id="tr_answer{$item.id}">
						<div id="answers_area{$item.id}"></div>
					</div>
				</div>
				{/if}
			<div id="tr_answer{$item.id}" style="display:none;">
				<div id="answers_area{$item.id}"></div>
			</div>
		</div>
		{foreachelse}
		<p>{$lang.answers.no_questions}</p>
		{/foreach}
	</div>
	
	{include file="$gentemplates/pagination_bottom.tpl"}
</div>
<div id="tmp" style="display:none;"></div>
<script type="text/javascript">
file_name = '{$file_name}';
tmp_text = '{$lang.ajax.tmp_text}';
{literal}

function viewAnswers(id){
	refreshAnswers(id);
    $('#show_answers_'+id).hide();
    $('#hide_answers_'+id).show();
	/*$('#hide_link_'+id).show();
	$('#show_link_'+id).hide();
	$('#hide_image_'+id).show();
	$('#show_image_'+id).hide();*/
}

function refreshAnswers(id){
	tr_answer_obj = getById('tr_answer'+id);
	tr_answer_obj.style.display = '';
	answers_area_obj = getById('answers_area'+id);
	answers_area_obj.style.display = '';

	str_adds = '';
	a_page_obj = getById('answer_page_num'+id);
	if(a_page_obj!=null){
		str_adds +='&ans_page'+id+'='+a_page_obj.value;
	}else{
		str_adds +='&ans_page'+id+'=1';
	}

	str = 'sel=get_answers&id_parent='+id+str_adds;
	destination_odj = getById('answers_area'+id);
	anisochronous = true;
	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);
}

function goToAnswerPage(num,id){
	a_page_obj = getById('answer_page_num'+id);
	a_page_obj.value = num;
	refreshAnswers(id);
}

function makeBest(id, id_parent){

	str = 'sel=make_best&id='+id+'&id_parent='+id_parent;
	destination_odj = getById('tmp');
	anisochronous = false;
	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);
	goToAnswerPage('1', id_parent);
}

function cropAnswers(id){
    $('#show_answers_'+id).show();
    $('#hide_answers_'+id).hide();
	/*$('#hide_link_'+id).show();
	$('#show_link_'+id).hide();
	$('#hide_image_'+id).show();
	$('#show_image_'+id).hide();*/
}

function getById(id){
	return document.getElementById(id);
}
{/literal}
</script>
{include file="$gentemplates/$footer_tpl"}