<?php
/**
@licence GPL 2005-2009  The osCSS developers - osCSS Open Source E-commerce
  @package oscss-2 <www http://www.oscss.org>
  @version Rc-3
  @date  03/04/10, 09:55
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/

if($action=='new_member' || $action=='edit_member') :
  tep_include_file (DIR_WS_TEMPLATE."jquery.validate.css",true);
  tep_include_file ("includes/javascript/jquery.validate.min.js",true);
?>
<script type="text/javascript">
$(function(){
  // validate signup form on keyup and submit
  $("#newmember").validate({
    invalidHandler: function(e, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'You missed 1 field. It has been highlighted below'
          : 'You missed ' + errors + ' fields.  They have been highlighted below';
        $("div.error span").html(message);
        $("div.error").show();
      }
      else {$("div.error").hide();}
    },
    onkeyup: false,
    rules: {
      admin_firstname: {required: true, minlength: 3},
      admin_lastname: {required: true, minlength: 3},
      admin_email_address: {required: true, email: true},
      admin_groups_id:{required: true, minlength: 1}
    },
    messages: {
      admin_firstname: {
        required: "<?php echo JS_ALERT_FIRSTNAME ?>",
        minlength: "Your username must consist of at least 3 characters"
      },
      admin_lastname: {
        required: "<?php echo JS_ALERT_LASTNAME ?>",
        minlength: "Your username must consist of at least 3 characters"
      },
      admin_email_address: "<?php echo JS_ALERT_EMAIL ?>",
      admin_groups_id: "Please enter groupe id"
    }
  });
});
</script>
<?php  elseif($action=='new_group' || $action=='edit_group') :
  tep_include_file (DIR_WS_TEMPLATE."jquery.validate.css",true);
  tep_include_file ("includes/javascript/jquery.validate.min.js",true);
?>
<script type="text/javascript">
$(function(){
  // validate signup form on keyup and submit
  $("#new_group").validate({
    invalidHandler: function(e, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'You missed 1 field. It has been highlighted below'
          : 'You missed ' + errors + ' fields.  They have been highlighted below';
        $("div.error span").html(message);
        $("div.error").show();
      }
      else {$("div.error").hide();}
    },
    onkeyup: false,
    rules: {
      admin_groups_name: {required: true, minlength: 6},
    },
    messages: {
      admin_groups_name: {
        required: "Please enter a group name",
        minlength: "Your username must consist of at least 5 characters"
      }
    }
  });
});
</script>
<?php endif; ?>