print<<TABLETWO;
<table width=50% class=text border=0>
<tr>
  </td>
  </tr>
  <tr valign=middle>
   <td>
     List current email accounts and addresses
   </td>
   <td align=left>	
TABLETWO

show_option ($view_email_setup);
show_help ($view_email_setup);

print "</td></tr>";


if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($view_forwarding) eq "yes" ) )
{
        print "<tr valign=middle><td>List current email forwarding</td><td>";
        show_option ($view_forwarding);
        show_help ($view_forwarding);
}


print "<tr valign=middle><td width=55%><BR>";
print_header ("Manage your existing email set-up");
print "</td> </tr>";

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($create_user) eq "yes" ) )
{
	print "<tr valign=middle><td>Create a new email user</td><td>";
	show_option ($create_user);
	show_help ($create_user);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($delete_user) eq "yes" ) )
{
	print "<tr valign=middle><td>Delete an email user</td><td>";
        show_option ($delete_user);
        show_help ($delete_user);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($reset_password) eq "yes" ) )
{
        print "<tr valign=middle><td>Reset a user's password</td><td>";
        show_option ("$reset_password?type=email");
        show_help ($reset_password);
}


# To create a new email address the total number of email addresses must not exceed the soho limit

@existing_addresses = find_existing_addresses($domainname);
$num_existing_addresses = @existing_addresses;

@addresses_awaiting_addition = find_addresses_awaiting_addition_for_domain($domainname);
$num_addresses_awaiting_addition = @addresses_awaiting_addition;

@addresses_awaiting_deletion = find_addresses_awaiting_deletion_for_domain($domainname);
$num_addresses_awaiting_deletion = @addresses_awaiting_deletion;

$total_num_addresses = $num_existing_addresses + $num_addresses_awaiting_addition - $num_addresses_awaiting_deletion;

if ( ( $hostingplan ne "SOHO" ) || ( (check_if_allowed_on_soho($create_address) eq "yes") && ($total_num_addresses <= $soho_address_limit) ))
{
	print "<tr valign=middle><td>Create a new email address</td><td>";
        show_option ($create_address);
        show_help ($create_address);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($delete_address) eq "yes" ) )
{
        print "<tr valign=middle><td>Delete an email address</td><td>";
        show_option ($delete_address);
        show_help ($delete_address);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($create_forwarding) eq "yes" ) )
{
        print "<tr valign=middle><td>Forward emails to another email address</td><td>";
        show_option ($create_forwarding);
        show_help ($create_forwarding);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($empty_mailbox) eq "yes" ) )
{
	print "<tr valign=middle><td>Empty a user's mailbox</td><td>";
	show_option ($empty_mailbox);
	show_help ($empty_mailbox);
}

if ( ( $hostingplan ne "SOHO" ) || ( check_if_allowed_on_soho($create_multidrop) eq "yes" ) )
{

	print "<tr valign=middle><td width=50%><BR>";
	print_header ("Manage your multidrop account");
	print "</td> </tr>";

	$multidrop_address = "\@$domainname";
	$address_exists = find_if_address_exists($multidrop_address);
	if ( $address_exists == 0 )
	{
	        print "<tr valign=middle><td>Create a 'multi-drop' email account</td><td>";
        	show_option ($create_multidrop);
	        show_help ($create_multidrop);
	} else {
		print "<tr valign=middle><td>Delete your 'multi-drop' email account</td><td>";
        	show_option ($delete_multidrop);
		show_help ($delete_multidrop);
	}
}

if ( $hostingplan ne "SOHO" )
{
	print "<tr valign=middle><td width=50%><BR>";
        print_header ("Manage your 'Out of Office' email");
	print "</td> </tr>";

	print "<tr valign=middle><td>Create an 'Out of Office' reply</td><td>";
	show_option ($create_out_of_office);
	show_help ($create_out_of_office);

	# Show delete option only if there is at least one out of office reply already set up.
 	$num_out_of_office_replies = find_number_of_out_of_office_replies($domainname);
	if ( $num_out_of_office_replies > 0 )
	{
		print "<tr valign=middle><td>Delete an 'Out of Office' reply</td><td>";
		show_option ($delete_out_of_office);
		show_help ($delete_out_of_office);
	}
}

print "</table>";
