<?PHP
include "../inc/connect.php";
include $server_inc."/whm_functions.php";

// Start Form Handler

// create group
if (isset($submitx))
	{
	if (strlen(trim($package_group))==0)
		{
		$errg=true;
		}
	else
		{
		if (!isset($group_status))
			{
			$group_status=0;
			}

		mysql_query("insert into plan_groups set name='".addslashes(trim($package_group))."', group_status='".addslashes(trim($group_status))."'");
		}
	}

// edit group
if (isset($submity))
	{
	if (strlen(trim($edit_group_name))==0)
		{
		$erre=true;
		}
	else
		{
		mysql_query("update plan_groups set name='".addslashes(trim($edit_group_name))."' where gid='".addslashes(trim($gid))."'");
		}
	}

// delete group
if (isset($submitz))
	{
	// this query makes the plans visible in the edit menu as undefined
	// want to do this because the og plan group for this plan no longer
	// exists, well it does until the next query.
	mysql_query("update plan_specs set gid='0' where gid='".addslashes(trim($gid))."'");

	// ok, the plan group is deleted.
	mysql_query("delete from plan_groups where gid='".addslashes(trim($gid))."'");
	}
if (isset($submit))
	{
	if (strlen(trim($package_name))==0) { $err0=true; } else { $n0=true; }
	if (strlen(trim($monthly_cost))==0) { $err1=true; } else { $n1=true; }
	if (strlen(trim($quarterly_cost))==0) { $err2=true; } else { $n2=true; }
	if (strlen(trim($semi_annual_cost))==0) { $err3=true; } else { $n3=true; }
	if (strlen(trim($annual_cost))==0) { $err4=true; } else { $n4=true; }
	if (strlen(trim($whm_package_name))==0) { $err5=true; } else { $n5=true; }
	if (strlen(trim($web_space))==0) { $err6=true; } else { $n6=true; }
	if (strlen(trim($bandwidth))==0) { $err7=true; } else { $n7=true; }
	if (isset($tpp_high)) { if (strlen(trim($tpp_pro_period))==0) { $err8=true; } else { $n8=true; } } else {$n8=true;}
	if (isset($unique_ip_activate)) { if (strlen(trim($unique_ip_cost))==0) { $err9=true; } else { $n9=true; } } else {$n9=true;}
	if (isset($ssl_activate)) { if (strlen(trim($ssl_cost))==0) { $err10=true; } else { $n10=true; } } else {$n10=true;}
	if (isset($extra_space_activate)) 
		{ 
		if (strlen(trim($extra_space_cost))==0) { $err11=true; } else { $n11=true; } 
		if (strlen(trim($extra_space))==0) { $err11=true; } else { $n11=true; } 
		} 
	else 
		{
		$n11=true;
		}

	if (isset($addon_1_activate)) 
		{ 
		if (strlen(trim($addon_1_name))==0) { $err12=true; } else { $n12=true; } 
		if (strlen(trim($addon_1_cost))==0) { $err12=true; } else { $n12=true; } 
		} 
	else 
		{
		$n12=true;
		}

	if (isset($addon_2_activate)) 
		{ 
		if (strlen(trim($addon_2_name))==0) { $err13=true; } else { $n13=true; } 
		if (strlen(trim($addon_2_cost))==0) { $err13=true; } else { $n13=true; } 
		} 
	else 
		{
		$n13=true;
		}

	if (isset($addon_3_activate)) 
		{ 
		if (strlen(trim($addon_3_name))==0) { $err14=true; } else { $n14=true; } 
		if (strlen(trim($addon_3_cost))==0) { $err14=true; } else { $n14=true; } 
		} 
	else 
		{
		$n14=true;
		}

	if (isset($n0)&&isset($n1)&&isset($n2)&&isset($n3)&&isset($n4)&&isset($n5)&&isset($n6)&&isset($n7)&&isset($n8)&&isset($n9)&&isset($n10)&&isset($n11)&&isset($n12)&&isset($n13)&&isset($n14))
		{
		// if isset($pid) then it's an edit
		if (isset($pid))
			{
			// build the query
			$update="update plan_specs set ";
			$update.="package_name='".addslashes(trim($package_name))."', ";
			$update.="whm_package_name='".addslashes(trim($whm_package_name))."', ";
			$update.="plan_status='".addslashes(trim($plan_status))."', ";
			$update.="monthly_cost='".addslashes(str_replace("$", "", trim($monthly_cost)))."', ";
			$update.="quarterly_cost='".addslashes(str_replace("$", "", trim($quarterly_cost)))."', ";
			$update.="semi_annual_cost='".addslashes(str_replace("$", "", trim($semi_annual_cost)))."', ";
			$update.="annual_cost='".addslashes(str_replace("$", "", trim($annual_cost)))."', ";
			$update.="setup_cost='".addslashes(str_replace("$", "", trim($setup_cost)))."', ";
			$update.="web_space='".addslashes(trim($web_space))."', ";
			$update.="shell_access='".addslashes(trim($shell_access))."', ";
			$update.="ftp='".addslashes(trim($ftp))."', ";
			$update.="email='".addslashes(trim($email))."', ";
			$update.="email_list='".addslashes(trim($email_list))."', ";
			$update.="sql='".addslashes(trim($sql))."', ";
			$update.="sub_domain='".addslashes(trim($sub_domain))."', ";
			$update.="parked_domain='".addslashes(trim($parked_domain))."', ";
			$update.="addon_domain='".addslashes(trim($addon_domain))."', ";
			$update.="unique_ip_activate='".addslashes(trim($unique_ip_activate))."', ";
			$update.="unique_ip_cost='".addslashes(str_replace("$", "", trim($unique_ip_cost)))."', ";
			$update.="cgi_access='".addslashes(trim($cgi_access))."', ";
			$update.="frontpage='".addslashes(trim($frontpage))."', ";
			$update.="bandwidth='".addslashes(trim($bandwidth))."', ";
			$update.="cpanel_theme='".addslashes(trim($cpanel_theme))."', ";
			$update.="ssl_activate='".addslashes(trim($ssl_activate))."', ";
			if (isset($tpp_pro_period))
				{
				$update.="tpp_pro_period='".addslashes(trim($tpp_pro_period))."', ";
				}
			else
				{
				$update.="tpp_pro_period='x', ";
				}
			$update.="extra_space_cost='".addslashes(str_replace("$", "", trim($extra_space_cost)))."', ";
			$update.="gid='".addslashes(trim($gid))."', ";
			$update.="extra_space='".addslashes(trim($extra_space))."', ";
			$update.="extra_space_activate='".addslashes(trim($extra_space_activate))."', ";
			$update.="addon_1_name='".addslashes(trim($addon_1_name))."', ";
			$update.="addon_1_cost='".addslashes(str_replace("$", "", trim($addon_1_cost)))."', ";
			$update.="addon_1_terms='".addslashes(trim($addon_1_terms))."', ";
			$update.="addon_1_activate='".addslashes(trim($addon_1_activate))."', ";
			$update.="addon_2_name='".addslashes(trim($addon_2_name))."', ";
			$update.="addon_2_cost='".addslashes(str_replace("$", "", trim($addon_2_cost)))."', ";
			$update.="addon_2_terms='".addslashes(trim($addon_2_terms))."', ";
			$update.="addon_2_activate='".addslashes(trim($addon_2_activate))."', ";
			$update.="addon_3_name='".addslashes(trim($addon_3_name))."', ";
			$update.="addon_3_cost='".addslashes(str_replace("$", "", trim($addon_3_cost)))."', ";
			$update.="addon_3_terms='".addslashes(trim($addon_3_terms))."', ";
			$update.="addon_3_activate='".addslashes(trim($addon_3_activate))."', ";
			$update.="ssl_cost='".addslashes(str_replace("$", "", trim($ssl_cost)))."' ";
			$update.="where pid='".addslashes(trim($pid))."'";

			// execute the query
			mysql_query($update);
			}
		else
			{
			// build the query
			$add="insert into plan_specs set ";
			$add.="package_name='".addslashes(trim($package_name))."', ";
			$add.="whm_package_name='".addslashes(trim($whm_package_name))."', ";
			$add.="plan_status='".addslashes(trim($plan_status))."', ";
			$add.="monthly_cost='".addslashes(str_replace("$", "", trim($monthly_cost)))."', ";
			$add.="quarterly_cost='".addslashes(str_replace("$", "", trim($quarterly_cost)))."', ";
			$add.="semi_annual_cost='".addslashes(str_replace("$", "", trim($semi_annual_cost)))."', ";
			$add.="annual_cost='".addslashes(str_replace("$", "", trim($annual_cost)))."', ";
			$add.="setup_cost='".addslashes(str_replace("$", "", trim($setup_cost)))."', ";
			$add.="web_space='".addslashes(trim($web_space))."', ";
			$add.="shell_access='".addslashes(trim($shell_access))."', ";
			$add.="ftp='".addslashes(trim($ftp))."', ";
			$add.="email='".addslashes(trim($email))."', ";
			$add.="email_list='".addslashes(trim($email_list))."', ";
			$add.="sql='".addslashes(trim($sql))."', ";
			$add.="sub_domain='".addslashes(trim($sub_domain))."', ";
			$add.="parked_domain='".addslashes(trim($parked_domain))."', ";
			$add.="addon_domain='".addslashes(trim($addon_domain))."', ";
			$add.="unique_ip_activate='".addslashes(trim($unique_ip_activate))."', ";
			$add.="unique_ip_cost='".addslashes(str_replace("$", "", trim($unique_ip_cost)))."', ";
			$add.="cgi_access='".addslashes(trim($cgi_access))."', ";
			$add.="frontpage='".addslashes(trim($frontpage))."', ";
			$add.="bandwidth='".addslashes(trim($bandwidth))."', ";
			$add.="cpanel_theme='".addslashes(trim($cpanel_theme))."', ";
			$add.="ssl_activate='".addslashes(trim($ssl_activate))."', ";
			if (isset($tpp_pro_period))
				{
				$add.="tpp_pro_period='".addslashes(trim($tpp_pro_period))."', ";
				}
			else
				{
				$add.="tpp_pro_period='x', ";
				}
			$add.="extra_space_cost='".addslashes(str_replace("$", "", trim($extra_space_cost)))."', ";
			$add.="gid='".addslashes(trim($gid))."', ";
			$add.="extra_space='".addslashes(trim($extra_space))."', ";
			$add.="extra_space_activate='".addslashes(trim($extra_space_activate))."', ";
			$add.="addon_1_name='".addslashes(trim($addon_1_name))."', ";
			$add.="addon_1_cost='".addslashes(str_replace("$", "", trim($addon_1_cost)))."', ";
			$add.="addon_1_terms='".addslashes(trim($addon_1_terms))."', ";
			$add.="addon_1_activate='".addslashes(trim($addon_1_activate))."', ";
			$add.="addon_2_name='".addslashes(trim($addon_2_name))."', ";
			$add.="addon_2_cost='".addslashes(str_replace("$", "", trim($addon_2_cost)))."', ";
			$add.="addon_2_terms='".addslashes(trim($addon_2_terms))."', ";
			$add.="addon_2_activate='".addslashes(trim($addon_2_activate))."', ";
			$add.="addon_3_name='".addslashes(trim($addon_3_name))."', ";
			$add.="addon_3_cost='".addslashes(str_replace("$", "", trim($addon_3_cost)))."', ";
			$add.="addon_3_terms='".addslashes(trim($addon_3_terms))."', ";
			$add.="addon_3_activate='".addslashes(trim($addon_3_activate))."', ";
			$add.="ssl_cost='".addslashes(str_replace("$", "", trim($ssl_cost)))."' ";

			// execute the query
			mysql_query($add);

			// get the last entry id, call it PID
			$pid=mysql_insert_id();
			}
		$done=true;
		}
	}

