        var url = '../../captcheck.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;
            if(captchaOK != 1) {
              alert('The entered code was not correct. Please try again');
              document.propm.code.value='';
              document.propm.code.focus();
              return false;
              }
              document.propm.submit();
           }
        }

        function checkcode(thecode) {
        http.open("GET", url + escape(thecode), true);
        http.onreadystatechange = handleHttpResponse;
        http.send(null);
        }
        
        function checkform() {
        // First the normal form validation
        if(document.propm.Name.value=='') {
          alert('Please complete the "Name" field');
          document.propm.Name.focus();
          return false;
          }
		  if(document.propm.Phone.value=='') {
          alert('Please complete the "Phone" field');
          document.propm.Phone.focus();
          return false;
          }
		if(document.propm.email.value=='') {
          alert('Please complete the "E-Mail" field');
          document.propm.email.focus();
          return false;
          }
		  
		  if(document.propm.verify.value=='') {
          alert('Please complete the "Verify E-Mail" field');
          document.propm.verify.focus();
          return false;
          }
		  
		  if(document.propm.email.value!=document.propm.verify.value) {
		  alert('E-Mail Addresses Do Not Match - Please Verify');
		  document.propm.email.value='';
		  document.propm.verify.value='';
          document.propm.email.focus();
          return false;
          }
		  
		  if(document.propm.Address.value=='') {
          alert('Please complete the "Property Address" field');
          document.propm.Address.focus();
          return false;
          }		
		  if(document.propm.Rate.value=='') {
          alert('Please complete the "Rental Rate" field');
          document.propm.Rate.focus();
          return false;
          }		
        if(document.propm.code.value=='') {
          alert('Please enter the code from the image above');
          document.propm.code.value='';
          document.propm.code.focus();
          return false;
          }
          // Now the Ajax CAPTCHA validation
          checkcode(document.propm.code.value);
          return false;
        }      
