#!/usr/bin/perl

print "Content-Type: Text/HTML\n\n";

use CGI ':standard';
use Vpanel 1.00;
require $header;
require $accountinfo;
$domainname = find_domain ($mainuser);

@existing_addresses = find_existing_addresses($domainname);
@addresses_awaiting_deletion = find_addresses_awaiting_deletion();

$abuse = "abuse\@$domainname";
$postmaster = "postmaster\@$domainname";

# Define the tab which appears to the front
$tab_section = $tabnum_email;

# Output the content associated with this tab
print "<body class=section-$tab_section>";

# display tabs
require $tabdisplay;

print_header ("Deletion of an email address for $domainname");

print "Please select the address you wish to delete from the list below:<BR><BR>";

print "<table width=50% class=text>";
print "<form method=post action=/$script_bin/$confirm_delete_address class=text>";
print "<tr><td width=10%><B>Address:</B></td><td><select name=address class=text>";

for $existing_address ( @existing_addresses )
{
	$awaiting_deletion = 0;
	chomp ($existing_address);
	for $del_address (@addresses_awaiting_deletion)
	{
		chomp ($del_address);
		if ( $del_address eq $existing_address ) 
		{
			$awaiting_deletion = 1;
			break;
		}
	}
	
	if ( $awaiting_deletion == 0 && ( $existing_address ne $abuse ) && ( $existing_address ne $postmaster ) )
	{
		print "<option value=$existing_address>$existing_address";
	}
}
print "</select></td></tr></table>";

print_end_of_form();

require $footer;
