/*
22/09/2009 8.03
$js = "window.addEvent('domready', function(){checkCaptcha('".$form."','".$buttonid."','".$pswid."','".$msgid."'); })";
  function checkCaptcha(form) {
*/
//window.addEvent("domready",function(){
function checkCaptcha(form, buttonid, pswid, msgid, msg ) {
	$(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(msg);
        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(1000, this, {'opacity': 0});
                    	}).chain(function() {
                    		box.style.display="none";
                    		this.start.delay(1000, this, {'opacity': 1});
                    	});

            }
        }).request();
      }
    });
};