// JavaScript Document

function check_captcha(captcha){
	 
	// get correct XMLHttp request 
	var http = GetXmlHttpObject();
	if (http == null){
		alert ("Browser does not support HTTP Request");
		return;
	} 
	
	// set up our vars
	var url = window.location.protocol+"//"+window.location.host+"/form_mailer.php";
	var params = "captcha_confirm="+captcha.value;
	
	// open the connection
	http.open("POST", url, true);
	
	// send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	// call a function when the state changes.
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) {
			if(http.responseText == 'captcha_denied'){
				document.getElementById('captcha_msg').innerHTML='Invalid, please try again!';
			}else{
				document.myForm.submit();
			}		
		}
	}
	
	// send actual params via POST
	http.send(params);
	
}

function GetXmlHttpObject() { 
	
	// create new var
	var objXMLHttp=null;
	
	// if u have a dope browser this will work
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest();
	}
	
	// if your on the shittiest browser on earth u will need this 
	else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	// send our correct request back
	return objXMLHttp;
}