<?PHP
echo("
<form action='".$PHP_SELF."' method='POST' name='form'>
<input type='hidden' name='sid' value='".trim($sid)."'>
<input type='hidden' name='gid' value='".trim($gid)."'>
<table width='85%' cellpadding='2' cellspacing='0' border='0'>
	<tr>
		<td>
<table width='500' cellpadding='2' cellspacing='0' border='0'>
	<tr>
		<td align='center' valign='middle'><font color='#990000'><b>Buy</b></font></td>
		<td align='left' valign='middle'>&nbsp;<font color='#990000'><b>Addon Name</b></font></td>
		<td align='left' valign='middle'>&nbsp;<font color='#990000'><b>Setup Fee</b></font></td>
		<td align='left' valign='middle'>&nbsp;<font color='#990000'><b>Addon Cost</b></font></td>
	</tr>
	");

// grab choices from db and break them up
$rs1=mysql_fetch_row(mysql_query("select addon_choices from hosting_order where oid='".addslashes(trim($oid))."'"));
$addon_choices=$rs1[0];
$count=substr_count($addon_choices, "|");
$explode=explode("|", $addon_choices);

// select all addons for the set
$query="select ";
$query.="group_addons ";				// 0
$query.="from addon_groups ";
$query.="where addon_gid='".addslashes(trim($addon_gid))."'";

$rs=mysql_fetch_row(mysql_query($query));
$group_addons=stripslashes(trim($rs[0]));

$ii=0;
$x=0;
$tok=strtok($group_addons, "|");
while ($tok)
	{
	if (trim($addon_choices)!="")
		{
		for ($i=0; $i<=$count; $i++) { if ($explode[$i]==$tok) { $bit=true; } }
		}

	$query0.="select ";
	$query0.="addon_name, ";				// 0
	$query0.="addon_description, ";			// 1
	$query0.="addon_show_description, ";	// 2
	$query0.="setup_cost, ";				// 3
	$query0.="setup_activate, ";			// 4
	$query0.="addon_cost, ";				// 5
	$query0.="addon_state, ";				// 6
	$query0.="addon_activate ";				// 7
	$query0.="from addon_specs ";
	$query0.="where aid='".addslashes(trim($tok))."'";

	$rs0=mysql_fetch_row(mysql_query($query0));

	$addon_name=stripslashes(trim($rs0[0])); 
	$addon_description=stripslashes(trim($rs0[1]));
	$addon_show_description=stripslashes(trim($rs0[2]));
	$setup_cost=stripslashes(trim($rs0[3])); 
	$setup_activate=stripslashes(trim($rs0[4]));
	$addon_cost=stripslashes(trim($rs0[5]));
	$addon_state=stripslashes(trim($rs0[6]));
	$addon_activate=stripslashes(trim($rs0[7]));

	if ($setup_activate==0&&$addon_activate==0) { $free=true; }

	if ($addon_show_description==1)
		{
		echo("
			<tr id=\"xc".$ii."\" onClick='if (aid".$ii.".checked) { aid".$ii.".checked=false;} else { aid".$ii.".checked = true;} change_tr_color(document.all(\"xc".$ii."\").bgColor, \"xc".$ii."\", \"#EEEEEE\"); change_tr_color(document.all(\"xc".$ii."x\").bgColor, \"xc".$ii."x\", \"#EEEEEE\");'".((isset($bit))?" bgcolor='#EEEEEE'":"").">
			");
		}
	else
		{
		echo("
			<tr id=\"xc".$ii."\" onClick='if (aid".$ii.".checked) { aid".$ii.".checked=false;} else { aid".$ii.".checked = true;} change_tr_color(document.all(\"xc".$ii."\").bgColor, \"xc".$ii."\", \"#EEEEEE\");'".((isset($bit))?" bgcolor='#EEEEEE'":"").">
			");
		}

	echo("
			<td align='center' valign='top'><input id=\"c".$ii."\" type='checkbox' name='aid".$ii."' value='".$tok."'".((isset($bit))?" checked":"")." onclick='if (aid".$ii.".checked) { aid".$ii.".checked=false;} else { aid".$ii.".checked = true;}'></td>
			<td align='left' valign='top'>&nbsp;".$addon_name."</td>
			<td align='left' valign='top'>&nbsp;
		");
	if ($setup_activate==1) { echo $currency.sprintf("%01.2f", $setup_cost).$currency_type; }
	else { echo "None"; }
	echo("
			</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;
		");
	if ($addon_activate==1) 
		{
		echo $currency.sprintf("%01.2f", $addon_cost).$currency_type;
		if ($addon_state==1) { echo " One Time Fee"; }
		else if ($addon_state==2) { echo " Per Month"; }
		else if ($addon_state==3) { echo " Per Year"; }
		}
	else 
		{ 
		echo "None"; 
		}
	echo("
			</td>
		</tr>
		");

	if ($addon_show_description==1)
		{
		echo("
			<tr id=\"xc".$ii."x\" onClick='if (aid".$ii.".checked) { aid".$ii.".checked=false;} else { aid".$ii.".checked = true;} change_tr_color(document.all(\"xc".$ii."\").bgColor, \"xc".$ii."\", \"#EEEEEE\"); change_tr_color(document.all(\"xc".$ii."x\").bgColor, \"xc".$ii."x\", \"#EEEEEE\");'".((isset($bit))?" bgcolor='#EEEEEE'":"").">
				<td colspan='1' align='left' valign='top'></td>
				<td colspan='3' align='left' valign='top'>&nbsp;".$addon_description."</td>
			</tr>
			");
		}

	echo("
		<tr>
			<td colspan='4'><img src='".$http_image."/space.gif' width='1' height='2'></td>
		</tr>
		");

	unset($bit);
	unset($xtok);
	unset($addon_name);
	unset($addon_description);
	unset($addon_show_description);
	unset($setup_cost);
	unset($setup_activate);
	unset($addon_cost);
	unset($addon_state);
	unset($addon_activate);
	unset($query0);
	unset($rs0);

	$ii++;

	$tok=strtok("|");
	}

echo("
	<tr>
		<td colspan='4'><img src='".$http_images."/space.gif' width='1' height='16'></td>
	</tr>
	<tr>
		<td colspan='1' align='left' valign='top'></td>
		<td colspan='3' align='left' valign='top'><input ".$button_style." type='submit' name='submitz' value='Click to Continue &gt&gt'></td>
	</tr>
</table>

</form>
");
?>