<?session_start();
	include("logic.php");
	include("class.php");
	
	
	if (!$_SESSION['user'])
		header("Location: index.php");
	
	if ($_GET['act']) {
		removeLogicArgument($_GET['arg']);
		header("Location: logicedit.php?id=".$_GET['id']);
	}
	
	if ($_POST['gen_arg_id']) {
		if (!get_magic_quotes_gpc()) {
			$_POST['gen_arg_pos'] = addslashes($_POST['gen_arg_pos']);
			$_POST['gen_arg_input'] = addslashes($_POST['gen_arg_input']);
			$_POST['gen_arg_reason'] = addslashes($_POST['gen_arg_reason']);
			if ($_POST['gen_arg_input_2'])
				$_POST['gen_arg_input_2'] = addslashes($_POST['gen_arg_input_2']);
			if ($_POST['gen_arg_input_3'])
				$_POST['gen_arg_input_3'] = addslashes($_POST['gen_arg_input_3']);
			if ($_POST['gen_arg_input_4'])
				$_POST['gen_arg_input_4'] = addslashes($_POST['gen_arg_input_4']);
			if ($_POST['gen_arg_option_1']) {
				$_POST['gen_arg_option_1'] = addslashes($_POST['gen_arg_option_1']);
				$_POST['gen_arg_option_2'] = addslashes($_POST['gen_arg_option_2']);
			}
		}
		if ($_POST['gen_arg_id'] == -1)
			addLogicArgument($_GET['id'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_input']);
		else
			editLogicArgument($_POST['gen_arg_id'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_input']);
		
		if ($_POST['gen_arg_id_2'])
			editLogicArgument($_POST['gen_arg_id_2'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_input_2']);
			
		if ($_POST['gen_arg_id_3'])
			editLogicArgument($_POST['gen_arg_id_3'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_input_3']);
		
		if ($_POST['gen_arg_id_4'])
			editLogicArgument($_POST['gen_arg_id_4'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_input_4']);
		
		if ($_POST['gen_arg_option_1'])
			editOptionalInputs($_POST['gen_arg_id'], $_POST['gen_arg_option_1'], $_POST['gen_arg_option_2']);
		
		if ($_POST['gen_arg_reason'] && $_POST['gen_arg_reason'] != '')
			addLogicArgument($_GET['id'], 0, $_POST['gen_arg_subtype'], $_POST['gen_arg_pos'], $_POST['gen_arg_reason']);
	}
	
	if ($_POST['gen_obj_id']) {
		if (!get_magic_quotes_gpc()) {
			$_POST['gen_obj_pos'] = addslashes($_POST['gen_obj_pos']);
			$_POST['gen_obj_input'] = addslashes($_POST['gen_obj_input']);
			$_POST['gen_obj_reason'] = addslashes($_POST['gen_obj_reason']);
			if ($_POST['gen_obj_input_2'])
				$_POST['gen_obj_input_2'] = addslashes($_POST['gen_obj_input_2']);
			if ($_POST['gen_obj_input_3'])
				$_POST['gen_obj_input_3'] = addslashes($_POST['gen_obj_input_3']);
			if ($_POST['gen_obj_input_4'])
				$_POST['gen_obj_input_4'] = addslashes($_POST['gen_obj_input_4']);
			if ($_POST['gen_obj_option_1']) {
				$_POST['gen_obj_option_1'] = addslashes($_POST['gen_obj_option_1']);
				$_POST['gen_obj_option_2'] = addslashes($_POST['gen_obj_option_2']);
			}
		}
		if ($_POST['gen_obj_id'] == -1) {
		echo($_POST['gen_obj_subtype']."-".$_POST['gen_obj_pos']."-".$_POST['gen_obj_input']);
			addLogicArgument($_GET['id'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_input']);
		}
		else
			editLogicArgument($_POST['gen_obj_id'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_input']);
			
		if ($_POST['gen_obj_id_2'])
			editLogicArgument($_POST['gen_obj_id_2'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_input_2']);
			
		if ($_POST['gen_obj_id_3'])
			editLogicArgument($_POST['gen_obj_id_3'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_input_3']);
		
		if ($_POST['gen_obj_id_4'])
			editLogicArgument($_POST['gen_obj_id_4'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_input_4']);
		
		if ($_POST['gen_obj_option_1'])
			editOptionalInputs($_POST['gen_obj_id'], $_POST['gen_obj_option_1'], $_POST['gen_obj_option_2']);
		
		if ($_POST['gen_obj_reason'] && $_POST['gen_obj_reason'] != '')
			addLogicArgument($_GET['id'], 1, $_POST['gen_obj_subtype'], $_POST['gen_obj_pos'], $_POST['gen_obj_reason']);
	}
		
	$baseid = $_GET['id'];
	$base = getLogicBaseByID($baseid);
	if ($base['UserID'] != $_SESSION['user'] && $_SESSION['admin'] == 0)
		header("Location: logichome.php");
		
	$args = getLogicArguments($baseid);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit Argument Set</title>
<script language='javascript'>
<!-- 
	preview_open = false;

	function create(typeid) {
		switch(typeid) {
			case 0:	document.getElementById('gen_arg_start').style.display = 'none';
					position = document.getElementById('gen_arg_create_input').value;
					i = document.getElementById('gen_arg_create_subtype').selectedIndex;
					subtype = document.getElementById('gen_arg_create_subtype').options[i].value;
					newdiv = document.getElementById('gen_arg_body');
					newdiv2 = document.getElementById('gen_arg_body_inner');
					if (subtype == 0)
						newdiv2.innerHTML = "<input type='text' name='gen_arg_pos' id='gen_arg_pos' value=''  /> because "+
											 "<input type='text' name='gen_arg_input' id='gen_arg_input' value=''  />.";
					else if (subtype == 1)
						newdiv2.innerHTML = "Since <input type='text' name='gen_arg_input' id='gen_arg_input' value=''  />, "+
											 "<input type='text' name='gen_arg_pos' id='gen_arg_pos' value=''  />.";
					else if (subtype == 2)
						newdiv2.innerHTML = "<input type='text' name='gen_arg_input' id='gen_arg_input' value=''  />. Therefore, "+
											 "<input type='text' name='gen_arg_pos' id='gen_arg_pos' value=''  />.";
					newdiv.innerHTML += "<br><input type='submit' value='Update' /> <input type='button' onclick='remove(0);' value='Remove' /> "+
										"<input type='hidden' name='gen_arg_id' id='gen_arg_id' value='-1' />"+
										"<input type='hidden' name='gen_arg_subtype' id='gen_arg_subtype' value='"+subtype+"' />";
					newdiv.style.display = "block";
					document.getElementById('gen_arg_pos').value = position;
					break;
			case 1:	document.getElementById('gen_obj_start').style.display = 'none';
					position = document.getElementById('gen_obj_create_input').value;
					i = document.getElementById('gen_obj_create_subtype').selectedIndex;
					subtype = document.getElementById('gen_obj_create_subtype').options[i].value;
					newdiv = document.getElementById('gen_obj_body');
					newdiv2 = document.getElementById('gen_obj_body_inner');
					if (subtype == 0)
						newdiv2.innerHTML = "One might disagree with the position that <input type='text' name='gen_obj_pos' id='gen_obj_pos' "+
											"value=''  /> because <input type='text' name='gen_obj_input'"+
											" id='gen_obj_input' value=''  />.";
					else if (subtype == 1)
						newdiv2.innerHTML = "One might object that since <input type='text' name='gen_obj_input' id='gen_obj_input'"+
											" value=''  />, it is not true that <input type='text' "+
											"name='gen_obj_pos' id='gen_obj_pos' value=''  />.";
					else if (subtype == 2)
						newdiv2.innerHTML = "Not everyone agrees. It is true that <input type='text' name='gen_obj_input' id='gen_obj_input'"+
											" value=''  />.<br>Therefore, it is probably not true that <input type='text' name='gen_obj_pos' "+
											"id='gen_obj_pos' value=''  />.";
					newdiv.innerHTML += "<br><input type='submit' value='Update' /> <input type='button' onclick='remove(1);' value='Remove' /> "+
										"<input type='hidden' name='gen_obj_id' id='gen_obj_id' value='-1' />"+
										"<input type='hidden' name='gen_obj_subtype' id='gen_obj_subtype' value='"+subtype+"' />";
					newdiv.style.display = "block";
					document.getElementById('gen_obj_pos').value = position;
					break;

		}
	}

	function remove(typeid) {
		var arg;
		switch(typeid) {
			case 0:	arg = document.getElementById('gen_arg_id').value;
					break;
			case 1:	arg = document.getElementById('gen_obj_id').value;
					break;
		}
		if (arg != -1)
			window.location = 'logicedit.php?id=<? echo($baseid) ?>&act=1&arg='+arg;
		else
			window.location = 'logicedit.php?id=<? echo($baseid) ?>';
	}
	
	function preview() {
		if (!preview_open) {
			full_string = "";
			if (document.getElementById('gen_arg_pos') != null) {
				pos = document.getElementById('gen_arg_pos').value;
				input = document.getElementById('gen_arg_input').value;
				subtype = document.getElementById('gen_arg_subtype').value;
				numReasons = document.getElementById('gen_arg_input_2') != null?
							 	document.getElementById('gen_arg_input_3') != null?
									document.getElementById('gen_arg_input_4') != null?4:3:2:1;
				full_string += "<h4>General Argument</h4><div style='position:relative; left:20px;  width:37em'>";
				if (numReasons == 1) {
					if (subtype == 0)
						full_string += pos+" because "+input+".<br><br>";
					else if (subtype == 1)
						full_string += "Since "+input+", "+pos+".<br><br>";
					else if (subtype == 2)
						full_string += input+". Therefore "+pos+".<br><br>";
				}
				else if (numReasons == 2) {
					input2 = document.getElementById('gen_arg_input_2').value;
					if (subtype == 0)
						full_string += pos+" because "+input+" and "+input2+".<br><br>";
					else if (subtype == 1)
						full_string += "Since "+input+" and "+input2+", "+pos+".<br><br>";
					else if (subtype == 2)
						full_string += input+". Moreover, "+input2+". Therefore "+pos+".<br><br>";
				}
				else if (numReasons >= 3) {
					input2 = document.getElementById('gen_arg_input_2').value;
					input3 = document.getElementById('gen_arg_input_3').value;
					if (numReasons == 4)
						input4 = document.getElementById('gen_arg_input_4').value;
					optionA = document.getElementById('gen_arg_option_1').value;
					if (optionA == "<optional>") optionA = '';
					optionB = document.getElementById('gen_arg_option_2').value;
					if (optionB == "<optional>") optionB = '';
					full_string += "There are several reasons "+optionA+" that "+pos+
								   ". First, "+input+". Second, "+input2+".";
					if (numReasons == 3)
						full_string += " Finally, "+input3+".";
					else
						full_string += " Third, "+input3+". Finally, "+input4+".";
					full_string += " Consequently, "+optionB+" "+pos+".";
				}
				full_string += "</div>";
			}
			if (document.getElementById('gen_obj_pos') != null) {
				pos = document.getElementById('gen_obj_pos').value;
				input = document.getElementById('gen_obj_input').value;
				subtype = document.getElementById('gen_obj_subtype').value;
				numReasons = document.getElementById('gen_obj_input_2') != null?
								document.getElementById('gen_obj_input_3') !=null?
									document.getElementById('gen_obj_input_4') != null?4:3:2:1;
				full_string += "<h4>General Objection</h4><div style='position:relative; left:20px; width:37em'>";
				if (numReasons == 1) {
					if (subtype == 0)
						full_string += "One might disagree with the position that "+pos+" because "+input+".<br><br>";
					else if (subtype == 1)
						full_string += "One might object that since "+input+", it is not true that "+pos+".<br><br>";
					else if (subtype == 2)
						full_string += "Not everyone agrees.  It is true that "+input+". Therefore, it is probably not true that "
						               +pos+".<br><br>";
				}
				else if (numReasons == 2) {
					input2 = document.getElementById('gen_obj_input_2').value;
					if (subtype == 0)
						full_string += "One might disagree with the position that "+pos+" because "+input+" and "+input2+".<br><br>";
					else if (subtype == 1)
						full_string += "One might object that since "+input+" and "+input2+", it is not true that "+pos+".<br><br>";
					else if (subtype == 2)
						full_string += "Not everyone agrees.  It is true that "+input+". Moreover, "+input2+
						               ". Therefore, it is probably not true that "+pos+".<br><br>";
				}
				else if (numReasons >= 3) {
					input2 = document.getElementById('gen_obj_input_2').value;
					input3 = document.getElementById('gen_obj_input_3').value;
					if (numReasons == 4)
						input4 = document.getElementById('gen_obj_input_4').value;
					optionA = document.getElementById('gen_obj_option_1').value;
					if (optionA == "<optional>") optionA = '';
					optionB = document.getElementById('gen_obj_option_2').value;
					if (optionB == "<optional>") optionB = '';
					full_string += "There are several reasons "+optionA+" the position that "+pos+" is not true. First, "+input+
								   ". Second, "+input2+". ";
					if (numReasons == 3)
						full_string += "Finally, "+input3+".";
					else
						full_string += "Third, "+input3+". Finally, "+input4+".";
					full_string += " Consequently, "+optionB+" the position that "+pos+" is not true.";
				}
				full_string += "</div>";
			}
			document.getElementById('preview_text').innerHTML = full_string;
			document.getElementById('preview').style.display = 'block';
			document.getElementById('preview_button').value = 'Close Preview';
			preview_open = true;
		}
		else {
			document.getElementById('preview').style.display = 'none';
			document.getElementById('preview_button').value = 'Open Preview';
			preview_open = false;
		}
	}
	
	function addReason(type, isOpen) {
		document.getElementById("addReason"+type).disabled = isOpen;
		switch(type) {
			case 0:	document.getElementById('addGenArgReason').style.display = isOpen?'block':'none';
					break;
			case 1: document.getElementById('addGenObjReason').style.display = isOpen?'block':'none';
		}
	}
	
-->
</script>
</head>
<? include("header.php"); ?>
<h3> Edit Argument Set:</h3>
<? echo("<ul><li>".$base['BasePosition']."</li></ul>"); ?>
The generic argument form allows you to enter as many as four reasons to support or undermine a position.<br />
The same reason cannot both support and undermine the position.
<br />
<div style='position:relative; left:20px'>
<h4>Generic Argument</h4>
<form id='gen_arg_form' name='gen_arg_form' method='POST'>
<?	$sub_args = separateOnType($args, 0);
	$allowAdd = true;
	if (count($sub_args) > 0) {
		$arg = $sub_args[0];
		echo("<div style='position:relative; left:20px'>");
		if (count($sub_args) == 1) {
			if ($arg['Subtype'] == 0) {
				?>
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> because 
				<input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 1) {
				?>
				Since <input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />, 
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 2) {
				?>
				<input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />. Therefore, 
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
		}
		else if (count($sub_args) == 2) {
			$arg_2 = $sub_args[1];
			if ($arg['Subtype'] == 0) {
				?>
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> because 
				<input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  /> and 
				<input type='text' name='gen_arg_input_2' id='gen_arg_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 1) {
				?>
				Since <input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  /> and 
				<input type='text' name='gen_arg_input_2' id='gen_arg_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />, 
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 2) {
				?>
				<input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />. Moreover, 
				<input type='text' name='gen_arg_input_2' id='gen_arg_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />. Therefore, 
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
			?> <input type='hidden' name='gen_arg_id_2' id='gen_arg_id_2' value='<? echo($arg_2['ID']); ?>' /> <?
		}
		else if (count($sub_args) >= 3) {
			$arg_2 = $sub_args[1];
			$arg_3 = $sub_args[2];
			if (count($sub_args) == 4) {
				$arg_4 = $sub_args[3];
				$allowAdd = false;
			}
				?>
				<div style='font-size:11px; font-weight:bold; font-style:italic;'>
				Note: When filling in the optional inputs, '&lt;optional&gt;' or blank input will result in disregarding the input.
				</div><br />
				There are several reasons
				<input type='text' name='gen_arg_option_1' id='gen_arg_option_1' 
					value='<? echo(htmlspecialchars($arg['Optional_A'], ENT_QUOTES)); ?>' />
				that <input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />. <br />
				First, <input type='text' name='gen_arg_input' id='gen_arg_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />. <br />
				Second, <input type='text' name='gen_arg_input_2' id='gen_arg_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? if ($allowAdd) { ?>
				Finally, <input type='text' name='gen_arg_input_3' id='gen_arg_input_3' 
					value='<? echo(htmlspecialchars($arg_3['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? }
				   else { ?>
				Third, <input type='text' name='gen_arg_input_3' id='gen_arg_input_3' 
					value='<? echo(htmlspecialchars($arg_3['Input'], ENT_QUOTES)); ?>'  />. <br />
				Finally, <input type='text' name='gen_arg_input_4' id='gen_arg_input_4' 
					value='<? echo(htmlspecialchars($arg_4['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? } ?>
				Consequently, <input type='text' name='gen_arg_option_2' id='gen_arg_option_2' 
					value='<? echo(htmlspecialchars($arg['Optional_B'], ENT_QUOTES)); ?>' /> 
				<input type='text' name='gen_arg_pos' id='gen_arg_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<input type='hidden' name='gen_arg_id_3' id='gen_arg_id_3' value='<? echo($arg_3['ID']); ?>' /> 
				<input type='hidden' name='gen_arg_id_2' id='gen_arg_id_2' value='<? echo($arg_2['ID']); ?>' /> <?
				if (!$allowAdd) echo("<input type='hidden' name='gen_arg_id_4' id='gen_arg_id_4' value='".$arg_4['ID']."' />");
		}
		?>
		</div>
		<br />
		<input type='submit' value='Update' /> 
		<input type='button' onclick='addReason(0, true);' id='addReason0' value='Add Reason' <? echo($allowAdd?"":"disabled='disabled'"); ?> /> 
		<input type='button' onclick='remove(0);' value='Remove' />
		<input type='hidden' name='gen_arg_id' id='gen_arg_id' value='<? echo($arg['ID']); ?>' />
		<input type='hidden' name='gen_arg_subtype' id='gen_arg_subtype' value='<? echo($arg['Subtype']);?>' />
		<?
   }
   else { ?>
 		<div id='gen_arg_start' style='display:block; position:relative; left:20px'>
			<input type='text' name='gen_arg_create_input' id='gen_arg_create_input' 
				value='<? echo(htmlspecialchars($base['BasePosition'], ENT_QUOTES)); ?>' /> &nbsp;
			<select name='gen_arg_create_subtype' id='gen_arg_create_subtype'>
				<option value='0'>BECAUSE</option>
				<option value='1'>SINCE</option>
				<option value='2'>THEREFORE</option>
			</select> &nbsp;
			<input type='button' onclick='create(0);' value='Create' />
		</div>
		<div id='gen_arg_body' style='display:none;'>
			<div id='gen_arg_body_inner' style='position:relative; left:20px'>
			</div>
		</div>
<? } ?>
<div id='addGenArgReason' style='display:none; position:absolute; z-index:5; background-color:#FFFFCC;'>
	<table border='1'>
	<tr><td>
			<table cellpadding='2px'>
				<tr>
					<td colspan=2><b>Add new reason:</b></td>
				</tr>
				<tr>
					<td colspan=2><input type='text' name='gen_arg_reason' id='gen_arg_reason' value='' />
				</tr>
				<tr>
					<td><input type='submit' id='yes' name='yes' value='Add' /></td>
					<td><input type='button' value='Cancel' 
							onclick='addReason(0, false); document.getElementById("gen_arg_reason").value="";' /></td>
				</tr>
			</table>
	</td></tr>
	</table>
</div>
</form>

<h4>Generic Objection</h4>
<form id='gen_obj_form' name='gen_obj_form' method='POST'>
<? 
	$sub_args = separateOnType($args, 1);
	$allowAdd = true;
	if (count($sub_args) > 0) {
		$arg = $sub_args[0];
		echo("<div style='position:relative; left:20px'>");
		if (count($sub_args) == 1) {
			if ($arg['Subtype'] == 0) {
				?>
				One might disagree with the position that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> because 
				<input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 1) {
				?>
				One might object that since <input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />, 
				it is not true that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 2) {
				?>
				Not everyone agrees. It is true that <input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />.
				<br />Therefore, it is probably not true that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
		}
		else if (count($sub_args) == 2) {
			$arg_2 = $sub_args[1];
			if ($arg['Subtype'] == 0) {
				?>
				One might disagree with the position that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> because 
				<input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  /><br />
				 and <input type='text' name='gen_obj_input_2' id='gen_obj_input_2' 
				 	value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 1) {
				?>
				One might object that since <input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  /> and <br />
				<input type='text' name='gen_obj_input_2' id='gen_obj_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />, 
				it is not true that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
			else if ($arg['Subtype'] == 2) {
				?>
				Not everyone agrees. It is true that <input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />.<br />
				 Moreover, <input type='text' name='gen_obj_input_2' id='gen_obj_input_2' 
				 	value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />. 
				<br />Therefore, it is probably not true that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  />.
				<?
			}
		}
		else if (count($sub_args) >= 3) {
			$arg_2 = $sub_args[1];
			$arg_3 = $sub_args[2];
			if (count($sub_args) == 4) {
				$arg_4 = $sub_args[3];
				$allowAdd = false;
			}
			?>
				<div style='font-size:11px; font-weight:bold; font-style:italic;'>
				Note: When filling in the optional inputs, '&lt;optional&gt;' or blank input will result in disregarding the input.
				</div><br />
				There are several reasons
				<input type='text' name='gen_obj_option_1' id='gen_obj_option_1' 
					value='<? echo(htmlspecialchars($arg['Optional_A'], ENT_QUOTES)); ?>' />
				the position that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> is not true. <br />
				First, <input type='text' name='gen_obj_input' id='gen_obj_input' 
					value='<? echo(htmlspecialchars($arg['Input'], ENT_QUOTES)); ?>'  />. <br />
				Second, <input type='text' name='gen_obj_input_2' id='gen_obj_input_2' 
					value='<? echo(htmlspecialchars($arg_2['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? if ($allowAdd) { ?>
				Finally, <input type='text' name='gen_obj_input_3' id='gen_obj_input_3' 
					value='<? echo(htmlspecialchars($arg_3['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? }
				   else { ?>
				Third, <input type='text' name='gen_obj_input_3' id='gen_obj_input_3' 
					value='<? echo(htmlspecialchars($arg_3['Input'], ENT_QUOTES)); ?>'  />. <br />
				Finally, <input type='text' name='gen_obj_input_4' id='gen_obj_input_4' 
					value='<? echo(htmlspecialchars($arg_4['Input'], ENT_QUOTES)); ?>'  />. <br />
				<? } ?>
				Consequently, <input type='text' name='gen_obj_option_2' id='gen_obj_option_2' 
					value='<? echo(htmlspecialchars($arg['Optional_B'], ENT_QUOTES)); ?>' /> the position 
				that <input type='text' name='gen_obj_pos' id='gen_obj_pos' 
					value='<? echo(htmlspecialchars($arg['Position'], ENT_QUOTES)); ?>'  /> is not true.
				<input type='hidden' name='gen_obj_id_3' id='gen_obj_id_3' value='<? echo($arg_3['ID']); ?>' /> 
				<input type='hidden' name='gen_obj_id_2' id='gen_obj_id_2' value='<? echo($arg_2['ID']); ?>' /> <?
				if (!$allowAdd) echo("<input type='hidden' name='gen_obj_id_4' id='gen_obj_id_4' value='".$arg_4['ID']."' />");
		}
		?>
		</div><br />
		<input type='submit' value='Update' /> 
		<input type='button' onclick='addReason(1, true);' id='addReason1' value='Add Reason' <? echo($allowAdd?"":"disabled='disabled'"); ?> /> 
		<input type='button' onclick='remove(1);' value='Remove' />
		<input type='hidden' name='gen_obj_id' id='gen_obj_id' value='<? echo($arg['ID']); ?>' />
		<input type='hidden' name='gen_obj_subtype' id='gen_obj_subtype' value='<? echo($arg['Subtype']);?>' />
		<?
   }
   else { ?>
 		<div id='gen_obj_start' style='display:block; position:relative; left:20px'>
			<input type='text' name='gen_obj_create_input' id='gen_obj_create_input' 
				value='<? echo(htmlspecialchars($base['BasePosition'], ENT_QUOTES)); ?>'  /> &nbsp;
			<select name='gen_obj_create_subtype' id='gen_obj_create_subtype'>
				<option value='0'>BECAUSE</option>
				<option value='1'>SINCE</option>
				<option value='2'>THEREFORE</option>
			</select> &nbsp;
			<input type='button' onclick='create(1);' value='Create' />
		</div>
		<div id='gen_obj_body' style='display:none;'>
			<div id='gen_obj_body_inner' style='position:relative; left:20px'>
			</div>
		</div>
<? } ?>
<div id='addGenObjReason' style='display:none; position:absolute; z-index:5; background-color:#FFFFCC;'>
	<table border='1'>
	<tr><td>
			<table cellpadding='2px'>
				<tr>
					<td colspan=2><b>Add new reason:</b></td>
				</tr>
				<tr>
					<td colspan=2><input type='text' name='gen_obj_reason' id='gen_obj_reason' value='' />
				</tr>
				<tr>
					<td><input type='submit' id='yes' name='yes' value='Add' /></td>
					<td><input type='button' value='Cancel' 
							onclick='addReason(1, false); document.getElementById("gen_obj_reason").value="";' /></td>
				</tr>
			</table>
	</td></tr>
	</table>
</div>
</form>
</div>
<br />
<input type='button' id='preview_button' onclick='preview();' value='Open Preview' /> &nbsp;
<input type='button' value='Return to Argument Sets' onclick='window.location="logichome.php"' />
<div id='preview' style='display:none; position:absolute; left:17.5em; top:10em; background-color:#FFFFFF'>
	<table border='1' cellpadding='10' style='width:45em'>
		<tr>
			<td></td>
			<td><span id='preview_text'></span></td>
			<td></td>
		</tr>
	</table>
</div>
<? include("footer.php"); ?>
</html>
