<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>



<script language="JavaScript" type="text/javascript">
	function setCommentParent(comment_id, comment_parent_id) {
		//make form parent_id hidden field value = comment_id
		document.getElementById('id_comment_parent').value=comment_id;
		
		//turn comment red
		formElementCommentBody = 'comment_body_id_'+comment_id;
		formElementCommentLink = 'comment_link_id_'+comment_id;
		document.getElementById(formElementCommentBody).style.color='blue';
		document.getElementById(formElementCommentLink).style.textDecoration='none';
		
		document.getElementById('commentIntro').innerHTML ='<?php echo $lang['txt_comment_position1'];?>';
		
		document.location.href='#commentform';
	}
</script>

<script type="text/javascript" src="speller/spellChecker.js"></script>
<script type="text/javascript">
	function openSpellChecker() {
		var speller = new spellChecker();
		speller.spellCheckAll();
	}
</script>


<div id="comment_form">
	<h3>
	<?php
		if (isset($display) && $display == "preview_comment") {
		?>
		<?php echo $lang['hdr_comment_preview'];?>
		<?php }?>
	</h3>
	
	<?php
	if (!isset($_SESSION['user_id'])) { //not logged in
	?>
		<p>
			<b><?php echo $lang['txt_no_comment_allowed_login'];?></b><br />
		</p>
	<?php
	}
	else {
	?>
	
	<?php
	if (isset($display) && $display == "preview_comment") {
	?>
	<a name="commentpreview"></a>
	
	<p>
		<input type="hidden" name="comment_body" value="<?php echo $comment['comment_body'];?>" />
		<input type="hidden" name="comment_parent_id" value="<?php echo $comment['comment_parent_id'];?>" />
		<?php echo $comment['display_comment_body'];?><br />
	</p>

	<script language="JavaScript" type="text/javascript">
		document.location.href='#commentpreview';
	</script>
		
	<p align="right">
		<input type="submit" name="edit_comment_again" class="input_submit" value="<?php echo $lang['sub_edit_again'];?>" />&nbsp;&nbsp;
		<input type="submit" name="insert_comment" class="input_submit" value="<?php echo $lang['sub_add'];?>" /><br />
	</p>
	<?php
	}
	else {
	?>
	
	<span class="gui">
		<script language="JavaScript" type="text/javascript">
			var displayType = 'comment';
		</script>
		<script language="JavaScript" type="text/javascript" src="js/gui_wiki.js"></script>
	</span>
	
	<a name="commentform"></a>
	<h4><?php echo $lang['hdr_add_comment'];?></h4>
	
	<p>
		<span id="commentIntro"><?php echo $lang['txt_comment_position'];?></span>
	</p>
	
	<p>
		<input type="hidden" id="id_comment_parent" name="comment_parent_id" value="<?php if(isset($comment['comment_parent_id'])) { echo $comment['comment_parent_id'];}?>" />
		<textarea id="id_comment" name="comment_body" rows="4" cols="70"><?php if(isset($comment['comment_body'])) { echo $comment['comment_body'];}?></textarea><br />
		<script language="JavaScript" type="text/javascript">
			var txtarea = document.comment.comment_body;
		</script>
	</p>
	
	<p align="right">
		<?php if (isset($allow_spellcheck)) {?>
		<input type="button" class="input_submit" value="<?php echo $lang['sub_check_spelling'];?>" class="button_light" onClick="openSpellChecker();" />&nbsp;
		<?php }?>
		<input type="submit" name="preview_comment" class="input_submit" value="<?php echo $lang['sub_preview'];?>" />&nbsp;
		
		<input type="submit" name="insert_comment" class="input_submit" value="<?php echo $lang['sub_add'];?>" /><br />
	</p>
	<?php }?>
	<?php }?>

	<?php // if "edit again we jump to form
	if (isset($_POST['edit_comment_again']))  {
	?>
		<script language="JavaScript" type="text/javascript">
			document.location.href='#commentform';
		</script>
	<?php }?>
	</div>
</form>