Index: /trunk/cic-hcap/perllib/plugins/CICPlug.pm
===================================================================
--- /trunk/cic-hcap/perllib/plugins/CICPlug.pm	(revision 11874)
+++ /trunk/cic-hcap/perllib/plugins/CICPlug.pm	(revision 11875)
@@ -861,7 +861,6 @@
     print STDERR "Writing $static_browser_macrofile_path...\n";
     open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
+    &write_static_browser_macros($static_browser_package_name, $name_to_id_mapping);
     close(BROWSER_MACROFILE);
-
-    &write_static_browser_macros($static_browser_package_name, $name_to_id_mapping);
 }
 
@@ -871,8 +870,7 @@
     my $static_browser_package_name = shift(@_);
     my $name_to_id_mapping = shift(@_);
+    my $id_to_extra_mapping = shift(@_);
     my $table_columns = 2;
 
-    my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_name.dm";
-    open(BROWSER_MACROFILE, ">>$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
     print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
     print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
@@ -907,10 +905,18 @@
 	    my $name = $letter_names[$i];
 	    my $id = $name_to_id_mapping->{$name};
-	    print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a></td>";
+	    my $extra = "";
+	    if (defined($id_to_extra_mapping)) {
+		$extra = $id_to_extra_mapping->{$id};
+	    }
+	    print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a>$extra</td>";
 
 	    $name = $letter_names[$i+$half_point];
 	    if (defined($name)) {
 		$id = $name_to_id_mapping->{$name};
-		print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a></td>";
+		$extra = "";
+		if (defined($id_to_extra_mapping)) {
+		    $extra = $id_to_extra_mapping->{$id};
+		}
+		print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a>$extra</td>";
 	    }
 	    else {
@@ -923,5 +929,4 @@
 
     print BROWSER_MACROFILE "}\n";
-    close(BROWSER_MACROFILE);
 }
 
@@ -945,179 +950,9 @@
 	$static_browser_package_name =~ s/\W//g;
 
-	print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
-        print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
-
-        print BROWSER_MACROFILE "<center><b>";
-        foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
-	    print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a>&nbsp;";
-        }
-        print BROWSER_MACROFILE "</b></center>\n";
-
-	print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
-
-	my $last_name = "";
-        my $current_letter = "";
-        my $current_position = 0;
+	my %name_to_id_mapping_for_category = ();
 	foreach my $name (sort(@{$category_to_names_mapping->{$category}})) {
-	    # Ignore duplicates
-	    next if ($name eq $last_name);
-
-	    $name =~ /^(.)/;
-	    if ($1 ne $current_letter) {
-		if ($current_position > 0) {
-		    while ($current_position > 0) {
-			print BROWSER_MACROFILE "<td></td>";
-			$current_position--;
-		    }
-		    print BROWSER_MACROFILE "</tr>\n";
-		}
-		print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td width=\"50%\"></td></tr>\n";
-		$current_letter = $1;
-	    }
-
-	    my $id = $name_to_id_mapping->{$name};
-	    my $extra = "";
-	    if (defined($id_to_extra_mapping)) {
-		$extra = $id_to_extra_mapping->{$id};
-	    }
-
-	    if ($current_position == 0) {
-		print BROWSER_MACROFILE "<tr>";
-	    }
-	    print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a>$extra</td>";
-	    $current_position++;
-	    if ($current_position == $table_columns) {
-		print BROWSER_MACROFILE "</tr>\n";
-		$current_position = 0;
-	    }
-
-	    $last_name = $name;
-	}
-
-	print BROWSER_MACROFILE "}\n\n";
-    }
-
-    close(BROWSER_MACROFILE);
-}
-
-
-sub write_bilevel_static_browser_macrofile_new
-{
-    my $static_browser_package_root = shift(@_);
-    my $category_to_names_mapping = shift(@_);
-    my $name_to_id_mapping = shift(@_);
-    my $id_to_extra_mapping = shift(@_);
-    my $table_columns = 2;
-
-    my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_root.dm";
-    print STDERR "Writing $static_browser_macrofile_path...\n";
-    open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
-
-    foreach my $category (keys(%{$category_to_names_mapping})) {
-	# print STDERR "Category: $category\n";
-
-	my $static_browser_package_name = $static_browser_package_root . $category;
-	$static_browser_package_name =~ s/\W//g;
-
-	print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
-        print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
-
-	my %letter_to_name_mapping;
-	foreach my $name (@{$category_to_names_mapping->{$category}}) {
-	    my ($letter) = ($name =~ /^(.)/);
-	    push(@{$letter_to_name_mapping{$letter}}, $name);
-	}
-
-        print BROWSER_MACROFILE "<center><b>";
-        foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
-	    if (defined($letter_to_name_mapping{$letter})) {
-		print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a>&nbsp;";
-	    }
-	    else {
-		print BROWSER_MACROFILE "$letter&nbsp;";
-	    }
-	}
-        print BROWSER_MACROFILE "</b></center>\n";
-
-	print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
-
-	foreach my $letter (sort(keys %letter_to_name_mapping)) {
-	    print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$letter\"/><span style=\"color: black;\"><b>$letter</b></span></td><td width=\"50%\"></td></tr>\n";
-
-	    my @letter_names = sort(@{$letter_to_name_mapping{$letter}});
-	    my $half_point = ((scalar(@letter_names) % 2 == 0) ? scalar(@letter_names) / 2 : (scalar(@letter_names) + 1) / 2);
-	    for (my $i = 0; $i < $half_point; $i++) {
-		print BROWSER_MACROFILE "<tr>";
-
-		my $name = $letter_names[$i];
-		my $id = $name_to_id_mapping->{$name};
-		my $extra = $id_to_extra_mapping->{$id};
-		print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a>$extra</td>";
-
-		$name = $letter_names[$i+$half_point];
-		if (defined($name)) {
-		    $id = $name_to_id_mapping->{$name};
-		    $extra = $id_to_extra_mapping->{$id};
-		    print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a>$extra</td>";
-		}
-		else {
-		    print BROWSER_MACROFILE "<td></td>";
-		}
-
-		print BROWSER_MACROFILE "</tr>\n";
-	    }
-	}
-
-#  	my $last_name = "";
-#          my $current_letter = "";
-#          my $current_position = 0;
-#  	foreach my $name (sort(@{$category_to_names_mapping->{$category}})) {
-#  	    # Ignore duplicates
-#  	    next if ($name eq $last_name);
-
-#  	    $name =~ /^(.)/;
-#  	    if ($1 ne $current_letter) {
-#  		if ($current_position > 0) {
-#  		    while ($current_position > 0) {
-#  			print BROWSER_MACROFILE "<td></td>";
-#  			$current_position--;
-#  		    }
-#  		    print BROWSER_MACROFILE "</tr>\n";
-#  		}
-#  		if ($table_columns == 2) {
-#  		    print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td width=\"50%\"></td></tr>\n";
-#  		}
-#  		else {
-#  		    print BROWSER_MACROFILE "<tr><td width=\"33%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td style=\"padding-left: 3px; padding-right: 3px;\" width=\"34%\"></td><td width=\"33%\"></td></tr>\n";
-#  		}
-#  		$current_letter = $1;
-#  	    }
-
-#  	    my $id = $name_to_id_mapping->{$name};
-#  	    my $extra = "";
-#  	    if (defined($id_to_extra_mapping)) {
-#  		$extra = $id_to_extra_mapping->{$id};
-#  	    }
-
-#  	    if ($current_position == 0) {
-#  		print BROWSER_MACROFILE "<tr>";
-#  	    }
-#  	    if (!defined($name) || !defined($id_prefix) || !defined($id) || !defined($extra)) {
-#  		print STDERR "Name: $name\n";
-#  		print STDERR "ID prefix: $id_prefix\n";
-#  		print STDERR "ID: $id\n";
-#  		print STDERR "Extra: $extra\n";
-#  	    }
-#  	    print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id_prefix$id\">$name</a>$extra</td>";
-#  	    $current_position++;
-#  	    if ($current_position == $table_columns) {
-#  		print BROWSER_MACROFILE "</tr>\n";
-#  		$current_position = 0;
-#  	    }
-
-#  	    $last_name = $name;
-#  	}
-
-	print BROWSER_MACROFILE "}\n\n";
+	    $name_to_id_mapping_for_category{$name} = $name_to_id_mapping->{$name};
+	}
+	&write_static_browser_macros($static_browser_package_name, \%name_to_id_mapping_for_category, $id_to_extra_mapping);
     }
 
