<?php TPL::output('global/header.tpl.htm'); ?>

<div class="tny-basic main tny-clear allbg">
<div class="tny-left lsidebar">
<form action="publish/ajax/<?php if ($this->question_info['question_id']) { ?>modify<?php } else { ?>publish<?php } ?>_question/" method="post" id="question_form" onsubmit="return false;">
<input type="hidden" name="post_hash" value="<?php echo new_post_hash(); ?>" />
<input type="hidden" name="attach_access_key" value="<?php echo $this->attach_access_key; ?>" />
<input type="hidden" name="question_id" id="question_id" value="<?php echo $this->question_info['question_id']; ?>" />
<input type="hidden" name="ask_user_id" value="<?php echo $_POST['ask_user_id']; ?>" />
<?php if ($this->question_category_list) { ?>
<select name="category_id" class="tny-hide" id="category_id">
	<option value="0">- Select category -</option>
	<?php echo $this->question_category_list; ?>
	</select>
<?php } ?>
<div class="b_restrain">
        <h4 class="tny-gloCor trends-H3 content-H3"><b>Ask a question</b></h4>
		<div class="a_question">
			<div class="qsAsk">
				<h4>Question title:</h4>
				<div class="qsAskQuestion rel">
				<div class="qsClassList abs" id="category_list">
					<span class="qsSelect  glotxtclass a_txtClass rel" id="category_container" onclick="$.Q.selectd({fg:this,listId:$('#tny-data_list'),arrowsId:$('#a_arr'),selectId:$('#a_select'),category_id:$('#category_id')});"><big id="a_select" class="tny-txtHide">Select category</big><em title="Select category" class="abs tny-small" id="a_arr"></em></span>
					<div class="tny-data_list abs" id="tny-data_list">
						<em class="arrows"></em>
						<p class="tny-list_p"><a href="javascript:;">Please wait...</a></p>
						
					</div>
				</div>
                <input type="text"  name="question_content" id="question_contents" value="<?php echo $this->question_info['question_content']; ?>" onFocus="$.focus(this,'Question title...');" class=" a_txtClass question_title_txt glotxtclass"/>
			</div>
		</div>
		
		<div class="qsAsk">
			<h4>Supplement question (optional):</h4>
			<div class="qsReplenish">
				<textarea name="question_detail" id="question_detail" class="glotxtclass txtHeight a_qstxt advanced_editor" onFocus="$.focus(this,'');"><?php echo $this->question_info['question_detail']; ?></textarea>
               
					<div class="acceMain">
						<div class="uploadMain" id="file_uploader_question">
							
						</div>
					</div>
				</div>
			</div>
			
			<?php if (!$this->question_info['question_id']) { ?>
			<div class="qsAsk">
			<h4 style="padding-bottom:0;">Add topic: <span class="q_topicMuster" id="PublicTopic">
				<?php if ($_GET['topic_title']) { ?>
				<a style="" data-value="sds" class="glotopic rel pd"><?php echo urldecode($_GET['topic_title']); ?><em title="Delete" onclick="$.topic.deleted_topic(this,event,true); return false;" class="handle abs">×</em><input type="hidden" value="<?php echo urldecode($_GET['topic_title']); ?>" name="topics[]"></a>
				<?php } ?>
				
				<?php if ($_POST['topics']) { ?>
				<?php foreach ($_POST['topics'] AS $key => $val) { ?>
				<a style="" data-value="sds" class="glotopic rel pd"><?php echo $val; ?><em title="Delete" onclick="$.topic.deleted_topic(this,event,true); return false;" class="handle abs">×</em><input type="hidden" value="<?php echo $val; ?>" name="topics[]"></a>
				<?php } ?>
				<?php } ?>
			</span>
				<span class="q_editor tny-small" title="Topic Edit" onClick="$.topic.editor_topic({flg:this,make:true});" id="editor_topicBtns" style="margin-bottom:5px;">Topic Edit</span></h4>
			</div>
			<?php } ?>
		
			<?php if ($this->human_valid) { ?>
			<div class="qsAsk">
				<h4>Validation code:</h4>
				<p><input type="text" name="seccode_verify" value="Verification code" onFocus="$.focus(this,'Verification code');" class="glotxtclass a_txtClass a_wcode"/> <img id="captcha" onclick="this.src = GET_BASE_URL + '/account/captcha/rnd-' + Math.floor(Math.random() * 10000);" title="Click change to another one" src=""></p>
			</div>
			<?php } ?>
		
			<div class="qsAsk tny-tr" style=" padding-top:5px;">
				<?php if ($this->question_info['question_id'] AND ((!$this->question_info['lock'] AND ($this->question_info['published_uid'] == $this->user_id OR $this->user_info['permission']['edit_question'])) OR $this->user_info['permission']['is_administortar'] OR $this->user_info['permission']['is_moderator'])) { ?>
				<span class="anonymity"><input type="checkbox" title="Delete question" name="do_delete" value="1" id="tny-delete"><label for="tny-delete">Delete question</label></span>
				<?php } ?>
				<?php if (!$this->question_info['question_id'] AND get_setting('anonymous_enable') == 'Y') { ?>
				<span class="anonymity"><input type="checkbox" title="Delete question" name="anonymous" value="1" id="anonymity"><label for="anonymity">Delete question</label></span>
				<?php } ?>
				<a class="btn-raplay2" href="javascript:;" title="Confirm to ask" id="sQuestions_submite">Confirm to ask</a>
			</div>
