<?PHP
echo("
	<table width='100%' cellpadding='2' cellspacing='0' border='0'>
	<tr>
		<td align='left' valign='top'>
		<table width='100%' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td colspan='4' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='4'></td>
			</tr>
			<tr>
				<td colspan='4' align='left' valign='top'>Define default email for this processor:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;<a href='".$http_admin."/payment_process.php?sid=".trim($sid)."&reset=5&id=".$id."'>reset to original template</a>&nbsp;]</td>
			</tr>
			<tr>
				<td colspan='4' align='left' valign='top'><hr color='#F0EFED'></td>
			</tr>
			<tr>
				<td colspan='4'><font color='#990000'>Objects Available:</font></td>
			</tr>
		");
	$rs0=mysql_fetch_row(mysql_query("select subject, message, attr_avail from email_templates where emid='8'"));

	$total=substr_count($rs0[2], "|");
	$g=1;
	$tok = strtok($rs0[2],"|");
	while ($tok) 
		{
		if ($g==1)
			{
			echo"<tr>\n\t<td>".$tok."</td>\n";
			$g=2;
			}
		else if ($g==2)
			{
			echo"\t<td>".$tok."</td>\n";
			$g=3;
			}
		else if ($g==3)
			{
			echo"\t<td>".$tok."</td>\n";
			$g=4;
			}
		else if ($g==4)
			{
			echo"\t<td>".$tok."</td>\n</tr>\n";
			$g=1;
			}
		$tok = strtok("|");
		}

	// finish out table html
	if ($g==2)
		{
		echo"\t<td></td>\n";
		echo"\t<td></td>\n";
		echo"\t<td></td>\n</tr>\n";
		$g=3;
		}
	else if ($g==3)
		{
		echo"\t<td></td>\n";
		echo"\t<td></td>\n</tr>\n";
		$g=4;
		}
	else if ($g==4)
		{
		echo"\t<td></td>\n</tr>\n";
		$g=1;
		}
	echo("
			</table>
			</td>
		</tr>
		<tr>
			<td align='left' valign='top'><hr color='#F0EFED'></td>
		</tr>
	");
if (trim($default_email)=="")
	{
	echo("
			<tr>
				<td>Subject: <input ".$input_style." size='72' maxlength='255' type='text' name='subject' value='".stripslashes(trim($rs0[0]))."'></td>
			</tr>
			<tr>
				<td><textarea name='message' rows='15' cols='80' ".$input_style.">".stripslashes(trim($rs0[1]))."</textarea></td>
			</tr>
		");
	}
else
	{
	$rs0=mysql_fetch_row(mysql_query("select default_email from payment_process where pid='".addslashes(trim($id))."'"));
	list($sub, $body)=split("{{break}}", $rs0[0]);
	$sub=base64_decode($sub);
	$body=base64_decode($body);
	echo("
			<tr>
				<td>Subject: <input ".$input_style." size='72' maxlength='255' type='text' name='subject' value='".stripslashes(trim($sub))."'></td>
			</tr>
			<tr>
				<td><textarea name='message' rows='15' cols='80' ".$input_style.">".stripslashes(trim($body))."</textarea></td>
			</tr>
		");
	}
echo "</table>"; 
?>