<?php 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: checkout_register_form.php,v 1.9 2005/01/27 19:34:01 soeren_nb Exp $
* @package mambo-phpShop
* @subpackage HTML
* @copyright (C) 2004 Miro
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* mambo-phpShop is Free Software.
* mambo-phpShop comes with absolute no warranty.
*
* www.mambo-phpshop.net
*/
mm_showMyFileName( __FILE__ );
?>

  <script language="javascript" type="text/javascript">
		function submitregistration() {
			var form = document.mosform;
			var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
      
			// do field validation
          <?php 
          if (!$my->id) { ?>
          
			if (form.username.value == "") {
				alert( "<?php echo _REGWARN_UNAME; ?>" );
			}
            else if (r.exec(form.username.value) || form.username.value.length < 3) {
                      alert( "<?php printf(_VALID_AZ09, _PROMPT_UNAME, 2);   ?>" );
                  } 
            else if (form.email.value == "") {
                      alert( "<?php echo _REGWARN_MAIL;    ?>" );
            }          
            else if (form.password.value.length < 6) {
                alert( "<?php echo _REGWARN_PASS;?>" );
            } else if (form.password2.value == "") {
                alert( "<?php echo _REGWARN_VPASS1;?>" );
            } else if ((form.password.value != "") && (form.password.value != form.password2.value)){
                alert( "<?php echo _REGWARN_VPASS2;?>" );
            } else if (r.exec(form.password.value)) {
                alert( "<?php printf( _VALID_AZ09, _REGISTER_PASS, 6 );?>" );
            }
          <?php 
        }
        if (MUST_AGREE_TO_TOS == '1') { 
          if (!$my->id) echo "else"; ?>
        
            if (!form.agreed.checked) {
                alert( "<?php echo $PHPSHOP_LANG->_PHPSHOP_AGREE_TO_TOS ?>" );
            }
        <?php 
        }
        if (MUST_AGREE_TO_TOS == '1' || !$my->id) echo "else "; ?>
           {
				form.submit();
			}
		}
	</script>
<?php
  $missing_style = "style=\"color: Red; font-weight: Bold;\"";
  
  if (!empty($_REQUEST['missing']))
      echo "<script> alert('"._CONTACT_FORM_NC."'); </script>\n";
  else
    $_REQUEST['missing'] = '';
  ?>

<table cellpadding="5" cellspacing="0" border="0" width="98%" class="contentpane">

  <form action="<? echo SECUREURL ?>index.php" method="post" name="mosform">

    <tr>
      <td colspan="2" width="100%" class="componentheading"><?php echo _REGISTER_TITLE . " (* = " . _CMN_REQUIRED . ")";
        ?></td>
    </tr>
