/*
06/07/2009 20.22
$js = "window.addEvent('domready', function(){checkCaptcha('".$form."','".$buttonid."','".$pswid."','".$msgid."'); })";
  function checkCaptcha(form) {
*/
//window.addEvent("domready",function(){
function checkCaptcha(form, buttonid,pswid,msgid ) {
	$(buttonid).setProperty('disabled', 'true');
	var box = $(msgid);
	var fx = box.effects({duration: 1000, transition: Fx.Transitions.Quart.easeOut});
            
            $(pswid).addEvent("change",function(){
            	$(buttonid).setProperty('disabled', 'true');
            if ( $(pswid).value.length > 0 ){
              
            
                var url="index.php?option=com_"+form+"&amp;task=chkCaptcha&amp;format=raw&amp;"+pswid+"="+this.getValue()+"&amp;campo="+pswid+"&amp;fid="+buttonid;
                box.style.display="block";     
            		box.setHTML('Controllo in corso...');	 
                var a=new Ajax(url,{
                    method:"get",
                    onComplete: function(response){
                        var resp=Json.evaluate(response);
            
                        if (resp.msg==='false'){
                         $(pswid).value='';
                         $(pswid).focus();
                           $(buttonid).setProperty('disabled', 'true');
                        }else{
                        	$(buttonid).removeProperty('disabled'); 
                        }
            
                        fx.start({	
		                    	}).chain(function() {
		                    		box.setHTML(resp.html);
		                    		this.start.delay(1500, this, {'opacity': 0});
		                    	}).chain(function() {
		                    		box.style.display="none";
		                    		this.start.delay(1501, this, {'opacity': 1});
		                    	});	
              
                    }
                }).request();
              } //la if  
            });
        }
        
//  );
