$(document).ready(function(){
	
	$('form.check_required').submit(function()
	{
		
	
		var errors = false;
		var first_error_id = '';
		$('.required').each(function()
		{
			$(this).removeClass('error');
			if ($(this).attr('value') == '')
			{
				$(this).addClass('error');
				errors = true;
				if (first_error_id == '')
				{
					first_error_id = $(this).attr('name');
					// since these forms don't have ID"s in the input tag
					$(this).attr('id', first_error_id);
				}
			}
			
			
		});
		
		if (errors == true) 
		{
			alert('Please fill all required fields.');
			$('#'+first_error_id).focus();
			return false;
		}
	});
});