// JavaScript Document
function checkemail(str){
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    result=true
 else {
    result=false
}
 return (result)
}


function checkFields()
{
	
	var err_bgcolor = '#FFA5BE';
	var bgcolor = '#C0D5E6';
	var name = document.getElementById('txtname');
	var email = document.getElementById('txtemail');
	var phone = document.getElementById('txtphone');
	var subject = document.getElementById('txtsubject');
	var message = document.getElementById('txtmessage');
	var err = 0;
	
	if (!checkemail(email.value)) {
		err = 1;
		email.style.backgroundColor = err_bgcolor;
	}
	else
		email.style.backgroundColor = bgcolor;
	
	if (name.value == '') {
		err = 1;
		name.style.backgroundColor = err_bgcolor;
	}
	else
		name.style.backgroundColor = bgcolor;
	
	if (email.value == '') {
		err = 1;
		email.style.backgroundColor = err_bgcolor;
	}
	else
		email.style.backgroundColor = bgcolor;
	
	if (phone.value == '') {
		err = 1;
		phone.style.backgroundColor = err_bgcolor;
	}
	else
		phone.style.backgroundColor = bgcolor;
	
	if (message.value == '') {
		err = 1;
		message.style.backgroundColor = err_bgcolor;
	}
	else
		message.style.backgroundColor = bgcolor;
			
	if (err == 0)
		return true;
	else {	
		document.getElementById('msgBox').innerHTML = 'Please complete the necessary information.';
		return false;
	}
}