Update fs_selfservice/FS-SelfService/cgi/signup.html
[freeside.git] / fs_selfservice / FS-SelfService / cgi / signup.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4   <TITLE><%= $agent || ( $signup_service eq 'svc_phone' ? 'ITSP' : 'ISP' ) %> Signup form</TITLE>
5   <%= $head %>
6 </HEAD>
7 <BODY BGCOLOR="<%= $body_bgcolor || '#e8e8e8' %>" onUnload="myclose()">
8 <%= if ( $terms_of_service =~ /\S/ ) { # enable overlib
9   $OUT .= qq!<SCRIPT type="text/javascript" src="$_.js"></SCRIPT>\n!
10     foreach (qw(overlibmws overlibmws_iframe overlibmws_draggable 
11                 overlibmws_crossframe iframecontentmws ));
12 }
13 %>
14 <script type="text/javascript">
15   var mywindow = -1;
16   function myopen(filename,windowname,properties) {
17     myclose();
18     mywindow = window.open(filename,windowname,properties);
19   }
20   function myclose() {
21     if ( mywindow != -1 )
22       mywindow.close();
23     mywindow = -1
24   }
25 </script>
26
27 <%= $OUT .= $body_header
28       || '<FONT SIZE=7>'.
29          ( $agent || ( $signup_service eq 'svc_phone' ? 'ITSP' : 'ISP' ) ).
30          ' Signup form</FONT><BR><BR>';
31 %>
32
33 <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT>
34
35 <FORM NAME="OneTrueForm" ACTION="<%= $self_url %>" METHOD=POST onSubmit="document.OneTrueForm.signup.disabled=true">
36 <INPUT TYPE="hidden" NAME="prepaid_shortform" VALUE="<%= $prepaid_shortform %>">
37 <INPUT TYPE="hidden" NAME="session" VALUE="<%= $session_id %>">
38 <INPUT TYPE="hidden" NAME="action" VALUE="process_signup">
39 <INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $agentnum %>">
40 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<%= $referral_custnum %>">
41 <INPUT TYPE="hidden" NAME="ss" VALUE="">
42 <input type="hidden" name="payby">
43 <%=
44   $OUT = join("\n",map { my $method = $_ ; map { qq|<input type="hidden" name="${method}_$_" />| } qw / payinfo payinfo1 payinfo2 payname paystate paytype paycvv month year type  /  } @payby);
45 %>
46
47 <%=
48   $OUT = join("\n", map { qq|<input type="hidden" name="$_" />| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum mac_addr countrycode phonenum sip_password pin / );
49 %>
50
51 <%=
52   if ($override_ban_warn) {
53     $OUT .= 'Are you sure you want to sign up again? <SELECT NAME="override_ban_warn"><OPTION VALUE="0">No<OPTION VALUE="1">Yes</SELECT><BR><BR>';
54   } else {
55     $OUT .= '';
56   }
57 %>
58
59 Where did you hear about our service? <SELECT NAME="refnum">
60 <%=
61   $OUT .= '<OPTION VALUE="">' unless $refnum;
62   foreach my $part_referral ( @part_referral ) {
63     $OUT .= '<OPTION VALUE="'. $part_referral->{'refnum'}. '"';
64     $OUT .= ' SELECTED' if $part_referral->{'refnum'} == $refnum;
65     $OUT .= '>'. $part_referral->{'referral'};
66   }
67 %>
68 </SELECT><BR><BR>
69
70 <%= unless ( $prepaid_template_custnum && $prepaid_shortform  ) {
71
72 my $bgcolor = $box_bgcolor || '#c0c0c0';
73 $OUT .= qq!
74 Contact Information
75 <TABLE BGCOLOR="$bgcolor" BORDER=0 CELLSPACING=0 WIDTH="100%">
76 <TR>
77   <TH ALIGN="right"><font color="#ff0000">*</font>Contact name<BR>(last, first)</TH>
78   <TD COLSPAN=5><INPUT TYPE="text" NAME="last" VALUE="$last">,
79                 <INPUT TYPE="text" NAME="first" VALUE="$first"></TD>
80 </TR>
81 <TR>
82   <TD ALIGN="right">Company</TD>
83   <TD COLSPAN=5><INPUT TYPE="text" NAME="company" SIZE=70 VALUE="$company"></TD>
84 </TR>
85 <TR>
86   <TH ALIGN="right"><font color="#ff0000">*</font>Address</TH>
87   <TD COLSPAN=5><INPUT TYPE="text" NAME="address1" SIZE=70 VALUE="$address1"></TD>
88 </TR>
89 <TR>
90   <TD ALIGN="right">&nbsp;</TD>
91   <TD COLSPAN=5><INPUT TYPE="text" NAME="address2" SIZE=70 VALUE="$address2"></TD>
92 </TR>
93 <TR>
94   <TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
95   <TD><INPUT TYPE="text" NAME="city" VALUE="$city"></TD> !;
96
97         my ($county_html, $state_html, $country_html) =
98           regionselector( {
99             selected_county  => $county,
100             selected_state   => $state,
101             selected_country => $country,
102             default_state    => $statedefault,
103             default_country  => $countrydefault,
104             locales          => \@cust_main_county,
105           } );
106  
107 $county_out = ($county_html =~ /SELECT/) ? 'County/State' : 'State';
108 $OUT .= qq!<TH ALIGN="right"><font color="#ff0000">*</font> $county_out </TH>
109   <TD>
110     $county_html $state_html
111   </TD>
112   <TH><font color="#ff0000">*</font>Zip</TH>
113   <TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="$zip"></TD>
114 </TR>
115 <TR>
116   <TH ALIGN="right"><font color="#ff0000">*</font>Country</TH>
117   <TD>$country_html</TD>
118 <TR>
119   <TD ALIGN="right">Day Phone</TD>
120   <TD COLSPAN=5><INPUT TYPE="text" NAME="daytime" VALUE="$daytime" SIZE=18></TD>
121 </TR>
122 <TR>
123   <TD ALIGN="right">Night Phone</TD>
124   <TD COLSPAN=5><INPUT TYPE="text" NAME="night" VALUE="$night" SIZE=18></TD>
125 </TR>
126 <TR>
127   <TD ALIGN="right">Fax</TD>
128   <TD COLSPAN=5><INPUT TYPE="text" NAME="fax" VALUE="$fax" SIZE=12></TD>
129 </TR>
130 !;
131   if ( $stateid_enabled ) {
132     my ($county_html, $state_html, $country_html) =
133       regionselector( {
134         prefix           => 'stateid_',
135         default_state    => $statedefault,
136         default_country  => $countrydefault,
137         locales          => \@cust_main_county,
138       } );
139     $OUT .= qq!<TR><TD ALIGN="right">!. $label{stateid}.'</TD>';
140     $OUT .= qq!<TD><INPUT TYPE="text" NAME="stateid" VALUE="$stateid" SIZE=12></TD>!;
141     $OUT .= qq!<TD ALIGN="right">!. $label{stateid_state} .'</TD>';
142     $OUT .="<TD COLSPAN=3>$county_html $state_html</TD></TR>";
143   }
144 $OUT .= qq!
145 </TABLE><font color="#ff0000">*</font> required fields<BR>
146 !;
147
148 }
149 else {
150     @payby = ('PREPAY');
151 }
152 %>
153
154 <BR>Billing information<TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
155 <TR><TD>
156
157   <%=
158     $OUT ='';
159     unless ( $emailinvoiceonly ) { 
160     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
161     my @invoicing_list = split(', ', $invoicing_list );
162     $OUT .= ' CHECKED'
163       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
164     $OUT .= '>   Postal mail invoice'; } 
165   %>
166
167
168 </TD></TR>
169 <TR><TD><%= $OUT = ( $emailinvoiceonly ? q|<font color="#ff0000">*</font>| : q|| ) %> Email invoice <INPUT TYPE="text" NAME="invoicing_list" VALUE="<%= join(', ', grep { $_ ne 'POST' } split(', ', $invoicing_list ) ) %>">
170 </TD></TR>
171 <%= ( scalar(@payby) > 1 or 1 ) ? '<TR><TD>Billing type ' : '' %>
172 <!--</TABLE>
173 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
174 <TR>-->
175
176   <%=
177
178     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
179     foreach ( keys %card_types ) {
180       $selected = $CARD_type eq $card_types{$_} ? 'SELECTED' : '';
181       $cardselect .= qq!<OPTION $selected VALUE="$card_types{$_}">$_</OPTION>!;
182     }
183     $cardselect .= '</SELECT>';
184   
185     my %payby = (
186       'CARD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="CARD_payinfo" VALUE="" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("CARD"). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="CARD_payname" VALUE="">!,
187       'DCRD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("DCRD"). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="">!,
188       'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="" MAXLENGTH=10><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9> Type <SELECT NAME="CHEK_paytype">!. join('', map {qq!<OPTION VALUE="$_">$_</OPTION>!} @paytypes). qq!</SELECT><BR>{$r}Bank State <INPUT TYPE="text" NAME="CHEK_paystate" VALUE="" SIZE=5 MAXLENGTH=4><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="">!,
189       'DCHK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE="" MAXLENGTH=10> Type <SELECT NAME="DCHK_paytype">!. join('', map {qq!<OPTION VALUE="$_">$_</OPTION>!} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="" SIZE=10 MAXLENGTH=9><BR>{$r}Bank State <INPUT TYPE="text" NAME="DCHK_paystate" VALUE="" SIZE=5 MAXLENGTH=4><INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="">!,
190       'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" NAME="LECB_payinfo" VALUE="" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!,
191       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE=""><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<INPUT TYPE="text" NAME="BILL_payname" VALUE="Accounts Payable">!,
192       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE=""><BR><font color="#ff0000">*</font>Exp !. expselect("COMP"),
193       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
194     );
195
196     if ( $cvv_enabled ) {
197       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
198         $payby{$payby} .= qq!<TR><TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD><TD><INPUT TYPE="text" NAME=${payby}_paycvv VALUE="" SIZE=4 MAXLENGTH=4></TD></TR>!;
199       }
200     }
201     if ( $paystate_enabled ) {
202       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
203         my ($county_html, $state_html, $country_html) =
204           regionselector( {
205             prefix           => "${payby}_pay",
206             default_state    => $statedefault,
207             default_country  => $countrydefault,
208             locales          => \@cust_main_county,
209           } );
210         $payby{$payby} .= "<BR>${r}Bank state $county_html $state_html";
211       }
212     }
213
214     my( $account, $aba ) = split('@', $payinfo);
215     my %paybychecked = (
216       'CARD' => '<TABLE BGCOLOR="'. ( $box_bgcolor || '#c0c0c0' ). qq!" BORDER=0 CELLSPACING=0 WIDTH="100%"><TR><TD ALIGN="right"><font color="#ff0000">*</font> Card type</TD><TD>$cardselect</TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Card number</TD><TD><INPUT TYPE="text" NAME="CARD_payinfo" VALUE="$payinfo" MAXLENGTH=19></TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Expiration</TD><TD>!. expselect("CARD", $paydate). qq!</TD></TR><TR><TD ALIGN="right"><font color="#ff0000">*</font> Name on card</TD><TD><INPUT TYPE="text" NAME="CARD_payname" VALUE="$payname"></TD></TR>!,
217       'DCRD' => qq!Credit card<BR><font color="#ff0000">*</font>$cardselect<INPUT TYPE="text" NAME="DCRD_payinfo" VALUE="$payinfo" MAXLENGTH=19><BR><font color="#ff0000">*</font>Exp !. expselect("DCRD", $paydate). qq!<BR><font color="#ff0000">*</font>Name on card<BR><INPUT TYPE="text" NAME="DCRD_payname" VALUE="$payname">!,
218       'CHEK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="CHEK_payinfo1" VALUE="$account" MAXLENGTH=10> Type <SELECT NAME="CHEK_paytype">!. join('', map {qq!<OPTION VALUE="$_"!.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>"} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="CHEK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="CHEK_month" VALUE="12"><INPUT TYPE="hidden" NAME="CHEK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="CHEK_payname" VALUE="$payname">!,
219       'DCHK' => qq!Electronic check<BR>${r}Account number <INPUT TYPE="text" NAME="DCHK_payinfo1" VALUE="$account" MAXLENGTH=10> Type <SELECT NAME="DCHK_paytype">!. join('', map {qq!<OPTION VALUE="$_"!.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>"} @paytypes). qq!</SELECT><BR>${r}ABA/Routing code <INPUT TYPE="text" NAME="DCHK_payinfo2" VALUE="$aba" SIZE=10 MAXLENGTH=9><INPUT TYPE="hidden" NAME="DCHK_month" VALUE="12"><INPUT TYPE="hidden" NAME="DCHK_year" VALUE="2037"><BR>${r}Bank name <INPUT TYPE="text" NAME="DCHK_payname" VALUE="">!,
220       'LECB' => qq!Phone bill billing<BR>${r}Phone number <INPUT TYPE="text" BANE="LECB_payinfo" VALUE="$payinfo" MAXLENGTH=15 SIZE=16><INPUT TYPE="hidden" NAME="LECB_month" VALUE="12"><INPUT TYPE="hidden" NAME="LECB_year" VALUE="2037"><INPUT TYPE="hidden" NAME="LECB_payname" VALUE="">!,
221       'BILL' => qq!Billing<BR>P.O. <INPUT TYPE="text" NAME="BILL_payinfo" VALUE="$payinfo"><BR><INPUT TYPE="hidden" NAME="BILL_month" VALUE="12"><INPUT TYPE="hidden" NAME="BILL_year" VALUE="2037">Attention<INPUT TYPE="text" NAME="BILL_payname" VALUE="$payname">!,
222       'COMP' => qq!Complimentary<BR><font color="#ff0000">*</font>Approved by<INPUT TYPE="text" NAME="COMP_payinfo" VALUE="$payinfo"><BR><font color="#ff0000">*</font>Exp !. expselect("COMP", $paydate),
223       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
224     );
225
226     if ( $cvv_enabled ) {
227       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
228         $paybychecked{$payby} .= qq!<TR><TD ALIGN="right">CVV2&nbsp;(<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD><TD><INPUT TYPE="text" NAME=${payby}_paycvv VALUE="$paycvv" SIZE=4 MAXLENGTH=4></TD></TR>!;
229       }
230     }
231     if ( $paystate_enabled ) {
232       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
233         my ($county_html, $state_html, $country_html) =
234           regionselector( {
235             prefix           => "${payby}_pay",
236             selected_county  => $county,
237             selected_state   => $state,
238             selected_country => $country,
239             default_state    => $statedefault,
240             default_country  => $countrydefault,
241             locales          => \@cust_main_county,
242           } );
243         $paybychecked{$payby} .= "<BR>${r}Bank state $county_html $state_html";
244       }
245     }
246
247   my %payby_index = ( 'CARD'   => qq/Credit Card/,
248                       'DCRD'   => qq/Credit Card/,
249                       'CHEK'   => qq/Check/,
250                       'DCHK'   => qq/Check/,
251                       'LECB'   => qq/Phone Bill Billing/,
252                       'BILL'   => qq/Billing/,
253                       'COMP'   => qq/Complimentary/,
254                       'PREPAY' => qq/Prepaid Card/,
255                     );
256   
257
258 tie my %options, 'Tie::IxHash', ();
259
260 foreach my $payby_option ( @payby ) {
261   $options{$payby_option} = $payby_index{$payby_option};
262 }
263
264 my $selected_layer = ( grep { $_ eq 'CARD' } @payby ) ? 'CARD' : $payby[0];
265
266 HTML::Widgets::SelectLayers->new(
267   options => \%options,
268   selected_layer => $selected_layer,
269   form_name => 'dummy',
270   html_between => '</td></tr></table>',
271   form_action => 'dummy.cgi',
272   layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . '</TABLE>'; },
273 )->html;
274
275
276   %>
277
278 </TR></TABLE><font color="#ff0000">*</font> required fields
279 <FORM name="signup_form" action="<%= $self_url %>" METHOD="POST" onsubmit="return fixup_form();"><BR><BR>First package
280 <INPUT TYPE="hidden" NAME="promo_code" VALUE="<%= $promo_code %>">
281 <INPUT TYPE="hidden" NAME="reg_code" VALUE="<%= $reg_code %>">
282 <TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
283 <TR>
284   <TD COLSPAN=2><SELECT NAME="pkgpart">
285
286   <%=
287     $OUT .= '<OPTION VALUE="">(none)'
288       unless scalar(@part_pkg) == 1 or $default_pkgpart;
289     foreach my $part_pkg ( @part_pkg ) {
290       $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
291       $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
292       $OUT .= '>'. $part_pkg->{'pkg'};
293     }
294   %>
295
296   </SELECT></TD>
297 </TR>
298 <%=
299   if ( $signup_service eq 'svc_phone' ) {
300
301     $OUT .= '<TR><TD ALIGN="right">Phone number</TD><TD>'.
302             didselector( 'field'   => 'phonenum',
303                          'svcpart' => $default_svcpart,
304                        ).
305             '</TD></TR>';
306
307     $OUT .= <<ENDOUT;
308 <TR>
309   <TD ALIGN="right">Voicemail PIN</TD>
310   <TD><INPUT TYPE="pin" NAME="pin" VALUE="$pin"></TD>
311 </TR>
312 ENDOUT
313
314   } else {
315
316     $OUT .= <<ENDOUT;
317 <TR>
318   <TD ALIGN="right">Username</TD>
319   <TD><INPUT TYPE="text" NAME="username" VALUE="$username"></TD>
320 </TR>
321 <TR>
322   <TD ALIGN="right">Password</TD>
323   <TD><INPUT TYPE="password" NAME="_password" VALUE="$_password"></TD>
324 </TR>
325 <TR>
326   <TD ALIGN="right">Re-enter Password</TD>
327   <TD><INPUT TYPE="password" NAME="_password2" VALUE="$_password2"></TD>
328 </TR>
329 ENDOUT
330
331     if ( $security_phrase ) {
332       $OUT .= <<SECPHRASE;
333 <TR>
334   <TD ALIGN="right">Security Phrase</TD>
335   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
336   </TD>
337 </TR>
338 SECPHRASE
339     } else {
340       $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
341     }
342
343     if ( $nomadix ) {
344
345       warn $mac_addr;
346       $mac_addr ||= $MA;
347       warn $mac_addr;
348
349       $OUT .= <<NOMADIX;
350         <INPUT TYPE="hidden" NAME="mac_addr" VALUE="$mac_addr">
351 NOMADIX
352
353     }
354
355   }
356
357   if ( @svc_acct_pop ) {
358     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
359             popselector( 'popnum'        => $popnum,
360                          'pops'          => \@svc_acct_pop,
361                          'init_popstate' => $init_popstate,
362                          'popac'         => $popac,
363                          'acstate'       => $acstate,
364                        ).
365             '</TD></TR>';
366   } else {
367     $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
368   }
369
370 %>
371
372 </TABLE>
373
374 <%= 
375 if ( @optional_packages ) { 
376   my @html;
377   foreach my $ii ( 0 .. $#optional_packages) {
378   my $friendly_index = $ii + 1; 
379   if ($optional_packages[$ii]) {
380     push @html, qq|<BR>Optional Package #$friendly_index <br />|,'<table bgcolor="#c0c0c0"><tr><td>';
381
382     push @html, qq|<select name="optional_package${ii}">|;
383     push @html, qq|<option value="none"></option>|;
384     push @html, map { qq|<option value="$_->{pkgpart}">$_->{pkg}</option>| } @{$optional_packages[$ii]};
385     push @html, q|</select>|;
386     
387     push @html, '</td></tr></table>';
388     }
389     $OUT = join("\n", @html);
390   }  
391 } else {
392 $OUT = ''
393 }
394 %>
395 <%=
396   if ( $terms_of_service =~ /\S/ ) {
397     my $title = 'Terms of Service'; #config?
398     my $onclick = qq[overlib( terms_content, CAPTION, "$title", STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, CLOSETEXT, "Close" );];
399     # Container for $terms_of_service to avoid nasty escaping.
400     $OUT .= qq[
401 <BR>
402 <DIV id="div_terms" style="display:none">$terms_of_service</DIV>
403 <SCRIPT type="text/javascript">
404 function agree_to_terms (val) {
405   document.getElementById("signup").disabled = !val;
406 }
407 function show_terms () {
408   overlib( document.getElementById('div_terms').innerHTML,
409     CAPTION, '$title', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE,
410     CLOSECLICK, CLOSETEXT, 'Close' );
411 }
412 </SCRIPT>
413 <INPUT TYPE="checkbox" onchange="agree_to_terms(this.checked)">&nbsp;
414 I agree to the <a href="javascript:void(0);" onclick="show_terms();">Terms of Service</a>.
415 ];
416   }
417 %>
418 <BR><INPUT TYPE="submit" ID="signup" NAME="signup" VALUE="Signup">
419 <script language="javascript">
420 <%= length($terms_of_service) ? 'agree_to_terms(false)' : '' %>
421
422 function fixup_form() {
423     
424     // copy payment method data up to OneTrueForm
425     
426     var payment_method_elements = new Array( 'payinfo', 'payinfo1', 'payinfo2', 'payname', 'paycvv' , 'paystate', 'paytype', 'month', 'year','type' );
427     var payment_method_form_name = document.OneTrueForm.select.options[document.OneTrueForm.select.selectedIndex].value;
428     document.OneTrueForm.elements['payby'].value = payment_method_form_name;
429     var payment_method_form = document.forms[payment_method_form_name];
430
431     for ( ii = 0 ; ii < payment_method_elements.length ; ii++ ) {
432         var true_element_name = payment_method_form_name + '_' + payment_method_elements[ii];
433         copyelement ( payment_method_form.elements[true_element_name],
434                       document.OneTrueForm.elements[true_element_name] );
435     }
436     
437     // Copy signup details to OneTrueForm
438     
439     var signup_elements = new Array (
440       'promo_code', 'reg_code', 'pkgpart',
441       'username', '_password', '_password2', 'sec_phrase', 'popnum',
442       'mac_addr',
443       'countrycode', 'phonenum', 'sip_password', 'pin'
444     );
445
446     for ( ii = 0 ; ii < signup_elements.length ; ii ++ ) {
447         copyelement ( document.signup_form.elements[signup_elements[ii]],
448                       document.OneTrueForm.elements[signup_elements[ii]]);
449     }
450
451     document.OneTrueForm.submit();
452     return false;
453 }
454
455 function copyelement(from, to) {
456 //    alert ( from + ' ' + to );
457     
458     if ( from == undefined ) {
459         to.value = '';
460     } else { 
461         if ( from.type == 'select-one' ) {
462             to.value = from.options[from.selectedIndex].value;
463         } else if ( from.type == 'checkbox' ) {
464             if ( from.checked ) {
465                 to.value = from.value;
466             } else {
467                 to.value = '';
468             }
469         } else {
470             if ( from.value == undefined ) {
471                 to.value = '';
472             } else {
473                 to.value = from.value;
474             }
475         }
476 //      alert(from.name + " (" + from.type + "): " + to.name + " => " + to.value);
477     }
478 }
479
480 </script>
481 </FORM>
482 <%= $OUT .= $body_footer %>
483 </BODY>
484 </HTML>