{include file="$gentemplates/$header_tpl"}
	<div class="qa_main">
		<h2>{$general}</h2>
		
		{include file="$gentemplates/answ_menu.tpl"}
		
		<div class="homepage_answer">
				<div class="float_left">
					<h3>{$lang.answers.ask_your_question}</h3>
					<form action="{$file_name}" method="post">
					{$form.hiddens}
						<textarea cols="" rows="" name="question" id="question" onkeyup="BadWords('question');" style="width:300px; height:100px;">{$lang.answers.default_q}</textarea>
                        <div style="width: 300px;" id="bad_div_question" class="bad_div_left"></div>
						<p>
							<input type="button" value="{$lang.button.next}" onclick="this.form.submit();" />
						</p>
					</form>
				</div>
				<div class="float_right" style="width: 45%;">
					<h3>{$lang.answers.answer_questions}</h3>
					<p>{$lang.answers.answer_questions_comment}</p>
					<p>
					<input type="button" value="{$lang.answers.answer_questions_button}" onclick="location.href='{$file_name}?sel=answer'" />
					</p>
					{include file="$gentemplates/answ_info.tpl"}
				</div>
				
		</div>
		
		<h3 class="p-b5">{$lang.answers.hp_q_header}</h3>

		{foreach name=q from=$questions item=item}
			<div class="overflowhidden" style="margin-bottom: 10px;">
				<div class="float_left" style="margin-{$default_right}: 10px;">
					{if !$item.root_user}
						<a class="imgcanvas_container" href="{$item.profile_link}"><img alt="" class="imgcanvas" src="{$item.icon_url}" border="0"/></a>
					{else}
						<img alt="" class="imgcanvas" src="{$item.icon_url}" border="0"/>
					{/if}
					<br />
					{if !$item.root_user}
						<a href="{$item.profile_link}">{$item.name}</a>
					{else}
						{$item.name}
					{/if}
					<br />
					{$item.age} {$lang.answers.ans}
				</div>
				<div>
					<span class="text_head">{$lang.answers.asked}:</span>&nbsp;{if !$item.life_time}{$lang.answers.asked_now}{else}{$item.life_time}&nbsp;{$lang.answers.ago}{/if}&nbsp;|&nbsp;
					<span class="text_head">{$lang.answers.count_answers}:</span>&nbsp;{$item.answers_count}
					{if $item.is_open == '0'}
						&nbsp;|&nbsp;<span class="text_head">{$lang.answers.closed}:</span>&nbsp;{if !$item.closed_time}{$lang.answers.asked_now}{else}{$item.closed_time}&nbsp;{$lang.answers.ago}{/if}
					{/if}
					<br />
					<span class="text_head">{$lang.answers.question}:</span>&nbsp;{$item.text}<br />
					{if $item.details}<span class="text_head">{$lang.answers.details}:</span><span class="wysiwyg_content">{$item.details}</span><br />{/if}
					<span class="text_head">{$lang.answers.in}:</span>&nbsp;{$item.path}<br />
					{if $item.is_open == '0'}
						<span class="text_head">{$lang.answers.best_answer}:</span>&nbsp;<span class="wysiwyg_content">{$item.best_answer_text}</span>
					{/if}
                    {if $item.answers_count > '0'}
					<div class="search_form_hide_show" id="show_answers_{$item.id}" >						
						<div class="hide_line_text" id="show_link_{$item.id}" onclick="viewAnswers('{$item.id}'); return false;">
							{$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>
			</div>

		{foreachelse}
			<p>{$lang.answers.no_questions}</p>
		{/foreach}
		
		<h3 class="p-b5">{$lang.answers.top_experts}</h3>
		
		{foreach name=exp from=$experts item=item}
			<div class="overflowhidden" style="margin-bottom: 10px;">
				<div class="float_left" style="margin-{$default_right}: 10px;">
					{if !$item.root_user}
						<a class="imgcanvas_container" href="{$item.profile_link}"><img alt="" class="imgcanvas" src="{$item.icon_url}" border="0"/></a>
					{else}
						<img alt="" class="imgcanvas" src="{$item.icon_url}" border="0"/>
					{/if}
					<br />
					{if !$item.root_user}
						<a href="{$item.profile_link}">{$item.name}</a>
					{else}
						{$item.name}
					{/if}
					<br />
					{$item.age} {$lang.answers.ans}
				</div>
				<div>
					{$lang.answers.best_answ_count}: {$item.answers_count}<br />
					{$lang.answers.best_answ_in}:
					{foreach name=cats from=$item.count_answ_in_cats item=subitem}
						{$subitem.name} ({$subitem.answ_count}){if !$smarty.foreach.cats.last},{/if}
					{/foreach}
					<p>
						<img alt="" src="{$site_root}{$template_root}{$template_images_root}/expert.gif" align="{$default_left}" />
						<a id="view_exp_answers_link{$item.id_user}" href="#" onclick=" viewExpAnswers('{$item.id_user}'); return false;">{$lang.answers.view_exp_answ}</a>
					</p>
					<div id="tr_exp_answer{$item.id_user}" style="display:none;">
						<div id="exp_answers_area{$item.id_user}"></div>
					</div>
				</div>
			</div>

		{foreachelse}
			<p>{$expert_ans}</p>
		{/foreach}
		
	</div>
<div id="tmp" style="display:none;"></div>

{literal}
<script type="text/javascript">
file_name = '{/literal}{$file_name}{literal}';
tmp_text = '{/literal}{$lang.ajax.tmp_text}{literal}';

function viewAnswers(id){
	id = parseInt(id);
	refreshAnswers(id);
    $('#hide_answers_'+id).show();
    $('#show_answers_'+id).hide();
	/*$('#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){
	num = parseInt(num);
	id = parseInt(id);
	a_page_obj = getById('answer_page_num'+id);
	a_page_obj.value = num;
	refreshAnswers(id);
}

function makeBest(id, id_parent){
	id = parseInt(id);
	id_parent = parseInt(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){
	id = parseInt(id);
    $('#hide_answers_'+id).hide();
    $('#show_answers_'+id).show();
	/*$('#hide_link_'+id).hide();
	$('#show_link_'+id).show();
	$('#hide_image_'+id).hide();
	$('#show_image_'+id).show();
	answers_area_obj = getById('answers_area'+id);
	tr_answer_obj = getById('tr_answer'+id);
	tr_answer_obj.style.display = 'none';*/
}

//////experts

function viewExpAnswers(id_user){
	id_user = parseInt(id_user);
	refreshExpAnswers(id_user);
}

function refreshExpAnswers(id_user){
	id_user = parseInt(id_user);
	tr_answer_obj = getById('tr_exp_answer'+id_user);
	tr_answer_obj.style.display = '';
	answers_area_obj = getById('exp_answers_area'+id_user);
	answers_area_obj.style.display = '';

	str_adds = '';
	a_page_obj = getById('exp_page_num'+id_user);
	if(a_page_obj!=null){
		str_adds +='&exp_ans_page'+id_user+'='+a_page_obj.value;
	}else{
		str_adds +='&exp_ans_page'+id_user+'=1';
	}

	str = 'sel=get_exp_answers&id_user='+id_user+str_adds;
	destination_odj = getById('exp_answers_area'+id_user);
	anisochronous = true;
	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);
}

function goToExpAnswerPage(num,id_user){////////////////////////////////
	id_user = parseInt(id_user);
	num = parseInt(num);
	a_page_obj = getById('exp_page_num'+id_user);
	a_page_obj.value = num;
	refreshExpAnswers(id_user);
}

function cropExpAnswers(id){
	id = parseInt(id);
	answers_area_obj = getById('exp_answers_area'+id);
	tr_answer_obj = getById('tr_exp_answer'+id);
	tr_answer_obj.style.display = 'none';
}

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