var xmlhttp = false;

// check if we are using IE
try {
    // if the javascript version is greater than 5
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    // if not, then user older active x object.
    try {
        // if we are using IE
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(E) {
        // Else we must be using a non IE browser
        xmlhttp = false;
    }
}
// if we are using a non IE browser, create a Javascript instance of the object
if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
}


function validate(serverPage, objID) {
    var obj = document.getElementById(objID);
    var hncaptcha = document.captcha1.hncaptcha.value;
    var public_key = document.captcha1.public_key.value;
    var private_key = document.captcha1.private_key.value;

    var params = 'hncaptcha='+escape(hncaptcha)+'&public_key='+escape(public_key)+'&private_key='+escape(private_key);

    xmlhttp.open("POST", serverPage, true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        	if(xmlhttp.responseText == '1') {
        		document.vvc.submit();
        	} else {
        		obj.innerHTML = xmlhttp.responseText;
        	}
	        //alert(obj.innerHTML);
    	}
    }
    xmlhttp.send(params);

	return false;
}
