var dt = new Date(); function init_ajax() { var AjaxObj = false; if(window.XMLHttpRequest){ AjaxObj = new XMLHttpRequest(); }else if(window.ActiveXObject){ AjaxObj=new ActiveXObject("Msxml2.XMLHTTP"); if (!AjaxObj){ AjaxObj=new ActiveXObject("Microsoft.XMLHTTP"); } } return(AjaxObj); } function makeRequest(url,param,formName){ rstObj = document.getElementById('result-' + formName); imgObj = document.getElementById('imgCaptcha-' + formName); xmlhttp = init_ajax(); xmlhttp.open("POST",url + dt.getTime() + dt.getSeconds()); xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;'); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { switch(xmlhttp.responseText){ case '1': rstObj.innerHTML = "

Code was verified successfully, submitting your form now...

"; var frmObj = eval('document.' + formName); if(frmObj) frmObj.submit(); break; default: rstObj.innerHTML = "

Sorry, code verification failed! please retry

"; if(xmlhttp.status == 200) imgObj.src = 'captcha/create_image.php?' + Math.random() + '&fname=' + formName; break; } } } xmlhttp.send(param); } function getParam(theForm){ var url = 'captcha/captcha.php?x='; var paramStr = '&' + theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value ) + '&fname=' + theForm.name + '&tm=' + Math.random(); makeRequest(url,paramStr,theForm.name); }