var captcha_form; for(i=0;i-1 || codfld)){ //alert(nm+" "+nm.indexOf("*")); if(arr[i].type=="select-one" || arr[i].type=="select-multiple"){ try{ chk=arr[i].options[arr[i].selectedIndex].value; }catch(err){ chk=arr[i].value; } }else if(arr[i].type=="radio"){ chk=1; }else if(arr[i].type=="checkbox"){ chk=arr[i].checked; }else if(nm.indexOf("_*_confirm")>0){ fld=nm.replace("_*_confirm","_*"); if(fld=document.getElementById(fld)){ if(arr[i].value==fld.value && arr[i].value) { chk=1; }else{ arr[i].value=""; chk=0; } } }else{ chk=arr[i].value; } if(nm.indexOf("email")>-1 || nm.indexOf("Email")>-1){ if(isemailvalid(arr[i].value)){ chk=1; }else{ chk=0; } } }else{ if((nm.indexOf("*")>-1)){ if(arr[i].type=="textarea"){ fld=nm.replace("*","*_iframe"); if(fld=document.getElementById(fld)){ ctrl=fld; if(arr[i].value) { chk=1; }else{ chk=0; } } } } } if(ctrl.style.border){ ctrl.style.border="#cccccc 2px solid"; } if (chk==0 || chk=='00.00.00' ){ ctrl.style.border="#ff0000 2px solid"; if(focusi==-1) focusi=i; ret=false; } } if(ret){ if(cod>-1){ ret=checkcaptcha(arr[cod].value); } if(ret==1){ return true; }else{ arr[cod].style.border="2px solid #FF0000"; arr[cod].value=""; captchablick(arr[cod]); return false; } }else{ captchablick(arr[focusi]); return false; } } var lastcaptchablickobj; function isemailvalid(mail) { return (mail.match(/^[A-Za-z0-9\.\_\-]{1,32}\@[A-Za-z0-9\.\_\-]{1,32}\.[a-zA-Z]{2,6}$/)); } function captchablick(obj,s){ if(obj!=0){ lastcaptchablickobj=obj; lastcaptchablickbg=obj.style.backgroundColor; } else obj=lastcaptchablickobj; if(!obj.disabled){ if(s==null || s<7){ if(s==1 || s==3 || s==5){ obj.style.backgroundColor="#ffff00"; }else{ obj.style.backgroundColor=lastcaptchablickbg; } if(s==null) s=1; s++; setTimeout("captchablick(0,"+s+")",50); }else{ try{ obj.focus(); } catch(err){} } } } function checkcaptcha(val) { var http_request = false; url="/captcha.php"; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } http_request.open('POST', url, false); http_request.send(val); if(http_request.responseText==-1){ alert('Cookie must be enabled!'); return 0; } if(http_request.responseText==0){ document.getElementById("captchaimage").src="/captcha.php?captchadraw&rand="+Math.random(); } return http_request.responseText; }