<?php if (empty($my->id)) { ?>
    <tr>

      <td nowrap="nowrap" align="right" ><?php echo _REGISTER_UNAME    ?>*</td>
      <td><input type="text" name="username" size="40" value="<?php echo empty($_REQUEST['username']) ? '' : $_REQUEST['username']; ?>" class="inputbox" /></td>
    </tr>
<?php } ?>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_TITLE ?>:</td>
            <td width="70%" > <?php $ps_html->list_user_title(empty($_REQUEST['title']) ? '' : $_REQUEST['title']);
        ?>
            </td>
          </tr>
        <tr>   
            <td <?php if (stristr($_REQUEST['missing'],'first_name')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_FIRST_NAME ?>*:</td>
            <td width="70%" > 
              <input type="text" name="first_name" size="40" value="<?php echo empty($_REQUEST['first_name']) ? '' : $_REQUEST['first_name']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'last_name')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_LAST_NAME ?>*:</td>
            <td width="70%" > 
              <input type="text" name="last_name" size="40" value="<?php echo empty($_REQUEST['last_name']) ? '' : $_REQUEST['last_name']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_MIDDLE_NAME ?>:</td>
            <td width="70%" > 
              <input type="text" name="middle_name" size="40" value="<?php echo empty($_REQUEST['middle_name']) ? '' : $_REQUEST['middle_name']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td colspan="2" nowrap>&nbsp;</td>
          </tr>
          <tr> 
            <td colspan="2" nowrap><b><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_BILLTO_LBL ?></b></td>
          </tr>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_COMPANY_NAME ?>:</td>
            <td width="70%" > 
              <input type="text" name="company" size="40" value="<?php echo empty($_REQUEST['company']) ? '' : $_REQUEST['company']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'address_1')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_1 ?>*:</td>
            <td width="70%" > 
              <input type="text" name="address_1" size="40" value="<?php echo empty($_REQUEST['address_1']) ? '' : $_REQUEST['address_1']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_2 ?>:</td>
            <td width="70%" > 
              <input type="text" name="address_2" size="40" value="<?php echo empty($_REQUEST['address_2']) ? '' : $_REQUEST['address_2']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'city')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_CITY ?>*:</td>
            <td width="70%" > 
              <input type="text" name="city" size="40" value="<?php echo empty($_REQUEST['city']) ? '' : $_REQUEST['city']; ?>" class="inputbox" />
            </td>
          </tr>
          <?php if (CAN_SELECT_STATES == '1') {?>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'state')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_STATE ?>:</td>
            <td width="70%" > 
              <?php $ps_html->list_states("state", empty($_REQUEST['state']) ? '' : $_REQUEST['state']) ?>
            </td>
          </tr>
          <?php } ?>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'zip')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_ZIP ?>*:</td>
            <td width="70%" > 
              <input type="text" name="zip" size="10" value="<?php echo empty($_REQUEST['zip']) ? '' : $_REQUEST['zip']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'country')) echo $missing_style ?> width="30%" nowrap="nowrap" align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_COUNTRY ?>*:</td>
            <td width="70%" ><?php $ps_html->list_country("country", empty($_REQUEST['country']) ? $vendor_country : $_REQUEST['country']) ?>
            </td>
          </tr>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" > <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_PHONE ?>:</td>
            <td width="70%" > 
              <input type="text" name="phone_1" size="40" value="<?php echo empty($_REQUEST['phone_']) ? '' : $_REQUEST['phone_1']; ?>" class="inputbox" />
            </td>
          </tr>
          <tr> 
            <td width="30%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_FAX ?>:</td>
            <td width="70%" > 
              <input type="text" name="fax" size="40" value="<?php echo empty($_REQUEST['fax']) ? '' : $_REQUEST['fax']; ?>" class="inputbox" />
            </td>
          </tr>
          <?php if (LEAVE_BANK_DATA == '1') { 
                  $selected[0] = @$_REQUEST['bank_account_type']=="Checking" ? 'selected="selected"' : '';
                  $selected[1] = @$_REQUEST['bank_account_type']=="Business Checking" ? 'selected="selected"' : '';
                  $selected[2] = @$_REQUEST['bank_account_type']=="Savings" ? 'selected="selected"' : ''; ?>
            <tr>
                <td colspan="2" nowrap><b><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_BANK_TITLE ?> </b></td></tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_HOLDER ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_account_holder" size="24" value="<?php echo empty($_REQUEST['bank_account_holder']) ? '' : $_REQUEST['bank_account_holder']; ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_NR ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_account_nr" size="24" value="<?php echo empty($_REQUEST['bank_account_nr']) ? '' : $_REQUEST['bank_account_nr']; ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_SORT_CODE ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_sort_code" size="24" value="<?php echo empty($_REQUEST['bank_sort_code']) ? '' : $_REQUEST['bank_sort_code'];?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_NAME ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_name" size="24" value="<?php echo empty($_REQUEST['bank_name']) ? '' : $_REQUEST['bank_name']; ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE ?>:</td>
                <td width="73%" >
                  <select class="inputbox" name="bank_account_type">
                    <option <?php echo $selected[0] ?> value="Checking"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_CHECKING ?></option>
                    <option <?php echo $selected[1] ?> value="Business Checking"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_BUSINESSCHECKING ?></option>
                    <option <?php echo $selected[2] ?> value="Savings"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_SAVINGS ?></option>
                  </select>
                </td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_IBAN ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_iban" size="24" value="<?php echo empty($_REQUEST['bank_iban']) ? '' : $_REQUEST['bank_iban']; ?>" /></td>
            </tr>
            <?php 
          } 
          if (!$my->id) { ?>
            <tr>
              <td nowrap="nowrap" align="right" ><?php echo _REGISTER_EMAIL ?>*</td>
              <td><input type="text" name="email" size="40" value="<?php echo empty($_REQUEST['email']) ? '' : $_REQUEST['email']; ?>" class="inputbox" /></td>
            </tr>
            <tr>
              <td nowrap="nowrap" align="right" ><?php echo _REGISTER_PASS  ?>*</td>
              <td><input class="inputbox" type="password" name="password" size="40" value="" /></td>
            </tr>
            <tr>
              <td nowrap="nowrap" align="right" ><?php echo _REGISTER_VPASS ?>*</td>
              <td><input class="inputbox" type="password" name="password2" size="40" value="" /></td>
            </tr>
            <?php
          }
          if (MUST_AGREE_TO_TOS == '1') {
            ?>
                  <tr> 
                    <td width="30%" nowrap="nowrap" align="right" ><a href="javascript:void window.open('<?php echo $mosConfig_live_site ?>/index2.php?option=com_phpshop&page=shop.tos&pop=1', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');">
                    <?php echo $PHPSHOP_LANG->_PHPSHOP_I_AGREE_TO_TOS ?></a>:</td>
                    <td width="70%" > 
                      <input type="checkbox" name="agreed" value="1" class="inputbox" />
                    </td>
                  </tr>
            <?php } 
        ?>
            <tr>
              <td colspan="2">&nbsp;</td>
            </tr>
            <tr>
            <td colspan=2>
                <input type="hidden" name="id" value="<?php echo $my->id ?>" />
                <input type="hidden" name="Itemid" value="<?php echo @$_REQUEST['Itemid'] ?>" />
                <input type="hidden" name="user_id" value="<?php echo $my->id ?>" />
                <input type="hidden" name="gid" value="<? echo $my->gid ?>" />
                <input type="hidden" name="option" value="com_phpshop" />
                <input type="hidden" name="useractivation" value="<?php echo $mosConfig_useractivation; ?>" />
                <?php if (!$my->id) { ?>
                <input type="hidden" name="task" value="saveRegistration" />
                <input type="hidden" name="page" value="shop.registration" />
                <?php 
                } else { ?>
                <input type="hidden" name="func" value="shopperupdate" />
                <input type="hidden" name="page" value="checkout.index" />
                <?php } ?>
                <input type="hidden" name="is_it_safe" value="yep" />
                <input type="button" value="<?php echo _BUTTON_SEND_REG; ?>" class="button" onclick="javascript:submitregistration();" />
                </form>
              </td>
            </tr>
        </table>