// End Form Handler

echo("
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
	");
if (isset($pid))
	{
	$query="select ";
	$query.="package_name, ";		// 0-
	$query.="whm_package_name, ";	// 1-
	$query.="plan_status, ";		// 2-
	$query.="monthly_cost, ";		// 3-
	$query.="quarterly_cost, ";		// 4-
	$query.="semi_annual_cost, ";	// 5-
	$query.="annual_cost, ";		// 6-
	$query.="setup_cost, ";			// 7-
	$query.="web_space, ";			// 8-
	$query.="shell_access, ";		// 9-
	$query.="ftp, ";				// 10-
	$query.="email, ";				// 11-
	$query.="email_list, ";			// 12-
	$query.="sql, ";				// 13-
	$query.="sub_domain, ";			// 14-
	$query.="parked_domain, ";		// 15-
	$query.="addon_domain, ";		// 16-
	$query.="unique_ip_activate, ";	// 17-
	$query.="unique_ip_cost, ";		// 18-
	$query.="cgi_access, ";			// 19-
	$query.="frontpage, ";			// 20-
	$query.="bandwidth, ";			// 21-
	$query.="cpanel_theme, ";		// 22-
	$query.="ssl_cost, ";			// 23-
	$query.="ssl_activate, ";		// 24-
	$query.="tpp_pro_period, ";		// 25-
	$query.="extra_space_cost, ";	// 26-
	$query.="gid, ";				// 27-
	$query.="extra_space, ";		// 28-
	$query.="extra_space_activate, ";// 29-
	$query.="addon_1_name, ";		// 30-
	$query.="addon_1_cost, ";		// 31-
	$query.="addon_1_activate, ";	// 32-
	$query.="addon_2_name, ";		// 33-
	$query.="addon_2_cost, ";		// 34-
	$query.="addon_2_activate, ";	// 35-
	$query.="addon_3_name, ";		// 36-
	$query.="addon_3_cost, ";		// 37-
	$query.="addon_3_activate, ";	// 38-
	$query.="addon_1_terms, ";		// 39-
	$query.="addon_2_terms, ";		// 40-
	$query.="addon_3_terms ";		// 41-
	$query.="from plan_specs where pid='".addslashes(trim($pid))."'";

	// execute query
	$rs=mysql_fetch_row(mysql_query($query));
	}

// Check to make sure we have groups defined
$ct=mysql_fetch_row(mysql_query("select count(*) from plan_groups"));

// start error messages table
if (isset($errg)||isset($erre)||isset($err0)||isset($err1)||isset($err2)||isset($err3)||isset($err4)||isset($err5)||isset($err6)||isset($err7)||isset($err8)||isset($err9)||isset($err10)||isset($err11)||isset($err12)||isset($err13)||isset($err14))
	{
	echo"<table width='100%' cellpadding='2' cellspacing='0' border='0'>";
	}
// Tried to add new group with null name
if (isset($errg))
	{
	echo("
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>group name</b> to add a new group.</td> 
			</tr>
			<tr>
				<td align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Tried to rename group with null name
if (isset($erre))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>group name</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Left MIB Package null
if (isset($err0))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>MIB Package Name</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Monthly price defined
if (isset($err1))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Monthly Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Quarterly price defined
if (isset($err2))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Quarterly Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Semi-Annual price defined
if (isset($err3))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Semi-Annual</b> Cost to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Annual price defined
if (isset($err4))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>Annual Cost</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No Web Host Manager Plan Name defined.
if (isset($err5))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>WHM plan name</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No web space amount defined.
if (isset($err6))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter an amount of <b>web space</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// No bandwidth amount defined.
if (isset($err7))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter an amount of <b>bandwidth</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Missing TPP-PRO Period
if (isset($err8))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>TPP-PRO Period</b> to continue.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Unique IP addon activated with now cost/ip
if (isset($err9))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>cost per unique IP</b> to activate this addon.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// SSL cert addon activated with now cost/year
if (isset($err10))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must enter a <b>cost per SSL certificate per year</b> to activate this addon.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Web space addon activated with now cost/amount
if (isset($err11))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must define <b>cost per MB of web space</b> to activate this addon.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Generic addon 1 activated with now name/cost
if (isset($err12))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must define an <b>addon name and cost</b> to activate generic addon 1.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Generic addon 2 activated with now name/cost
if (isset($err13))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must define an <b>addon name and cost</b> to activate generic addon 2.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// Generic addon 3 activated with now name/cost
if (isset($err14))
	{
	echo("
			<tr>
				<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><img src='".$http_images."/error_arrow.gif'><b>ERROR!</b> You must define an <b>addon name and cost</b> to activate generic addon 3.</td> 
			</tr>
			<tr>
				<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
			</tr>
		");
	}

// complete the error table
if (isset($errg)||isset($erre)||isset($err0)||isset($err1)||isset($err2)||isset($err3)||isset($err4)||isset($err5)||isset($err6)||isset($err7)||isset($err8)||isset($err9)||isset($err10)||isset($err11)||isset($err12)||isset($err13)||isset($err14))
	{
	echo("
			<tr>
				<td align='left' valign='top'><hr></td>
			</tr>
		</table>
		");
	}

// ok, all done - Plan added
if (isset($done))
	{
	echo("
		<table width='100%' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'>The plan was ".((isset($pid))?"edited":"created")." successfully!</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><a href='".$http_admin."/plan_build.php'>Add new package specs</a>.</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'><a href='".$http_admin."/plan_edit.php'>Choose package specs to edit</a>.</td>
			</tr>
			<tr>
				<td align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Make edits to <b>".$package_name."</b> below:</td>
			</tr>
			<tr>
				<td align='left' valign='top'><hr></td>
			</tr>
		</table>
		");
	}
echo("
<!--- Start Main --->
<table width='100%' border='0' cellspacing='1' cellpadding='2'>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Manage Package Groups</b></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='space.gif' width='15' height='9'>Create New Group:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='35' maxlength='255' name='package_group'> <input ".$button_style." type='submit' name='submitx' value='Create &gt&gt'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='space.gif' width='15' height='9'>Create New Group:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='group_status' VALUE='1' checked> Check to make group viewable to the public.</td> 
	</tr>
</form>
<tr>
	<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
</tr>
	");

// if we have no groups defined kill off script until we can get some added.
if ($ct[0]<=0)
	{
	echo("
	</table>
	</form>
	<!--- End Main --->

		");
	// End Main Process
	mysql_close($dblink);
	die();
	}
else
	{
	echo"</form>";
	}

echo("
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
	<tr>
		<td width='25%' align='left' valign='top'><img src='space.gif' width='15' height='9'>Rename Group:</td> 
		<td width='75%' align='left' valign='top'><select name='gid' ".$input_style.">
	");	
$rog=mysql_query("select gid, name from plan_groups order by name asc");
while ($rg=mysql_fetch_row($rog))
	{
	echo"<option value='".$rg[0]."'".((isset($pid))?"".(($rg[0]==$pid)?" selected":"")."":"".((isset($gid))?"".(($gid==$rg[0])?" selected":"")."":"")."").">".stripslashes($rg[1])."</option>\n";
	}
echo("
		</select> to <input ".$input_style." type='text' size='16' maxlength='255' name='edit_group_name'> <input ".$button_style." type='submit' name='submity' value='Edit &gt&gt'></td> 
	</tr>
</form>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
	<tr>
		<td width='25%' align='left' valign='top'><img src='space.gif' width='15' height='9'>Delete Group:</td> 
		<td width='75%' align='left' valign='top'><select name='gid' ".$input_style.">
	");
$rog=mysql_query("select gid, name from plan_groups order by name asc");
while ($rg=mysql_fetch_row($rog))
	{
	echo"<option value='".$rg[0]."'".((isset($pid))?"".(($rg[0]==$pid)?" selected":"")."":"".((isset($gid))?"".(($gid==$rg[0])?" selected":"")."":"")."").">".stripslashes($rg[1])."</option>\n";
	}
echo("
		</select> <input ".$button_style." type='submit' name='submitz' value='Delete Group &gt&gt'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'></td> 
		<td width='75%' align='left' valign='top'><img src='".$http_images."/drop_arrow.gif'>This tool affects every package in the group.</td> 
	</tr>
</form>
<tr>
	<td colspan='2'><hr color='#F0EFED'></td>
</tr>
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>MIB Details</b></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err0))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Package Name:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='30' maxlength='255' name='package_name' value='".((isset($pid))?"".stripslashes($rs[0])."":"".((isset($package_name))?"".trim(stripslashes($package_name))."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Plan Status:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='plan_status' VALUE='1'".((isset($pid))?"".(($rs[2]==1)?" checked":"")."":" checked")."> Check to make package viewable to the public.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Choose Plan Group:</td> 
		<td width='75%' align='left' valign='top'>
		<select name='gid' ".$input_style.">
	");
$rog=mysql_query("select gid, name from plan_groups order by name asc");
while ($rg=mysql_fetch_row($rog))
	{
	echo"<option value='".$rg[0]."'".((isset($pid))?"".(($rg[0]==$rs[27])?" selected":"")."":"".((isset($gid))?"".(($gid==$rg[0])?" selected":"")."":"")."").">".stripslashes($rg[1])."</option>\n";
	}
echo("
		</select>
		</td> 
	</tr>
	");
if ($rs[27]==0)
	{
	echo("
		<tr>
			<td width='25%' align='left' valign='top'></td> 
			<td width='75%' align='left' valign='top'><img src='".$http_images."/drop_arrow.gif' width='15' height='9'>No defined group for this package. Please choose a group and update this form.</td> 
		</tr>
		");
	}
echo("
	<tr>
		<td colspan='2'><hr color='#F0EFED'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Pay Structure</b></td> 
	</tr>
	");
// is TPP PRO Active? if so grab the PaySystems TPP-Pro Period Value
$rs_tpp=mysql_fetch_row(mysql_query("select status from payment_process where name='Paysystems TPP-PRO'"));
if ($rs_tpp[0]==1)
	{
	echo("
		<!--- set bit for error checking--->
		<input type='hidden' name='tpp_high' value='1'>
		<tr>
			<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err8))?"error_arrow.gif":"space.gif")."' width='15' height='9'>PaySystems TPP-Pro Period:</td> 
			<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='tpp_pro_period' value='".((isset($pid))?"".(($rs[25]==0)?"":"".$rs[25]."")."":"".((isset($tpp_pro_period))?"".((trim($tpp_pro_period)=="0")?"":"".trim($tpp_pro_period)."")."":"")."")."'> [Required]</td> 
		</tr>
		");
	}
echo("
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err1))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Monthly Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='monthly_cost' value='".((isset($pid))?"".$rs[3]."":"".((isset($monthly_cost))?"".trim($monthly_cost)."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err2))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Quarterly Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='quarterly_cost' value='".((isset($pid))?"".$rs[4]."":"".((isset($quarterly_cost))?"".trim($quarterly_cost)."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err3))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Semi-Annual Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='semi_annual_cost' value='".((isset($pid))?"".$rs[5]."":"".((isset($semi_annual_cost))?"".trim($semi_annual_cost)."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err4))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Annual Cost:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='annual_cost' value='".((isset($pid))?"".$rs[6]."":"".((isset($annual_cost))?"".trim($annual_cost)."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Setup Fee:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='setup_cost' value='".((isset($pid))?"".(($rs[7]==0)?"":"".$rs[7]."")."":"".((isset($setup_cost))?"".trim($setup_cost)."":"")."")."'> [leave blank for no setup fee]</td> 
	</tr>
	<tr>
		<td colspan='2'><hr color='#F0EFED'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>WHM Details</b></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err5))?"error_arrow.gif":"space.gif")."' width='15' height='9'>WHM Plan Name (no spaces):</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='30' maxlength='255' name='whm_package_name' value='".((isset($pid))?"".stripslashes($rs[1])."":"".((isset($whm_package_name))?"".trim(stripslashes($whm_package_name))."":"")."")."'> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err6))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Web Space Quota:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='10' maxlength='10' name='web_space' value='".((isset($pid))?"".$rs[8]."":"".((isset($web_space))?"".trim($web_space)."":"")."")."'> <b>MB</b> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err7))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Bandwidth Limit:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='10' maxlength='20' name='bandwidth' value='".((isset($pid))?"".$rs[21]."":"".((isset($bandwidth))?"".trim($bandwidth)."":"")."")."'> <b>MB</b> [Required]</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Shell Access:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='shell_access' VALUE='1'".((isset($pid))?"".(($rs[9]==1)?" checked":"")."":"".((isset($shell_access))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Cgi Access:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='cgi_access' VALUE='1'".((isset($pid))?"".(($rs[19]==1)?" checked":"")."":"".((isset($cgi_access))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Frontpage Extentions:</td> 
		<td width='75%' align='left' valign='top'><input type='checkbox' name='frontpage' VALUE='1'".((isset($pid))?"".(($rs[20]==1)?" checked":"")."":"".((isset($frontpage))?" checked":"")."")."> Check to grant access.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Ftp Accounts:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='ftp' value='".((isset($pid))?"".$rs[10]."":"".((isset($ftp))?"".trim($ftp)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Email Accounts:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='email' value='".((isset($pid))?"".$rs[11]."":"".((isset($email))?"".trim($email)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Email Lists:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='email_list' value='".((isset($pid))?"".$rs[12]."":"".((isset($email_list))?"".trim($email_list)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max SQL Databases:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='sql' value='".((isset($pid))?"".$rs[13]."":"".((isset($sql))?"".trim($sql)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Sub Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='sub_domain' value='".((isset($pid))?"".$rs[14]."":"".((isset($sub_domain))?"".trim($sub_domain)."":"-1")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Parked Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='parked_domain' value='".((isset($pid))?"".$rs[15]."":"".((isset($parked_domain))?"".trim($parked_domain)."":"0")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Max Addon Domains:</td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_domain' value='".((isset($pid))?"".$rs[16]."":"".((isset($addon_domain))?"".trim($addon_domain)."":"0")."")."'> Set to -1 for Unlimited.</td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>Cpanel Theme:</td> 
		<td width='75%' align='left' valign='top'>
		<select name='cpanel_theme' ".$input_style.">
	");
$xtheme=strtok(list_cpanel_themes($whm_host,$whm_user,$whm_pass),"|");
while ($xtheme) 
	{
    echo "<option value='".$xtheme."'";
	if (isset($pid))
		{
		if (trim($xtheme)==trim($rs[22]))
			{
			echo" selected";
			}
		}
	else if (isset($cpanel_theme))
		{
		if (trim($xtheme)==trim($cpanel_theme))
			{
			echo" selected";
			}
		}
	else
		{
		if (trim($xtheme)=="default")
			{
			echo" selected";
			}
		}
	echo">".$xtheme."</option>\n";
    $xtheme = strtok("|");
	}
echo("
		</select>
		</td> 
	</tr>
	<tr>
		<td colspan='2'><hr color='#F0EFED'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Account Addons</b></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err9))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Unique IP Cost/Status: </td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='unique_ip_cost' value='".((isset($pid))?"".(($rs[18]==0)?"":"".$rs[18]."")."":"".((isset($unique_ip_cost))?"".trim($unique_ip_cost)."":"")."")."'> per IP<br><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='unique_ip_activate' VALUE='1'".((isset($pid))?"".(($rs[17]==1)?" checked":"")."":"".((isset($unique_ip_activate))?" checked":"")."")."> Check to activate.</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='4'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err10))?"error_arrow.gif":"space.gif")."' width='15' height='9'>SSL Certificate Cost/Status: </td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='ssl_cost' value='".((isset($pid))?"".(($rs[23]==0)?"":"".$rs[23]."")."":"".((isset($ssl_cost))?"".trim($ssl_cost)."":"")."")."'> per Certificate per Year<br><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='ssl_activate' VALUE='1'".((isset($pid))?"".(($rs[24]==1)?" checked":"")."":"".((isset($ssl_activate))?" checked":"")."")."> Check to activate.</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='4'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err11))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Extra Web Space Cost/MB: </td> 
		<td width='75%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='extra_space_cost' value='".((isset($pid))?"".(($rs[26]==0)?"":"".$rs[26]."")."":"".((isset($extra_space_cost))?"".trim($extra_space_cost)."":"")."")."'> per <input ".$input_style." type='text' size='10' maxlength='20' name='extra_space' value='".((isset($pid))?"".(($rs[28]==0)?"":"".$rs[28]."")."":"".((isset($extra_space))?"".trim($extra_space)."":"")."")."'> <b>MB</b><br><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='extra_space_activate' VALUE='1'".((isset($pid))?"".(($rs[29]==1)?" checked":"")."":"".((isset($extra_space_activate))?" checked":"")."")."> Check to activate.</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='4'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err12))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Generic Addon 1: </td> 
		<td width='75%' align='left' valign='top'>
		<table width='100%' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Name:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_1_name' value='".((isset($pid))?"".stripslashes($rs[30])."":"".((isset($addon_1_name))?"".trim(stripslashes($addon_1_name))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Cost:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_1_cost' value='".((isset($pid))?"".(($rs[31]==0)?"":"".stripslashes($rs[31])."")."":"".((isset($addon_1_cost))?"".trim(stripslashes($addon_1_cost))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Terms:</td>
				<td width='85%' align='left' valign='top'><select name='addon_1_terms' ".$input_style.">
				<option value='Fee'".((isset($pid))?"".((trim($rs[39])=="Fee")?" selected":"")."":"".((isset($addon_1_terms))?"".(($addon_1_terms=="Fee")?" selected":"")."":" selected")."").">One Time Fee</option>
				<option value='Month'".((isset($pid))?"".((trim($rs[39])=="Month")?" selected":"")."":"".((isset($addon_1_terms))?"".(($addon_1_terms=="Month")?" selected":"")."":"")."").">Per Month</option>
				<option value='Year'".((isset($pid))?"".((trim($rs[39])=="Year")?" selected":"")."":"".((isset($addon_1_terms))?"".(($addon_1_terms=="Year")?" selected":"")."":"")."").">Per Year</option>
				</select></td>
			</tr>
			<tr>
				<td colspan='2'><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='addon_1_activate' VALUE='1'".((isset($pid))?"".(($rs[32]==1)?" checked":"")."":"".((isset($addon_1_activate))?" checked":"")."")."> Check to activate.</td>
			</tr>
		</table>
		</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='4'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err13))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Generic Addon 2: </td> 
		<td width='75%' align='left' valign='top'>
		<table width='100%' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Name:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_2_name' value='".((isset($pid))?"".stripslashes($rs[33])."":"".((isset($addon_2_name))?"".trim(stripslashes($addon_2_name))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Cost:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_2_cost' value='".((isset($pid))?"".(($rs[34]==0)?"":"".stripslashes($rs[34])."")."":"".((isset($addon_2_cost))?"".trim(stripslashes($addon_2_cost))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Terms:</td>
				<td width='85%' align='left' valign='top'><select name='addon_2_terms' ".$input_style.">
				<option value='Fee'".((isset($pid))?"".((trim($rs[40])=="Fee")?" selected":"")."":"".((isset($addon_2_terms))?"".(($addon_2_terms=="Fee")?" selected":"")."":" selected")."").">One Time Fee</option>
				<option value='Month'".((isset($pid))?"".((trim($rs[40])=="Month")?" selected":"")."":"".((isset($addon_2_terms))?"".(($addon_2_terms=="Month")?" selected":"")."":"")."").">Per Month</option>
				<option value='Year'".((isset($pid))?"".((trim($rs[40])=="Year")?" selected":"")."":"".((isset($addon_2_terms))?"".(($addon_2_terms=="Year")?" selected":"")."":"")."").">Per Year</option>
				</select></td>
			</tr>
			<tr>
				<td colspan='2'><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='addon_2_activate' VALUE='1'".((isset($pid))?"".(($rs[35]==1)?" checked":"")."":"".((isset($addon_2_activate))?" checked":"")."")."> Check to activate.</td>
			</tr>
		</table>
		</td> 
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='4'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/".((isset($err14))?"error_arrow.gif":"space.gif")."' width='15' height='9'>Generic Addon 3: </td> 
		<td width='75%' align='left' valign='top'>
		<table width='100%' cellpadding='2' cellspacing='0' border='0'>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Name:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_3_name' value='".((isset($pid))?"".stripslashes($rs[36])."":"".((isset($addon_3_name))?"".trim(stripslashes($addon_3_name))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Cost:</td>
				<td width='85%' align='left' valign='top'><input ".$input_style." type='text' size='15' maxlength='20' name='addon_3_cost' value='".((isset($pid))?"".(($rs[37]==0)?"":"".stripslashes($rs[37])."")."":"".((isset($addon_3_cost))?"".trim(stripslashes($addon_3_cost))."":"")."")."'></td>
			</tr>
			<tr>
				<td width='15%' align='left' valign='top'>Addon Terms:</td>
				<td width='85%' align='left' valign='top'><select name='addon_3_terms' ".$input_style.">
				<option value='Fee'".((isset($pid))?"".((trim($rs[41])=="Fee")?" selected":"")."":"".((isset($addon_3_terms))?"".(($addon_3_terms=="Fee")?" selected":"")."":" selected")."").">One Time Fee</option>
				<option value='Month'".((isset($pid))?"".((trim($rs[41])=="Month")?" selected":"")."":"".((isset($addon_3_terms))?"".(($addon_3_terms=="Month")?" selected":"")."":"")."").">Per Month</option>
				<option value='Year'".((isset($pid))?"".((trim($rs[41])=="Year")?" selected":"")."":"".((isset($addon_3_terms))?"".(($addon_3_terms=="Year")?" selected":"")."":"")."").">Per Year</option>
				</select></td>
			</tr>
			<tr>
				<td colspan='2'><img src='".$http_images."/drop_arrow.gif' width='15' height='9'><input type='checkbox' name='addon_3_activate' VALUE='1'".((isset($pid))?"".(($rs[38]==1)?" checked":"")."":"".((isset($addon_3_activate))?" checked":"")."")."> Check to activate.</td>
			</tr>
		</table>
		</td> 
	</tr>
	<tr>
		<td colspan='2'><hr color='#F0EFED'></td>
	</tr>
	<tr>
		<td colspan='2' align='left' valign='top'><img border='0' src='".$http_images."/space.gif' width='1' height='2'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'></td> 
		<td width='75%' align='left' valign='top'><input ".$button_style." type='submit' name='submit' value='".((isset($pid))?"Edit":"Create")." Hosting Package Now &gt'></td> 
	</tr>
	<tr>
		<td width='25%' align='left' valign='top'><img src='".$http_images."/space.gif' width='247' height='1'></td> 
		<td width='75%' align='left' valign='top'><img src='".$http_images."/space.gif' width='277' height='1'></td> 
	</tr>
</table>
</form>
<!--- End Main --->

	");
// End Main Process
mysql_close($dblink);
?>