var http = getHTTPObject();

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;
}
        
        
function handleHttpResponse() 
{
		code	 = document.getElementById("code").value;
		
		if (http.readyState == 4) {
    	captchaOK = http.responseText;
    	
    	if(captchaOK != 1) {
      	document.getElementById("codeError").style.display = "inline";
				document.getElementById("code").select();
				document.getElementById("code").focus();
		 		return false;      	
		 		return false;      	
      }
      
       document.signupForm.submit();
   }
}


function checkform() 
{
  code	 = document.getElementById("code").value;
  
  if (code == ""){
	  hideAllErrors();
		document.getElementById("codeError").style.display = "inline";
		document.getElementById("code").select();
		document.getElementById("code").focus();
		return false;
	}     			
  					
  checkcode(document.signupForm.code.value); // form "name" wichtig!
  return false;
}     		



function hideAllErrors() 
{
	document.getElementById("codeError").style.display = "none"
}

function checkcode(thecode){
	http.open("GET","http://fcs.sebsta.at/classes/captcha/captcheck.php?code=" + escape(thecode), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null); 
}  
