function hform_writeError(msg) { if (document.getElementById("hformErrors")==null) { body=document.getElementsByTagName("body")[0]; parentElement=document.createElement('fieldset'); legendElement=document.createElement('legend'); legendText=document.createTextNode('Form Configuration problems - HForm.com'); legendElement.appendChild(legendText); parentElement.appendChild(legendElement); errorElement=document.createElement('p'); errorElement.id="hformErrors"; errorElement.style.color="red"; parentElement.appendChild(errorElement); body.insertBefore(parentElement,body.firstChild); } else errorElement=document.getElementById("hformErrors"); errorElement.innerHTML=errorElement.innerHTML+msg+"
"; errorElement.style.display='inline'; } var baseurl; baseurl="http://www.hform.com"; var hform_prevOnSubmit=null; function hform_getRequest() { var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } return xmlhttp; } function hform_hosted() { xmlhttpNewCode=hform_getRequest(); xmlhttpNewCode.onreadystatechange = hform_updateRefreshedCode; try { xmlhttpNewCode.open("GET", baseurl+"/captcha/newcode.cgi?10334765",false); xmlhttpNewCode.send(null); } catch (e) { return false; } return true; } var isHosted=hform_hosted(); function hform_showMessage(msg) { msgElem=document.getElementById("hform_cc_message"); if (msgElem!=null) { msgTextElem = document.createElement("span"); msgTextElem.id="hform_cc_message"; msgTextElem.innerHTML=msg; msgElem.parentNode.replaceChild(msgTextElem,msgElem); } } function hform_checkCode(event) { if (hform_prevOnSubmit!=null) { document.getElementById("hform_ccode").form.onsubmit=hform_prevOnSubmit; hform_res=document.getElementById("hform_ccode").form.onsubmit(); document.getElementById("hform_ccode").form.onsubmit=hform_checkCode; if (hform_res!=true) return hform_res; } hform_ccode_elem=document.getElementById("hform_ccode"); hform_cc_message_elem=document.getElementById("hform_cc_message"); if (hform_ccode_elem.value=='') { hform_cc_message_elem.innerHTML="* please enter code from picture"; hform_ccode_elem.style.borderColor="red"; return false; } else { xmlhttp=hform_getRequest(); xmlhttp.onreadystatechange = hform_checkCodeStateChanged; xmlhttp.open("GET", baseurl+"/captcha/check.cgi?ckey="+document.getElementById("hform_ckey").value+"&code="+hform_ccode_elem.value,true); // Execute the request try { xmlhttp.send(null); } catch (e) { hform_showMessage("* error checking code, please try again in 1-2 minutes"); hform_ccode_elem.style.borderColor="red"; return false; } } return false; } function hform_checkCodeStateChanged() { hform_ccode_elem=document.getElementById("hform_ccode"); hform_cc_message_elem=document.getElementById("hform_cc_message"); switch (xmlhttp.readyState) { case 1: case 2: case 3: hform_showMessage("please wait..."); break; case 4: if (xmlhttp.responseText == "OK") { hform_showMessage(""); document.getElementById("hform_ccode").form.submit(); return true; } else { hform_showMessage("* wrong code, please enter the correct code"); return false; } break; } } function hform_installCaptchaChecker() { if (isHosted) { if (document.getElementById("hform_ccode")!=null) { if (document.getElementById("hform_ccode").form!=null) { if (document.getElementById("hform_ccode").form.onsubmit!=null) hform_prevOnSubmit=document.getElementById("hform_ccode").form.onsubmit; else if (document.getElementById("hform_ccode").form.onSubmit!=null) { hform_prevOnSubmit=document.getElementById("hform_ccode").form.onSubmit; document.getElementById("hform_ccode").form.onSubmit=null; } document.getElementById("hform_ccode").form.onsubmit=hform_checkCode; } else { hform_WriteError("Error in CAPTCHA installation: code field is out of form tag"); } } else { hform_WriteError("Error in CAPTCHA installation: code field is not found"); } } } function hform_refreshCode() { xmlhttpNewCode=hform_getRequest(); xmlhttpNewCode.onreadystatechange = hform_updateRefreshedCode; xmlhttpNewCode.open("GET", baseurl+"/captcha/newcode.cgi?10334765",true); // Execute the request try { xmlhttpNewCode.send(null); } catch (e) { hform_showMessage("* error generating new code, please try again in 1-2 minutes"); return false; } } function hform_updateRefreshedCode() { switch (xmlhttpNewCode.readyState) { case 1: case 2: case 3: hform_showMessage("please wait..."); break; case 4: if (xmlhttpNewCode.responseText != "ERROR") { hform_showMessage(""); hform_newEncodedCode=xmlhttpNewCode.responseText; if (document.getElementById("hform_ckey")!=null) document.getElementById("hform_ckey").value="10334765-"+hform_newEncodedCode; if (document.getElementById("hform_cc_image")!=null) { document.getElementById("hform_cc_image").src=baseurl+'/captcha/image.cgi?ckey='+document.getElementById("hform_ckey").value; } return true; } else { hform_showMessage("* error refreshing new code, please try again in 1-2 minutres"); return false; } break; } } function hform_showCodeImage() { document.write('Please enter the following code:\n'); document.write('
\n'); document.write('\n'); if (isHosted) { document.write('
Can\'t read the code? Try another one\n'); } if (document.getElementById("hform_cc_image").src != baseurl+'/captcha/image.cgi?ckey='+document.getElementById("hform_ckey").value) document.getElementById("hform_cc_image").src=baseurl+'/captcha/image.cgi?ckey='+document.getElementById("hform_ckey").value; document.write('
\n'); document.write('\n'); document.write('
\n'); } function hform_captcha() { hform_showCodeImage(); hform_installCaptchaChecker(); }