
<script language="JavaScript" type="text/javascript">
<!--

function CalculateTotal(frm) {
    var base_box_var = <TMPL_VAR baseboxamount>
    var order_total = base_box_var
    var capacity_total = 0
    var imap_total = 0

    // Run through all the form fields
    for (var i=0; i < frm.elements.length; ++i) {

        // Get the current field
        form_field = frm.elements[i]

        // Get the field's name
        form_name = form_field.name

        // Is it a "Capacity" field?
        if (form_name == "capacity_upgrade_units") {
           item_price = <TMPL_VAR capacityamount> 

           // Get the quantity
           item_quantity = parseInt(form_field.value)

           // Update the order total
           if (item_quantity >= 0) {
               capacity_total += item_quantity * item_price
               order_total += capacity_total
           }
        }
        if (form_name == "imap") {
	        item_price = <TMPL_VAR imapamount> 

	    // Update the Order Total
	       if (form_field.checked) {
		       imap_total += item_price 
		       order_total += imap_total
	       }
	       else {
		       imap_total = "0"
	       }
		}
	}

    // Display the total rounded to two decimal places
    frm.total_capacity_upgrade_units.value = round_decimals(capacity_total, 2)
    frm.imap_total.value = round_decimals(imap_total,2)
    frm.total_per_box.value = round_decimals(order_total, 2)
    frm.base_box.value = round_decimals(base_box_var , 2)
}


function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()

    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {

        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0

        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }

    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length

    if (pad_total > 0) {

        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
        }
    return value_string
}

//-->
</script>

<center>
<P>
Step 1: E-mail Address Availability and Selection<br>
<b>Step 2: Mailbox Information and Upgrades</b><br>
Step 3: Account Holder Contact Information<br>
Step 4: Order Confirmation<br>

<form action="<TMPL_VAR CGI>" method="post" onBlur="CalculateTotal(this.form)">

 <input type="hidden" name="session" value="<TMPL_VAR ESCAPE=HTML session>">
 <input type="hidden" name="sign" value="<TMPL_VAR sign>">

  <table cellpadding="5" cellspacing="1" width="70%">
   <tr>
     <td align="center" colspan="3" class="main">
       <font class="heading">Create New Mailbox(es) for <TMPL_VAR email_domain></font>
     </td>
   </tr>
  <tr>
    <td class="accent" align="right" ><b>Mailbox Names</b></td>
     <td class="accent" colspan=2>
         <TMPL_VAR readable_box_names>
         <input type="hidden" name="box_names" value="<TMPL_VAR box_names>">
     </td>
  </tr>
  <tr>
    <td class="accent" align="right"><b>Domain Name</b></td>
    <td align="left" class="accent" colspan=2>
        <TMPL_VAR email_domain>
	<input type="hidden" name="email_domain" value="<TMPL_VAR email_domain>">
    </td>
  </tr>
   <tr>
     <td align="center" colspan="3" class="main">
       <font class="heading"><b>Mailbox Upgrades</b></font>
     </td>
   </tr>
   <tr>
     <td align="right" class="accent">
       <b>Mailbox</b>
     </td>
     <td align="left" class="accent">
       Each mailbox purchase includes <TMPL_VAR initial_capacity>MB storage
     </td>
     <td class="main">
     $<input type="text" name="base_box" size="5" value="<TMPL_VAR baseboxamount>" Readonly="readonly">
     </td>
   </tr>
   <tr>
     <td align="right" class="accent">
       <b>Storage Upgrades</b>
     </td>
     <td class="accent" nowrap>
       Add <select name=capacity_upgrade_units onChange="CalculateTotal(this.form)">
            <TMPL_VAR capacity_upgrade_list>
            </select>
       MB
       <i>(Maximum <TMPL_VAR max_capacity_upgrade>)</i>
     </td>
     <td class="main">
     $<input type="text" name="total_capacity_upgrade_units" size="5" Readonly="readonly">
     </td>

   </tr>
   <tr>
     <td align="right" class="accent">
       <b>IMAP Upgrade</b>
     </td>
     <td class="accent">
       <input type="checkbox" name="imap" onClick="CalculateTotal(this.form)" value="1" <TMPL_IF imap>CHECKED</TMPL_IF>  >
        Add IMAP Access
     </td>
      <td class="main">
      $<input type="text" name="imap_total" size="5" Readonly="readonly">
     </td>
   </tr>
   <tr>
     <td class="accent">
     </td>
     <td class="main">
       <table cellspacing="0">
         <tr><td align=right class="main"><b>Total Price Per Mailbox</b></td></tr>
         <tr><td class="main"><font size=-1>
         The Total Price Per Mailbox represents the monthly amount you will be
billed per mailbox.  For the first month of the service, you will only be
charged a pro-rated amount for the remaining days in the month.
         </font></td></tr>
       </table>
     </td>
     <td valign="top" class="main">
     $<input type="text" name="total_per_box" value="<TMPL_VAR baseboxamount>" size="5" Readonly="readonly">
     </td>
   </tr>
   <tr>
     <td align="center" colspan="3" class="main">
       <font class="heading">Mailbox Password</font>
     </td>
   </tr>
   <tr>
     <td class="accent" colspan=3>
	 This is the password that the Mailbox User will use to login to their
mailbox. For bulk orders, all Mailboxes will be assigned this same password.
Users should be encouraged to personalize their password through the WebMail
interface upon first use.
     </td>
   </tr>
   <tr>
     <td align="right" class="accent"><b>Password</b> (4 to 20 characters)</td>
     <td class="accent" colspan=2>
       <input type="password" name="box_password" size="20" value="<TMPL_VAR box_password>">
     </td>
   </tr>
   <tr>
     <td align="right" class="accent">
       <b>Re-enter password for confirmation</b>
     </td>
     <td class="accent" colspan=2>
       <input type="password" name="box_password_confirm" size="20" value="<TMPL_VAR box_password_confirm>">
     </td>
   </tr>
   <tr>
     <td class="main" align="center" colspan="3">
       <input type="hidden" name="action" value="verify_order_data">
       <b><input type="submit" value=" &nbsp; Next &gt;&gt; &nbsp; "></b>
     </td>
   </tr>
</table>

</form>


<a href="<TMPL_VAR CGI>?action=show_lookup">Start over with a new search...</a>

</center>


