new function() {
    $.fn.validate = {
        init: function(o) {
          if(o.name == 'username') { this.username(o) };
          if(o.name == 'password') { this.password(o) };
          if(o.name == 'email') { this.email(o) };
          if(o.name == 'captcha') { this.captcha(o) };
          if(o.name == 'passresend') { this.passresend(o) };
          if(o.name == 'actkey') { this.actkey(o) };
        },
        username: function(o) {
          var user = /[(\*\(\)\[\]\+\.\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/;
          
          if (!o.value.match(user)) {
             doValidate(o);
            } else {
             doError(o,'Keine Sonderzeichen erlaubt');
            };
        },
        password: function(o) {
          var pass = /[(\*\(\)\[\]\+\.\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/;
           if (!o.value.match(pass)) {
             doValidate(o);
            } else {
             doError(o,'Keine Sonderzeichen erlaubt');
            };
        },
        email: function(o) {
          var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
           if (o.value.match(email)) {
              doValidate(o);
            } else {
              doError(o,'Keine g&uuml;ltige E-Mail');
            };
        },
        captcha: function(o) {
          var captcha = /[(\*\(\)\[\]\+\.\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/;
           if (!o.value.match(captcha)) {
              doValidate(o);
            } else {
              doError(o,'Captcha falsch');
            };
        },
        passresend: function(o) {
        	var passresend = /.*/;
            if (o.value.match(passresend)) {
               doValidate(o);
              } else {
               doError(o,'Falsche Eingabe');
              };
          },
          actkey: function(o) {
          	var actkey = /.*/;
              if (o.value.match(actkey)) {
                 doValidate(o);
                } else {
                 doError(o,'Falsche Eingabe');
                };
            }
     };

     function doSuccess(o) {
              $('#' + o.id + '_img').html('<img src="../reg_new/images/accept.gif" border="0" style="float:left;" />');
              $('#' + o.id + '_li').removeClass("error");
              $('#' + o.id + '_msg').html("");
              $('#' + o.id + '_li').addClass("success");
     }

     function doError(o,m) {
              $('#' + o.id + '_img').html('<img src="../reg_new/images/exclamation.gif" border="0" style="float:left;" />');
              $('#' + o.id + '_li').addClass("error");
              $('#' + o.id + '_msg').html(m);
              $('#' + o.id + '_li').removeClass("success");
     }
     //private helper, validates each type after check
     function doValidate(o) {
        	$('#' + o.id + '_img').html('<img src="../reg_new/images/loading.gif" border="0" style="float:left;" />');
                $.post('http://www.funpic.de/reg_new/ajax.php?sid='+sid, { id: o.id, value: o.value }, function(json) {
                        var evalu = "var args = " + json + ";";
                        eval(evalu); 
			if (args.success == true)
                  	{
                  	  doSuccess(args);
                  	}
                  	else
                  	{
			  document.images['cpic'].src = 'captcha.php?id='+sid+'&r='+Math.round(new Date().getTime() / 1000);
                          doError(args,args.msg);
			  o.value='';
                  	}
                  });
    };

};
$.fn.match = function(m) {
	$('#' + this.eq(0).id + '_img').html('<img src="../reg_new/images/loading.gif" border="0" style="float:left;" />');
	if ($(this).eq(0).val() == $(m.match).val() && $(m.match).val() != '') {
          $('#' + this.eq(0).id + '_img').html('<img src="../reg_new/images/accept.gif" border="0" style="float:left;" />');
          $(m.error).removeClass("error");
          $(m.error).addClass("success");
          $('#' + this.eq(0).id + '_msg').html("");
        } else {
          $('#' + this.eq(0).id + '_img').html('<img src="../reg_new/images/exclamation.gif" border="0" style="float:left;" />');
          $(m.error).addClass("error");
          $(m.error).removeClass("success");
          $('#' + this.eq(0).id + '_msg').html("Die Passw&ouml;rter stimmen nicht &uuml;berein");
        };
};
$(document).ready(function()
{
  $("input.validated").blur(function() {
          $(this).validate.init(this);
  });

  $("#confirmpass").blur(function() {
          $(this).match({match: '#password', error: '#confirmpass_li'});
  });

  // This Used To Be HOVER, But I.E. Didnt Like It
  //$(".form li").hover(function(){$(this).addClass("selected");},function(){$(this).removeClass("selected");});
  //$(".form li").mouseover(function() {
  //        $(this).addClass("selected");
  //});
  //$(".form li").mouseout(function() {
  //        $(this).removeClass("selected");
  //});
});

