new function() {
    jQuery.fn.validate = {
        init: function(o) {
          if(o.id == 'billing-name') { this.username(o, true) };
          if(o.id == 'billing-email') { this.email(o, true) };
		  if(o.id == 'billing-telefon') { this.phone(o, true) };
          if(o.id == 'billing-strasse') { this.street(o, true) };
          if(o.id == 'billing-plz') { this.plz(o, true) };
          if(o.id == 'billing-ort') { this.street(o, true) };
		  if(o.id == 'delivery-name') { this.username(o, false) };
          if(o.id == 'delivery-strasse') { this.street(o, false) };
          if(o.id == 'delivery-plz') { this.plz(o, false) };
          if(o.id == 'delivery-ort') { this.street(o, false) };
		  if(o.id == 'vouchername') { this.voucher(o, false) };
          if(o.id == 'vouchernumber') { this.voucher(o, false) };
        },
        username: function(o, req) {
          var user = /.{2,20} .*/;
           if (!req && o.value == '' || o.value.match(user)) {
             doSuccess(o);
            } else {
             doError(o,'Please insert your full name.');
            };
        },
        street: function(o, req) {
          var street = /\S{3,50}/;
           if (!req && o.value == '' || o.value.match(street)) {
             doSuccess(o);
            } else {
             doError(o,'Please insert your address.');
            };
        },
        plz: function(o, req) {
          var plz = /^ *([0-9]){4,7} *$/;
           if (!req && o.value == '' || o.value.match(plz)) {
             doSuccess(o);
            } else {
             doError(o,'This isn\'t a valid zip-code.');
            };
        },
        email: function(o, req) {
          var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+ *$/;
           if (!req && o.value == '' || o.value.match(email)) {
              doSuccess(o);
            } else {
              doError(o,'Email incorrectly formed.');
            };
        },
		phone: function(o, req) {
           var phone = /^ *([0-9 +-]){6,20} *$/;
           if (!req && o.value == '' || o.value.match(phone)) {
             doSuccess(o);
            } else {
             doError(o,'This is not a telephone number.');
            };
        },
		voucher: function(o, req) {
			if (!req && o.value == '') {
				doSuccess(o);
				return;
			}
            if (o != '' && isNaN(parseInt(o))) {
              doError(o,'Customer name or number not found.');
            } else {
              doSuccess(o);
            };
        }
     };

     function doSuccess(o) {
              jQuery('#' + o.id + '_img').html('<img src="fileadmin/templates/css/images/accept.gif" border="0" style="float:left;" />');
              jQuery('#' + o.id + '_li').removeClass("error");
              jQuery('#' + o.id + '_msg').html("");
              jQuery('#' + o.id + '_li').addClass("success");
              if (jQuery('#name_li').hasClass("success") && jQuery('#email_li').hasClass("success") && jQuery('#strasse_li').hasClass("success") && jQuery('#plz_li').hasClass("success") && jQuery('#ort_li').hasClass("success")) {
                doValidate(o);
              }
     }

     function doError(o,m) {
              jQuery('#' + o.id + '_img').html('<img src="fileadmin/templates/css/images/exclamation.gif" border="0" style="float:left;" />');
              jQuery('#' + o.id + '_li').addClass("error");
              jQuery('#' + o.id + '_msg').html(m);
              jQuery('#' + o.id + '_li').removeClass("success");
              jQuery("#submit").attr('disabled', 'disabled');
     }
     function doValidate(o) {
        jQuery("#submit").removeAttr('disabled');
    };

};