	var xmlHttp;
	var msg;
	var reg_error=false;
	var curForm;
	
	function checkForm(frm){
		/* this script will normally check for the required fields but in this case
			 this is being done by the onkeyup evets within the form.
		*/
		
		var retVal = false;
		/* check that the name field is completed*/
		var name_note = document.getElementById('name_note');
		if(frm.name.value==''){
			name_note.style.color='#850400';
			name_note.innerHTML='Please enter your name.';
			name_note.style.display='block';
			return;
		}else{
			name_note.innerHTML='';
			name_note.style.display='none';
		}
		/* check that the email field is completed*/
		retVal = checkEmail(frm.email, false);
		if(!retVal){
			return;
		}
		
		/* get the value of the captcha field and post it to the validation script. */
		var c=frm.recaptcha_challenge_field.value;
		var r=frm.recaptcha_response_field.value;
		/* check if the captcha_note field is visible and hide it */
		checkCaptcha(c,r);

	}


	function checkCaptcha(c,r)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
		var url="processes/validatecaptcha.php5";
		var parameters="recaptcha_challenge_field="+c+"&recaptcha_response_field="+r;
		
		xmlHttp.onreadystatechange = captchaStateChanged;
		xmlHttp.open('POST', url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(parameters);
	}
		
		
	function captchaStateChanged(){ 
		if(xmlHttp.readyState != 4) { document.getElementById("msg").innerHTML = '<img id="loading" src="webimage/ajax-loader.gif"/><br/>Checking CAPTCHA data...';}
		if (xmlHttp.readyState==4){
			var info = document.getElementById("captcha_note");
			var xmlDoc=xmlHttp.responseXML.documentElement;
			var res='';
			var code = xmlDoc.getElementsByTagName("code")[0].childNodes[0].nodeValue;
	
			if(code!=1){
				info.style.display='block';
			}else{
				/* submit the form*/
				document.forms['c_soon'].submit();
			}
			
		}
	}
	