<?php
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.0.9
  @date  19/06/10, 21:03
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/
?>
<script type="text/javascript"><!--
$().ready(function() {
  // Validation de formulaire avec jquery.validate
  $("#create_account").validate({
    rules: {
      gender: "required",
      firstname: {
        required: true,
        minlength: <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>
      },
      lastname: {
        required: true,
        minlength: <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>
      },
      dob: "required",
      email_address: {
        required: true,
        email: true,
        minlength: <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>
      },
      street_address: {
        required: true,
        minlength: <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>
      },
      postcode: {
        required: true,
        minlength: <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>
      },
      city: {
        required: true,
        minlength: <?php echo ENTRY_CITY_MIN_LENGTH; ?>
      },
      country: "required",
      telephone: {
        required: true,
        minlength: <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>,
        number: true
      },
      password: {
        required: true,
        minlength: <?php echo ENTRY_PASSWORD_MIN_LENGTH; ?>
      },
      confirmation: {
        required: true,
        equalTo: "#password"
      },
    },
    messages: {
      gender: "<?php echo ENTRY_GENDER_ERROR; ?>",
      firstname: "<?php echo ENTRY_FIRST_NAME_ERROR ?>",
      lastname: "<?php echo ENTRY_LAST_NAME_ERROR ?>",
      dob: "<?php echo ENTRY_DATE_OF_BIRTH_ERROR; ?>",
      email_address: {
        required: "<?php echo ENTRY_EMAIL_ADDRESS_ERROR; ?>",
        email: "<?php echo ENTRY_EMAIL_ADDRESS_CHECK_ERROR; ?>",
        minlength: "<?php echo ENTRY_EMAIL_ADDRESS_ERROR; ?>"
      },
      street_address: "<?php echo ENTRY_STREET_ADDRESS_ERROR; ?>",
      postcode: "<?php echo ENTRY_POST_CODE_ERROR; ?>",
      city: "<?php echo ENTRY_CITY_ERROR; ?>",
      country: "<?php echo ENTRY_COUNTRY_ERROR; ?>",
      telephone: "<?php echo ENTRY_TELEPHONE_NUMBER_ERROR; ?>",
      password: "<?php echo ENTRY_PASSWORD_ERROR; ?>",
      confirmation: "<?php echo ENTRY_PASSWORD_ERROR_NOT_MATCHING; ?>"
    },
    errorElement: "span",
    errorClass: "messageStackError",
    errorPlacement: function(error, element) {
      error.appendTo( element.parent());
    },
    onkeyup: true
  });
  // Listes liées
  $("#state").parent().hide();
  $("#country").change( function () {
      $.get("./ajax_exe.php", { action:"create_account", country: this.value },
      function success(data) {
        $("#state").replaceWith(data);
        if ($(data).val() == null) {
          $("#state").parent().hide();
        } else {
          $("#state").parent().show();
        }
      });
  });
});

// BOF Customers extra fields
 <?php
global $page;
	$languages_id=$page->the_var('languages_id');
   $extra_fields_query = tep_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type, ce.fields_size from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status=1 and ce.fields_required_status=1 and cei.fields_id=ce.fields_id and cei.languages_id =" . $languages_id);
   while($extra_fields = tep_db_fetch_array($extra_fields_query)){
   $string_error=sprintf(ENTRY_EXTRA_FIELDS_ERROR,$extra_fields['fields_name'],$extra_fields['fields_size']);?>
    check_input("<?php echo 'fields_' . $extra_fields['fields_id']?>", <?php echo $extra_fields['fields_id']-1;?>, "<?php echo $string_error; ?>");
 <?php } ?>
// EOF Customers extra fields

//--></script>
