306e4974918c573894027e21ebfb4f6a5d91c1d9
[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"><%= encode_entities($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="<%= encode_entities($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
155 <BR>Billing information<TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
156 <TR><TD>
157
158   <%=
159     $OUT ='';
160     unless ( $emailinvoiceonly ) { 
161     $OUT .= '<INPUT TYPE="checkbox" NAME="invoicing_list_POST" VALUE="POST"';
162     my @invoicing_list = split(', ', $invoicing_list );
163     $OUT .= ' CHECKED'
164       if ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list;
165     $OUT .= '>   Postal mail invoice'; } 
166   %>
167
168
169 </TD></TR>
170 <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 ) ) %>">
171 </TD></TR>
172 <%= ( scalar(@payby) > 1 or 1 ) ? '<TR><TD>Billing type ' : '' %>
173 <!--</TABLE>
174 <TABLE BGCOLOR="#c0c0c0" BORDER=1 WIDTH="100%">
175 <TR>-->
176
177   <%=
178
179     my $cardselect = '<SELECT NAME="CARD_type"><OPTION></OPTION>';
180     foreach ( keys %card_types ) {
181       $selected = $CARD_type eq $card_types{$_} ? 'SELECTED' : '';
182       $cardselect .= qq!<OPTION $selected VALUE="$card_types{$_}">$_</OPTION>!;
183     }
184     $cardselect .= '</SELECT>';
185   
186     my %payby = (
187       '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="">!,
188       '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="">!,
189       '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="">!,
190       '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="">!,
191       '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="">!,
192       '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">!,
193       '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"),
194       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="" MAXLENGTH=80>!,
195     );
196
197     if ( $cvv_enabled ) {
198       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
199         $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>!;
200       }
201     }
202     if ( $paystate_enabled ) {
203       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
204         my ($county_html, $state_html, $country_html) =
205           regionselector( {
206             prefix           => "${payby}_pay",
207             default_state    => $statedefault,
208             default_country  => $countrydefault,
209             locales          => \@cust_main_county,
210           } );
211         $payby{$payby} .= "<BR>${r}Bank state $county_html $state_html";
212       }
213     }
214
215     my( $account, $aba ) = split('@', $payinfo);
216     my %paybychecked = (
217       '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>!,
218       '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">!,
219       '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">!,
220       '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="">!,
221       '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="">!,
222       '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">!,
223       '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),
224       'PREPAY' => qq!Prepaid card<BR><font color="#ff0000">*</font><INPUT TYPE="text" NAME="PREPAY_payinfo" VALUE="$payinfo" MAXLENGTH=80>!,
225     );
226
227     if ( $cvv_enabled ) {
228       foreach my $payby ( grep { exists $payby{$_} } qw(CARD DCRD) ) { #1.4/1.5
229         $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>!;
230       }
231     }
232     if ( $paystate_enabled ) {
233       foreach my $payby ( grep { exists $payby{$_} } qw(CHEK DCHK) ) { 
234         my ($county_html, $state_html, $country_html) =
235           regionselector( {
236             prefix           => "${payby}_pay",
237             selected_county  => $county,
238             selected_state   => $state,
239             selected_country => $country,
240             default_state    => $statedefault,
241             default_country  => $countrydefault,
242             locales          => \@cust_main_county,
243           } );
244         $paybychecked{$payby} .= "<BR>${r}Bank state $county_html $state_html";
245       }
246     }
247
248   my %payby_index = ( 'CARD'   => qq/Credit Card/,
249                       'DCRD'   => qq/Credit Card/,
250                       'CHEK'   => qq/Check/,
251                       'DCHK'   => qq/Check/,
252                       'LECB'   => qq/Phone Bill Billing/,
253                       'BILL'   => qq/Billing/,
254                       'COMP'   => qq/Complimentary/,
255                       'PREPAY' => qq/Prepaid Card/,
256                     );
257   
258
259 tie my %options, 'Tie::IxHash', ();
260
261 foreach my $payby_option ( @payby ) {
262   $options{$payby_option} = $payby_index{$payby_option};
263 }
264
265 my $selected_layer = ( grep { $_ eq 'CARD' } @payby ) ? 'CARD' : $payby[0];
266
267 HTML::Widgets::SelectLayers->new(
268   options => \%options,
269   selected_layer => $selected_layer,
270   form_name => 'dummy',
271   html_between => '</td></tr></table>',
272   form_action => 'dummy.cgi',
273   layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . '</TABLE>'; },
274 )->html;
275
276
277   %>
278
279 </TR></TABLE><font color="#ff0000">*</font> required fields
280 <FORM name="signup_form" action="<%= $self_url %>" METHOD="POST" onsubmit="return fixup_form();"><BR><BR>First package
281 <INPUT TYPE="hidden" NAME="promo_code" VALUE="<%= $promo_code %>">
282 <INPUT TYPE="hidden" NAME="reg_code" VALUE="<%= $reg_code %>">
283 <TABLE BGCOLOR="<%= $box_bgcolor || '#c0c0c0' %>" BORDER=0 CELLSPACING=0 WIDTH="100%">
284 <TR>
285   <TD COLSPAN=2><SELECT NAME="pkgpart">
286
287   <%=
288     $OUT .= '<OPTION VALUE="">(none)'
289       unless scalar(@part_pkg) == 1 or $default_pkgpart;
290     foreach my $part_pkg ( @part_pkg ) {
291       $OUT .= '<OPTION VALUE="'. $part_pkg->{'pkgpart'}. '"';
292       $OUT .= ' SELECTED' if $pkgpart && $part_pkg->{'pkgpart'} == $pkgpart;
293       $OUT .= '>'. $part_pkg->{'pkg'};
294     }
295   %>
296
297   </SELECT></TD>
298 </TR>
299 <%=
300   if ( $signup_service eq 'svc_phone' ) {
301
302     $OUT .= '<TR><TD ALIGN="right">Phone number</TD><TD>'.
303             didselector( 'field'   => 'phonenum',
304                          'svcpart' => $default_svcpart,
305                        ).
306             '</TD></TR>';
307
308     $OUT .= <<ENDOUT;
309 <TR>
310   <TD ALIGN="right">Voicemail PIN</TD>
311   <TD><INPUT TYPE="pin" NAME="pin" VALUE="$pin"></TD>
312 </TR>
313 ENDOUT
314
315   } else {
316
317     $OUT .= <<ENDOUT;
318 <TR>
319   <TD ALIGN="right">Username</TD>
320   <TD><INPUT TYPE="text" NAME="username" VALUE="$username"></TD>
321 </TR>
322 ENDOUT
323
324   $OUT .= domainselector( svcpart=>$default_svcpart, domsvc=>$default_domsvc )
325     if $default_svcpart;
326
327     $OUT .= <<ENDOUT;
328 <TR>
329   <TD ALIGN="right">Password</TD>
330   <TD><INPUT TYPE="password" NAME="_password" VALUE="$_password"></TD>
331 </TR>
332 <TR>
333   <TD ALIGN="right">Re-enter Password</TD>
334   <TD><INPUT TYPE="password" NAME="_password2" VALUE="$_password2"></TD>
335 </TR>
336 ENDOUT
337
338     if ( $security_phrase ) {
339       $OUT .= <<SECPHRASE;
340 <TR>
341   <TD ALIGN="right">Security Phrase</TD>
342   <TD><INPUT TYPE="text" NAME="sec_phrase" VALUE="$sec_phrase">
343   </TD>
344 </TR>
345 SECPHRASE
346     } else {
347       $OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
348     }
349
350     if ( $nomadix ) {
351
352       warn $mac_addr;
353       $mac_addr ||= $MA;
354       warn $mac_addr;
355
356       $OUT .= <<NOMADIX;
357         <INPUT TYPE="hidden" NAME="mac_addr" VALUE="$mac_addr">
358 NOMADIX
359
360     }
361
362   }
363
364   if ( @svc_acct_pop ) {
365     $OUT .= '<TR><TD ALIGN="right">Access number</TD><TD>'.
366             popselector( 'popnum'        => $popnum,
367                          'pops'          => \@svc_acct_pop,
368                          'init_popstate' => $init_popstate,
369                          'popac'         => $popac,
370                          'acstate'       => $acstate,
371                        ).
372             '</TD></TR>';
373   } else {
374     $OUT .= popselector(popnum=>$popnum, pops=>\@svc_acct_pop);
375   }
376
377 %>
378
379 </TABLE>
380
381 <%= 
382 if ( @optional_packages ) { 
383   my @html;
384   foreach my $ii ( 0 .. $#optional_packages) {
385   my $friendly_index = $ii + 1; 
386   if ($optional_packages[$ii]) {
387     push @html, qq|<BR>Optional Package #$friendly_index <br />|,'<table bgcolor="#c0c0c0"><tr><td>';
388
389     push @html, qq|<select name="optional_package${ii}">|;
390     push @html, qq|<option value="none"></option>|;
391     push @html, map { qq|<option value="$_->{pkgpart}">$_->{pkg}</option>| } @{$optional_packages[$ii]};
392     push @html, q|</select>|;
393     
394     push @html, '</td></tr></table>';
395     }
396     $OUT = join("\n", @html);
397   }  
398 } else {
399 $OUT = ''
400 }
401 %>
402 <%=
403   if ( $terms_of_service =~ /\S/ ) {
404     my $title = 'Terms of Service'; #config?
405     my $onclick = qq[overlib( terms_content, CAPTION, "$title", STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, CLOSETEXT, "Close" );];
406     # Container for $terms_of_service to avoid nasty escaping.
407     $OUT .= qq[
408 <BR>
409 <DIV id="div_terms" style="display:none">$terms_of_service</DIV>
410 <SCRIPT type="text/javascript">
411 function agree_to_terms (val) {
412   document.getElementById("signup").disabled = !val;
413 }
414 function show_terms () {
415   overlib( document.getElementById('div_terms').innerHTML,
416     CAPTION, '$title', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE,
417     CLOSECLICK, CLOSETEXT, 'Close' );
418 }
419 </SCRIPT>
420 <INPUT TYPE="checkbox" onchange="agree_to_terms(this.checked)">&nbsp;
421 I agree to the <a href="javascript:void(0);" onclick="show_terms();">Terms of Service</a>.
422 ];
423   }
424 %>
425 <BR><INPUT TYPE="submit" ID="signup" NAME="signup" VALUE="Signup">
426 <script language="javascript">
427 <%= length($terms_of_service) ? 'agree_to_terms(false)' : '' %>
428
429 function fixup_form() {
430     
431     // copy payment method data up to OneTrueForm
432     
433     var payment_method_elements = new Array( 'payinfo', 'payinfo1', 'payinfo2', 'payname', 'paycvv' , 'paystate', 'paytype', 'month', 'year','type' );
434     var payment_method_form_name = document.OneTrueForm.select.options[document.OneTrueForm.select.selectedIndex].value;
435     document.OneTrueForm.elements['payby'].value = payment_method_form_name;
436     var payment_method_form = document.forms[payment_method_form_name];
437
438     for ( ii = 0 ; ii < payment_method_elements.length ; ii++ ) {
439         var true_element_name = payment_method_form_name + '_' + payment_method_elements[ii];
440         copyelement ( payment_method_form.elements[true_element_name],
441                       document.OneTrueForm.elements[true_element_name] );
442     }
443     
444     // Copy signup details to OneTrueForm
445     
446     var signup_elements = new Array (
447       'promo_code', 'reg_code', 'pkgpart',
448       'username', '_password', '_password2', 'sec_phrase', 'popnum',
449       'mac_addr',
450       'countrycode', 'phonenum', 'sip_password', 'pin'
451     );
452
453     for ( ii = 0 ; ii < signup_elements.length ; ii ++ ) {
454         copyelement ( document.signup_form.elements[signup_elements[ii]],
455                       document.OneTrueForm.elements[signup_elements[ii]]);
456     }
457
458     document.OneTrueForm.submit();
459     return false;
460 }
461
462 function copyelement(from, to) {
463 //    alert ( from + ' ' + to );
464     
465     if ( from == undefined ) {
466         to.value = '';
467     } else { 
468         if ( from.type == 'select-one' ) {
469             to.value = from.options[from.selectedIndex].value;
470         } else if ( from.type == 'checkbox' ) {
471             if ( from.checked ) {
472                 to.value = from.value;
473             } else {
474                 to.value = '';
475             }
476         } else {
477             if ( from.value == undefined ) {
478                 to.value = '';
479             } else {
480                 to.value = from.value;
481             }
482         }
483 //      alert(from.name + " (" + from.type + "): " + to.name + " => " + to.value);
484     }
485 }
486
487 </script>
488 </FORM>
489 <%= $OUT .= $body_footer %>
490 </BODY>
491 </HTML>