function ContestEntryPage(params)
{
	this.Initializing = false;
	this.SName = $('#sName').val();
	this.SEmail = $('#sEmail').val();
	this.SPhone = $('#sPhone').val();
	this.SAddress = $('#sAddress').val();
	this.SComment = $('#sComment').val();
	
	this.Handler = params.handler;
}

ContestEntryPage.prototype.Initialize = function()
{
	this.Initializing = true;
	this.RegisterEvents();
	this.Initializing = false;
};

ContestEntryPage.prototype.RegisterEvents = function()
{
	var _this = this;
};

ContestEntryPage.prototype.SendForm = function()
{
	var _this = this;
	var Validated = _this.ValidateForm();
	
	if(Validated)
	{
		var FormVals = $("form").serialize();

		$.ajax({
					type: "POST",
					url: _this.Handler,
					data: "action=ProcessForm&" + FormVals,
					success: function(result)
					{
						var data = eval('('+ result +')');
						alert(data._txtSuccessText);
						
						if(data._sSuccess != "Duplicate Entry")
						{
							window.location = 'galleries.php';
						}
					}
			   });
	}
	
	return false;
};

ContestEntryPage.prototype.ValidateForm = function()
{
	var _this = this;

	var errors = 0;

	var sName = $('#sName').val();
	if(sName == "")
	{
		alert("Please give your name.");
		errors += 1;	
	}

	var sEmail = $('#sEmail').val();
	if(sEmail == "")
	{
		alert("Please incluse an email address.");
		errors += 1;	
	}

/*
	var sPhone = $('#sPhone').val();
	if(sPhone == "")
	{
		alert("Blank field.");
		errors += 1;	
	}

	var sAddress = $('#sAddress').val();
	if(sAddress == "")
	{
		alert("Blank field.");
		errors += 1;	
	}
*/

	var sComment = $('#sComment').val();
	if(sComment == "")
	{
		alert("Please provide your entry comment.");
		errors += 1;	
	}

		if(errors > 0)
		{
			return false;
		}
		else
		{
			return true;
		}
};
