(function(a){a.fn.jpassword=function(f){var h=this;var f=a.extend({},a.fn.jpassword.defaults,f);var j='<div class="jpassword"><div><p class="jpassword-meter">&nbsp;</p><p class="jpassword-info">&nbsp;</p></div></div>';return h.each(function(){if(a(h).is("input")){g(a(h))}});function g(l){var p="jpassword_"+parseInt(Math.random()*1000);var r=a(j).attr("id",p);if(f.flat==false){var s=l.offset();var q=d();var n="right";var t=s.top;var m=(s.left+l.width());r.appendTo(document.body);if((m+r.width())>(q.left+q.width)){m-=(r.width()+l.width());n="left"}if((t+r.height())>(q.top+q.height)){t-=(r.height()-(l.height()*1.5));n+="bottom"}else{n+="top"}r.css({left:m+"px",top:t+"px",display:"none"});r.addClass("jpassword-"+n)}else{r.insertAfter(l);r.css({position:"relative",display:"block"});r.addClass("jpassword-flat")}l.bind("keyup",function(u){e(l,r)});l.bind("focus",function(u){e(l,r);if(f.flat==false){k(r,"show")}if(a.isFunction(f.onShow)){f.onShow(l,r)}});l.bind("blur",function(u){if(f.flat==false){k(r,"hide")}if(a.isFunction(f.onHide)){f.onHide(l,r)}});var o=a("#"+f.generate);if(o){o.bind("click",function(u){l.val(b());e(l,r);return false})}if(a.isFunction(f.onComplete)){f.onComplete(l,r)}}function e(m,r){var q=m.val();var n=r.find(".jpassword-meter");var o=r.find(".jpassword-info");var l=i(q);var p="";if(l.lowercase<2){p=f.lang.lowercase}else{if(l.uppercase<2){p=f.lang.uppercase}else{if(l.number<2){p=f.lang.number}else{if(l.punctuation<2){p=f.lang.punctuation}else{if(l.special<2){p=f.lang.special}}}}}if(q.length<f.length&&l.level<10&&p==""){p=f.lang.length.replace(/-X-/g,f.length)}if(l.val==""){n.css("background-position","0 0");o.html(f.lang.please)}else{if(l.level<5){n.css("background-position","0 -10px");o.html(f.lang.low+" "+p)}else{if(l.level<10){n.css("background-position","0 -20px");o.html(f.lang.correct+" "+p)}else{n.css("background-position","0 -30px");o.html(f.lang.high)}}}m.val(l.val);if(a.isFunction(f.onKeyup)){f.onKeyup(m)}}function i(p){p=p.replace(/(^\s+)|(\s+$)/g,"");var m=cCap=cMin=cPct=cSpe=1;var l=p.length;for(var q=0;q<l;q++){var n=p.charCodeAt(q);if(n<128){if(n>47&&n<58){m+=1}else{if(n>64&&n<91){cCap+=1}else{if(n>96&&n<123){cMin+=1}else{cPct+=2}}}}else{cSpe+=3}}var o=(m*cCap*cMin*cPct*cSpe);o=Math.round(Math.log((o*o)));return{val:p,level:o,number:m,uppercase:cCap,lowercase:cMin,punctuation:cPct,special:cSpe}}function b(){var n="";for(c=0;c<f.length;c++){var l=Math.round(32+Math.random()*222);var m=0;if((l>47&&l<58)||(l>64&&l<91)||(l>96&&l<123)){m=1}if(f.type==1&&l<127){m=1}if(f.type==2){m=1}if(f.special&&(l==48||l==49||l==50||l==53||l==54||l==56||l==57||l==66||l==67||l==68||l==71||l==73||l==75||l==79||l==80||l==81||l==83||l==85||l==86||l==87||l==88||l==90||l==99||l==104||l==105||l==107||l==108||l==111||l==112||l==113||l==115||l==117||l==118||l==119||l==120||l==122)){m=0}if(m==1){n+=String.fromcharValueCode(l)}else{c--}}return n}function k(m,l){if(l=="show"){m.fadeIn()}else{m.fadeOut()}}function d(){var l=document.compatMode=="CSS1Compat";return{left:(window.pageXOffset||(l?document.documentElement.scrollLeft:document.body.scrollLeft)),top:(window.pageYOffset||(l?document.documentElement.scrollTop:document.body.scrollTop)),width:(window.innerWidth||(l?document.documentElement.clientWidth:document.body.clientWidth)),height:(window.innerHeight||(l?document.documentElement.clientHeight:document.body.clientHeight))}}};a.fn.jpassword.defaults={lang:{please:"A strong password...",low:"Low security.",correct:"Correct security.",high:"High security.",length:"-X- characters would be a plus.",number:"Why not numbers?",uppercase:"And caps?",lowercase:"Some tiny?",punctuation:"Punctuations?",special:"Best, special characters?"},length:8,flat:false,type:1,special:0,generate:null,onShow:function(){},onHide:function(){},onKeyup:function(){},onComplete:function(){}}})(jQuery);
