function display_error_text( form_field_name )
{
	form_field_error_notice = document.getElementById( form_field_name + '-error-notice' );
	form_field_error_notice.style['display'] = 'block';
}

function hide_error_text( form_field_name )
{
	form_field_error_notice = document.getElementById( form_field_name + '-error-notice' );
	form_field_error_notice.style['display'] = 'none';
}

function indicate_error( form_field_name )
{
	form_field_status_indicator = document.getElementById( form_field_name + '-field-status' );
	form_field_status_indicator.innerHTML = '<span style="color: #f00">&#10007;</span>';
}

function indicate_success( form_field_name )
{
	form_field_status_indicator = document.getElementById( form_field_name + '-field-status' );
	form_field_status_indicator.innerHTML = '<span style="color: #0f0">&#10003;</span>';
}

function validate_field( validation_type, form_field_name )
{
	form_field = document.getElementById( form_field_name );

	// allowed validation types: any text, e-mail
	if ( validation_type == 'any text' )
	{
		if ( form_field.value != '' )
		{
			indicate_success( form_field_name );
			return true;
		}
		else
		{
			indicate_error( form_field_name );
			return false;
		}
	}
	else if ( validation_type == 'e-mail' )
	{
		email_regexp = new RegExp( '^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+\.[a-zA-Z]+$' );
		if ( email_regexp.test( form_field.value ) )
		{
			indicate_success( form_field_name );
			return true;
		}
		else
		{
			indicate_error( form_field_name );
			return false;
		}
	}
}

// calling method: validate_multiple_fields( Array( 'validation type', 'field name' ) );
function validate_multiple_fields()
{
	errors_encountered = false;
	
	for ( i = 0; i < arguments.length; i++ )
	{
		validation_type = arguments[i][0];
		form_field_name = arguments[i][1];
		
		if ( validate_field( validation_type, form_field_name ) == false )
		{
			errors_encountered = true;
			display_error_text( form_field_name );
		}
		else
		{
			hide_error_text( form_field_name );
		}
	}
	
	return !errors_encountered;
}

