jQuery.QapTcha={build:function(options)
{var defaults={txtLock:'Slide the bar to unlock the form',txtUnlock:'Form unlocked'};if(this.length>0)
return jQuery(this).each(function(i){var
opts=$.extend(defaults,options),$this=$(this),form=$('form').has($this),Clr=jQuery('<div>',{'class':'clr'}),bgSlider=jQuery('<div>',{id:'bgSlider'}),Slider=jQuery('<div>',{id:'Slider'}),Icons=jQuery('<div>',{id:'Icons'}),TxtStatus=jQuery('<div>',{id:'TxtStatus',text:opts.txtLock}),inputQapTcha=jQuery('<input>',{id:'qaptchaPass',name:'qaptcha',value:generatePass(),type:'hidden'});form.find('input[type=\'submit\']').attr('disabled','disabled');bgSlider.appendTo($this);Icons.insertAfter(bgSlider);Clr.insertAfter(Icons);TxtStatus.insertAfter(Clr);inputQapTcha.appendTo($this);Slider.appendTo(bgSlider);$this.show();Slider.draggable({containment:bgSlider,axis:'x',stop:function(event,ui){if(ui.position.left>80)
{$.post(ajax_url+"/qaptcha.php",{action:$('#qaptchaPass').val()},function(data){if(!data.error)
{Slider.draggable('disable').css('cursor','default');TxtStatus.css({color:'#307F1F'}).text(opts.txtUnlock);Icons.css('background-position','-16px 0');form.find('input[type=\'submit\']').removeAttr('disabled');}},'json');}}});function generatePass(){var chars='azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN';var pass='';for(i=0;i<10;i++){var wpos=Math.round(Math.random()*chars.length);pass+=chars.substring(wpos,wpos+1);}
return pass;}});}};jQuery.fn.QapTcha=jQuery.QapTcha.build;
