NqCaptcha.prototype._makeHttpRequest = function(cUrl)
{
	var httpRequest;
	var cResponse = "";
	if (window.XMLHttpRequest) // firefox etc 
	{
	    httpRequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // ie
	    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	cUrl = "/captcha_proxy.cfm?cProxyUrl=" + encodeURI(this.cHost + cUrl + "?rnd=" + new Date().getMilliseconds());
	
	httpRequest.open('GET', cUrl, false);
	httpRequest.send(null);

	if (httpRequest.status == 200)
	{
		cResponse = httpRequest.responseText;
	}
	
	return cResponse;
}

NqCaptcha.prototype.fillCaptchaFields = function(aoHashField, aoImage)
{
	var cHash = this.getNewCaptchaHash();
	aoHashField.value = cHash;
	aoImage.src = this.getImgSrcFromHash(cHash);
}

NqCaptcha.prototype.getImgSrcFromHash = function(acHash)
{
	return this.cHost + "/create_captcha_from_hash.cfm?cHash=" + acHash + "&rnd=" + new Date().getMilliseconds();		
}

NqCaptcha.prototype.getNewCaptchaHash = function()
{
	var cResponse = this._makeHttpRequest("create_hash_reference.cfm");
	return cResponse;
}



function NqCaptcha(acHost)
{
	this.cHost = acHost;

	if (this.cHost.substring(this.cHost.length-1,1) != '/')
		this.cHost = this.cHost + "/";
}

