<?php echo Wo_LoadPage('forum/headers/header'); ?>
<div class="row">
	<label class="col-md-2"></label>
	<div class="col-md-8">
		<div class="red-list">
			<div class="wo_settings_page">
				<h3><?php echo $wo['lang']['edit_topic']; ?></h3>
				<form class="form" id="editopic" method="post">
					<div class="setting-panel row">
						<div class="sun_input">
							<textarea id="topicpostcont" name="topicpost" placeholder="<?php echo $wo['lang']['edit']?>"><?php echo br2nlf($wo['thread']['post']); ?></textarea>
							<label for="topicpostcont"><?php echo $wo['lang']['edit']?></label>
						</div>
						<!-- Text input-->
						<div class="sun_input">
							<input type="text" class="form-control" name="headline" id="headline" placeholder="<?php echo $wo['lang']['subject']?>" value="<?php echo $wo['thread']['orginal_headline']; ?>">
							<label for="headline"><?php echo $wo['lang']['subject']?></label>
						</div>
					</div>
					<div id="editopic-alert"></div>
					<div class="form-group last-sett-btn modal-footer">
						<div class="ball-pulse"><div></div><div></div><div></div></div>
						<button type="submit" class="btn btn-main setting-panel-mdbtn"><?php echo $wo['lang']['save'];?></button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- .col-md-8 -->
	<label class="col-md-2"></label>
</div>

<script>
jQuery(document).ready(function($) {
	$('#editopic').ajaxForm({
	      url: Wo_Ajax_Requests_File()  +  '?f=editopic&tid=<?php echo $wo['thread']['id']; ?>&hash=' + $('.main_session').val(),
	      beforeSend: function() {
	        Wo_progressIconLoader($('#editopic').find('button'));
	      },
	      success: function(data) {
	        scrollToTop();
	        if (data['status'] == 200) {
	         	$("#editopic-alert").html('<div class="alert alert-success">'+ data['message'] +'</div>');
	          	window.location = data['url'];
	        } else {
	         	$("#editopic-alert").html('<div class="alert alert-danger">' + data['message'] + '</div>');
	        } 
	        Wo_progressIconLoader($('#editopic').find('button'));
	      }
	});
	$("#topicpostcont").bbcode()
	$("#topicpostcont").autogrow({vertical: true, horizontal: false});

});
</script>

<?php echo Wo_LoadPage('forum/headers/footer'); ?>