var fields =
{
	'name'          : 'name',
	'email'         : 'email address',
	'subject'       : 'subject',
	'message'       : 'message',
	'security_code' : 'security code'
};


nicoswd.prototype.contact = function()
{
	/* Fancy constructor */
	
	this.is_valid = false;
}


nicoswd.prototype.contact.validate = function()
{
	var errorbox = new ErrorBox('errors', 500);
	var grammar;
    
    for (var field in fields)
    {
		var object = $('#' + field)[0];
		object.value = $.trim(object.value);
		
		if (!object.value)
		{
			grammar = fields[field][0] == 'e' ? 'n ' : ' ';
			errorbox.display('You did not enter a' + grammar + fields[field] + '!');
			object.focus();
			
			return false;
		}
	}
	
	this.is_valid = true;
	
	return this.submit();
}


nicoswd.prototype.contact.submit = function()
{
	if (!this.is_valid)
	{
		alert('What\'s with these shenanigans?');
		return false;
	}
	
	var values = [];
	
    for (var field in fields)
	{
		var obj = $('#' + field)[0];
		values[field] = obj.value;
		
		// obj.disabled = true;
		// obj.readOnly = true;
	}
	
	// alert(values);
	
	return true;
}

nicoswd.prototype.contact.init = function()
{
	for (var field in fields)
	{
		var object = $('#' + field);
		
		$('#con_' + object[0].id).addClass('contact_form_border');
		object.focus(highlight).blur(unhighlight);
	}
	
	$('#name')[0].focus();
}
