{include file="$gentemplates/$header_tpl"}

	<h2>{$lang.answers.ask_your_question}</h2>
	{include file="$gentemplates/answ_menu.tpl"}

	{if $err}
	<p class="error_msg" style="padding-top: 20px;">{$err}</p>
	{/if}

	
		<form name="add_question" action="{$file_name}" method="post">
		{$form.hiddens}
		<p>{$lang.answers.your_question}:</p>
		<p>
            <textarea cols="" rows="" name="question" id="question" onkeyup="BadWords('question');" style="width:250px; height:100px;">{$data.question}</textarea>
            <div id="bad_div_question" class="bad_div_left"></div>    
        </p>
		<p>{$lang.answers.details}:</p>
		<p>
			{$redactor}
            <textarea name="details" id="details" class="redactor_normal">{$data.details}</textarea>
            <div id="bad_div_details" class="bad_div_left"></div>
        </p>
		<p>{$lang.answers.categories}:</p>
		<p>
			<div id="cats0">
			<select name="categs" size="10" onchange="javascript: getSubCats(0, this.value); return false;" style="width:250px; padding-{$default_left}:3px;">
				{foreach name=category from=$categories item=item}
				<option value="{$item.id}" {if $data.cats == $item.id}selected="selected"{/if}>{$item.name}</option>
				{/foreach}
			</select>
			</div>
		</p>
		<p>
			<div id="cats" style="display:inline">
			{if $categories1}
				<select name="cats1" size="10" style="width:250px; padding-{$default_left}:3px;">
					{foreach name=category1 from=$categories1 item=item}
					<option value="{$item.id}" {if $data.cats1 == $item.id}selected="selected"{/if}>{$item.name}</option>
					{/foreach}
				</select>
			{/if}
			</div>
		</p>
		<div><input type="button" value="{$lang.answers.add_q}" onclick="addQ(document.add_question);" /></div>
		</form>

<script type="text/javascript">
file_name = '{$file_name}';
tmp_text = '{$lang.ajax.tmp_text}';
{literal}
function getSubCats(parent_level, id_parent){
	str='sel=get_cats&parent_level='+parent_level+'&id_parent='+id_parent;
	destination_odj = document.getElementById('cats');
	anisochronous = true;
	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);
}

function addQ(form){
	if (form.question.value == ''){
		alert('{/literal}{$lang.answers.empty_q_field|escape:javascript}{literal}');
		return false;
	}
	if (form.categs.value == ''){
		alert('{/literal}{$lang.answers.choose_cat|escape:javascript}{literal}');
		return false;
	}
	if (form.cats1.value == ''){
		alert('{/literal}{$lang.answers.choose_subcat|escape:javascript}{literal}');
		return false;
	}

	form.submit();
}

{/literal}
</script>
{include file="$gentemplates/$footer_tpl"}