</div>		
</form>
</div>
</div>

<div class="rsidebar">
	<div class="rightMain"> 
		<div class="interest-user">
			<h3>Guide to ask question</h3>
			<div class="a_contxt">
			<p><b>● Question title:</b> Please use exact language to start your question
			<?php if (get_setting('question_title_limit') > 0 ) { ?>
			, and control <?php echo get_setting('question_title_limit'); ?>  within two words
			<?php } ?>.
			</p>
			<p><b>● Supplement question:</b> Please give more details about your question, please also provide supplement materials to help others to understand your question better</p>
			<p><b>● Select a topic:</b> Please select one or more topic to let more interested people see your question. All people can edit the topic after you posted the question.</p>
            <?php if (get_setting('integral_system_enabled') == 'Y') { ?>
			<p><b>● About credit:</b> You initiate a problem will consume <?php echo -get_setting('integral_system_config_new_question'); ?> Points, each one more will get back to you <?php echo -get_setting('integral_system_config_new_answer'); ?> Reward points, for your benefit, when problems in initiating hopes to better describe your problem as well as multi-use Search function</p>
            <?php } ?>
			</div>
		</div>
	</div>
</div>
</div>

<script type="text/javascript">
	var ATTACH_ACCESS_KEY = '<?php echo $this->attach_access_key; ?>';
	
	$(document).ready(function(e) {
        $('#category_id').length == 0 ? ($('#category_list').hide(),$('#category_list').parent().addClass('category_list')) :'';
		$('#category_id').val() > 0 ? $('#category_container').click() : '';
		$('#question_contents').changeElement($.searchEventQs);//Question Search;
		
		
		$('#sQuestions_submite').click(function(){
			if($('#question_contents').val() == 'Question title...' || $.trim($('#question_contents').val()).length == 0){
				$.alert('Initiated title of the question can not be empty, and greater than 5 characters...')
				return;
			}else if($.trim($('#question_contents').val()).length <=5){
				$.alert('Initiated title of the question can not less than 6 characters...')
				return;
			}else if($('#category_id').length > 0 && $('#category_id').val().length == 0){
				$.alert('Please select the categories of question...')
				return;
			}else{
				ajax_post($('#question_form'));
				
			}
		})
    });
</script>

<?php TPL::output('global/footer.tpl.htm'); ?>