// JavaScript Document
        var url = 'captcha.php?code=';
        var captchaOK = 2;  // 2 - not yet checked, 1 - correct, 0 - failed
        
        function getHTTPObject()
        {
        try {
        req = new XMLHttpRequest();
          } catch (err1)
          {
          try {
          req = new ActiveXObject("Msxml12.XMLHTTP");
          } catch (err2)
          {
          try {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (err3)
            {
		req = false;
            }
          }
	}
        return req;
	}
        
        var http = getHTTPObject(); // We create the HTTP Object        
        
        function handleHttpResponse() {
        if (http.readyState == 4) {
            captchaOK = http.responseText;
			//alert(captchaOK);
            if(captchaOK != 1) {
              //alert('The entered code was not correct. Please try again');
			  document.getElementById('sec_cap').innerHTML="<font style='background-color:#FF0000; color:#FFFFFF; font-weight:bold;'>&nbsp;Invalid code&nbsp;</font>";
				  /*if(document.getElementById('res_sec').value!="125"){				 
				  document.getElementById('txtCaptcha').value="";				  
				  }*/				  
				return false;				  
              }
			  //alert("Hooray");
			  document.getElementById('res_sec').value="125";			 
			  document.getElementById('sec_cap').innerHTML="";
              //document.myform.submit();
			  return true;
           }
        }

        function checkcode(thecode) {
		//alert (thecode);
        http.open("GET", url + escape(thecode), true);
        http.onreadystatechange = handleHttpResponse;
        http.send(null);
        }
        
        function checkform(code_val) {
		  if(code_val!=''){
          checkcode(code_val);
		  //document.getElementById('txtCaptcha').value="";	
		  }
		 /* else{
		  document.getElementById('sec_cap').innerHTML="<font style='background-color:#FF0000; color:#FFFFFF; font-weight:bold;'>&nbsp;A value is required&nbsp;</font>";
		  }	*/  	  	  
        }
