$(document).ready(function(){
	

	$('#submit').click(function(){
		$('input.error, select.error, textarea.error', '#bspForm').removeClass('error');
		$('span.error', '#bspForm').remove();
		
		$('.required', '#bspForm').each(function(){
			if ( $(this).is('input') )
			{
				if ( '' == $(this).val() )
				{
					$(this).addClass('error');
				}
			};
			if ( $(this).is('select') )
			{
				if ( '' == $(':selected', this).val() )
				{
					$(this).addClass('error');
				}
			};
			if ( $(this).is('textarea') )
			{
				if ( '' == $(this).val() )
				{
					$(this).addClass('error');
				}
			};
		});
		
		if ( $('.error', '#bspForm').length > 0 ) 
		{
			$('<span class="error">Please complete all fields marked below.</span>').insertAfter('#bspForm h5');
			return false;
		}

	});
	
	$('<br><b class="count">150 Characters</b>')
	.insertAfter('textarea');

	$('textarea')
	.keyup(function(){
		$('b.count').text( (150 - $(this).val().length) +  ' Characters');
		if ( $(this).val().length > 150)
		{
			$(this).val( $(this).val().substring(0,149) );
		}
	});
	
	
});