function HumanCheck(p_instanceName, p_imagePath, p_imageCount, p_useGifs)
{
	if(TypeOf(p_instanceName) != 'String' || p_instanceName.length <= 0) { throw new Error('p_instanceName must have a string value.'); }
	if(TypeOf(p_imagePath) != 'String' || p_imagePath.length <= 0) { throw new Error('p_imagePath must have a string value.'); }
	this.Name = p_instanceName;
	this.ImagePath = p_imagePath;
	this.ImageCount = TypeOf(p_imageCount) != 'Number' ? 0 : parseInt(p_imageCount); // Set to use the default count.
	this.ImageExtension = p_useGifs ? '.gif' : '.jpg';
	this._RenderElement = null;
	this._GeneratedList = new Array();
	this._ImageList = new Array(
		'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
		);
	if(this.ImagePath.substring(this.ImagePath.length - 1) != '/') { this.ImagePath += '/'; }
	this._GenerateList();
	return;
}
HumanCheck.prototype.GetType = function() { return 'HumanCheck'; }
HumanCheck.prototype.GetHashCode = function() { return this.Name; }
HumanCheck.prototype.toString = function() { return this.ToString(); }
HumanCheck.prototype.ToString = function() { return this.Name; }
HumanCheck.prototype.DefaultImageCount = function() { return 8; }
HumanCheck.prototype.DefaultMessage = function() { return 'The letters/numbers you entered do not match the image.'; }
HumanCheck.prototype.GetGeneratedList = function() { return this._GeneratedList; }
HumanCheck.prototype.GetImageList = function() { return this._ImageList; }
HumanCheck.prototype.Render = function(p_renderElement)
{
	this._RenderElement = TypeOf(p_renderElement) == 'String' ? document.getElementById(p_renderElement) : p_renderElement;
	if(this._RenderElement == null) { throw new Error('Render element does not exist or was not found.'); }
	var v_html = new StringBuilder();
	for(var i = 0; i < this._GeneratedList.length; i++)
	{
		v_html.Append('<img src="').Append(this.ImagePath).Append(this._ImageList[this._GeneratedList[i]]).Append(this.ImageExtension).Append('" alt="" title="" style="border: none;" />');
	}
	try { this._RenderElement.innerHTML = v_html.ToString(); }
	catch(e) { throw new Error('Render element is not a valid HTML element or can not have its innerHTML property set.'); }
	return;
}
HumanCheck.prototype.Regenerate = function() {
    if (this._RenderElement == null) { throw new Error('Can not regenerate list because the control has not been rendered yet.'); }
    this._GeneratedList.length = 0;
    this._GenerateList();
    this.Render(this._RenderElement);
    return;
}
HumanCheck.prototype.Check = function(p_string)
{
	if(TypeOf(p_string) != 'String') { throw new Error('p_string must be a string value.'); }
	var v_list = new StringBuilder();
	for(var i = 0; i < this.ImageCount; i++) { v_list.Append(this._ImageList[this._GeneratedList[i]]); }
	return p_string.toUpperCase() == v_list.ToString().toUpperCase();
}
HumanCheck.prototype.CheckInput = function(p_input, p_message)
{
	if(p_input == null || p_input == undefined) { throw new Error('Invalid HTML input element.'); }
	if(TypeOf(p_message) != 'String' || p_message.length <= 0) { p_message = this.DefaultMessage(); }
	if(!this.Check(p_input.value)) { alert(p_message); return false; }
	return true;
}
HumanCheck.prototype.GetSecretCode = function() {
    var v_list = new StringBuilder();
    for (var i = 0; i < this.ImageCount; i++) { v_list.Append(this._ImageList[this._GeneratedList[i]]); }
    return v_list.ToString().toUpperCase();
}
HumanCheck.prototype._GenerateList = function()
{
	if(this.ImageCount <= 0) { this.ImageCount = this.DefaultImageCount(); }
	var v_multiplier = this._ImageList.length;
	for(var i = 0; i < this.ImageCount; i++)
	{
		this._GeneratedList.push(Math.floor(Math.random() * v_multiplier));
	}
	return;
}
