var total_errors = 0;

function validate(theForm){

	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	strEmail_1 = form.email.value;
	
	if(form.name.value == ''){
		var error_id = document.getElementById('name_err');
		error_id.style.visibility = 'visible';
		error_id.style.color = '#D53042';
		total_errors++;
	}else{
		var error_id = document.getElementById('name_err');
		error_id.style.visibility = 'hidden';
	}

	if(form.comments.value == ''){
		var error_id = document.getElementById('comments_err');
		error_id.style.visibility = 'visible';
		error_id.style.color = '#D53042';
		total_errors++;
	}else{
		var error_id = document.getElementById('comments_err');
		error_id.style.visibility = 'hidden';
	}

 	if ((strEmail_1.search(validRegExp) == -1) || (form.email.value == '')){
		var error_id = document.getElementById('email_err');
		error_id.style.visibility = 'visible';
		error_id.style.color = '#D53042';
		total_errors++;
	}else{
		var error_id = document.getElementById('email_err');
		error_id.style.visibility = 'hidden';
	}
		
	if(form.validate_me.value != form.hide.value){
		var error_id = document.getElementById('validate_err');
		error_id.style.visibility = 'visible';
		error_id.style.color = '#D53042';
		total_errors++;
	}else{
		var error_id = document.getElementById('validate_err');
		error_id.style.visibility = 'hidden';
	}				

	if(total_errors > 0){
		total_errors = 0;
		return false;
	}else{
		return true;
	}
}

function remove_errors(){
	var error_id = document.getElementById('name_err');
	error_id.style.visibility = 'hidden';
	var error_id = document.getElementById('comments_err');
	error_id.style.visibility = 'hidden';
	var error_id = document.getElementById('email_err');
	error_id.style.visibility = 'hidden';
	var error_id = document.getElementById('validate_err');
	error_id.style.visibility = 'hidden';	
}
