

$(function(){$('#id_password1').pstrength();});$.validator.setDefaults({submitHandler:function(form){form.submit();}});$.metadata.setType("attr","validate");$("#id_gender_0").attr({validate:'required:true'});$("#id_terms").attr({validate:'required:true'});$().ready(function(){$("#id_form_register").validate({rules:{email:{required:true,email:true,remote:"/account/signup/check_email/"},password1:{required:true,minlength:6},password2:{required:true,minlength:6,equalTo:"#id_password1"},full_name:{required:true,minlength:2},agree:"required"},messages:{email:{required:"<div>Please enter your e-mail.</div>",email:"<div>Please fill in a valid e-mail address.</div>",remote:$.format("{0} has been registered already")},agree:"<div>You must accept the priviacy policies.</div>",password1:{required:"<div>Please enter your password.</div>",minlength:"<div>6 characters or more</div>"},password2:{required:"<div>Please confirm your password</div>",minlength:"<div>6 characters or more</div>",equalTo:"<div>Please check your password</div>"},full_name:{required:"<div>Please enter a nick name</div>",minlength:"<div>3 characters or more</div>"}}});$('#id_country').blur(function(){if($(this).val()!='0'){$('#country').css('display','none');}});$('form').submit(function(){if($('#id_country').val()=='0'){$('#country').css('display','block');return false;}});});$('#id_email').blur(function(){var msg=$('#id_email').val();msg=msg.split('@');msg=msg[0];$('#id_full_name').val(msg);});(function($){$.extend($.fn,{pstrength:function(options){var options=$.extend({verdects:["Weak","Medium","Strong"],bgcolors:["#c06","#f60","#3c0"],scores:[10,15,30,40],minchar:6},options);return this.each(function(){var infoarea=$(this).attr('id');$(this).after('<div class="pstrength-info" id="'+infoarea+'_text"></div>');$(this).after('<div style="text-align: left;"><table class="pstrength-bar" style="margin: 3px 0 0 0; border: 1px #ddd solid; line-height: 16px; height: 18px; width: 180px; color: #999;"><tr><td id="'+
infoarea+'_short" style="width: 60px; text-align: center; background: #ddd; border-right: 1px #fff solid;">'+options.verdects[0]+'</td><td id="'+
infoarea+'_medium" style="width: 60px; text-align: center; background: #ddd; border-right: 1px #fff solid;">'+options.verdects[1]+'</td><td id="'+
infoarea+'_large" style="width: 60px; text-align: center; background: #ddd;">'+options.verdects[2]+'</td></tr></table></div>');$(this).keyup(function(){$.fn.runPassword($(this).val(),infoarea,options);});});},runPassword:function(password,infoarea,options){nPerc=$.fn.checkPassword(password,options);var ctlShort="#"+infoarea+"_short";var ctlMedium="#"+infoarea+"_medium";var ctlLarge="#"+infoarea+"_large";var ctlText="#"+infoarea+"_text";if(nPerc<0&&nPerc>-199){$(ctlShort).css({background:"#ddd",color:"#999"});$(ctlMedium).css({background:"#ddd",color:"#999"});$(ctlLarge).css({background:"#ddd",color:"#999"});}
else if(nPerc<=options.scores[0])
{$(ctlShort).css({background:"#c06",color:"#fff"});$(ctlMedium).css({background:"#ddd",color:"#999"});$(ctlLarge).css({background:"#ddd",color:"#999"});}
else if(nPerc>options.scores[0]&&nPerc<=options.scores[1])
{$(ctlMedium).css({background:"#f60",color:"#fff"});$(ctlShort).css({background:"#ddd",color:"#999"});$(ctlLarge).css({background:"#ddd",color:"#999"});}
else if(nPerc>options.scores[1]&&nPerc<=options.scores[2])
{$(ctlLarge).css({background:"#3c0",color:"#fff"});$(ctlShort).css({background:"#ddd",color:"#999"});$(ctlMedium).css({background:"#ddd",color:"#999"});}
else
{$(ctlLarge).css({background:"#3c0",color:"#fff"});$(ctlShort).css({background:"#ddd",color:"#999"});$(ctlMedium).css({background:"#ddd",color:"#999"});}},checkPassword:function(password,options)
{var intScore=0;var strVerdict=options.verdects[0];if(password.length<options.minchar)
{intScore=(intScore-100)}
else if(password.length>=options.minchar&&password.length<=(options.minchar+2))
{intScore=(intScore+6)}
else if(password.length>=(options.minchar+3)&&password.length<=(options.minchar+4))
{intScore=(intScore+12)}
else if(password.length>=(options.minchar+5))
{intScore=(intScore+18)}
if(password.match(/[a-z]/))
{intScore=(intScore+1)}
if(password.match(/[A-Z]/))
{intScore=(intScore+1)}
if(password.match(/\d+/))
{intScore=(intScore+1)}
if(password.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
{intScore=(intScore+1)}
if(password.match(/([a-zA-Z])/)&&password.match(/([0-9])/))
{intScore=(intScore+3)}
if(password.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
{intScore=(intScore+3)}
return intScore;}});})(jQuery);
