function verify()
{
	var required = 0;

	if (echeck(document.getElementById('form_email').value)==false)
		{
		document.getElementById('form_email').value='';
		}

	for(i=0; i<document.forms[0].elements.length; i++) //Counts all the elements in the form (inputs, textarea, etc)
		{
		if (document.forms[0].elements[i].className.indexOf('reqd') >=0 ) //Finds all the elements in the form that have a class of required
			{
			if (document.forms[0].elements[i].value == "") // IF required class is empty
				{
				document.forms[0].elements[i].style.background='#FFFF00'; //style of the required element
				document.forms[0].elements[i].style.border='3px solid #FF0000'; // style of the required element
				required++;
				} 
			else 
				{
				document.forms[0].elements[i].style.background='#FFFFFF'; // style of element if it is filled out correctly
				document.forms[0].elements[i].style.border='1px solid #CCCCCC'; // style of the required element
				}
			}
		}

	if (required != 0) 
		{
		alert("Please complete the highlighted fields.");
		return false;
		}
	else 
		{
		document.getElementById('contact_form').submit();
		}
}


function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var badEmail = 0;
		if (str.indexOf(at)==-1){
		   badEmail++;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   badEmail++;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   badEmail++;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   badEmail++;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   badEmail++;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   badEmail++;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   badEmail++;
		 }


	if (badEmail !== 0) 
		{
		alert("Invalid email address.");
		return false;
		}
	else 
		{
		return true;
		}
	}