
function validateForm(f) {

haveerrors = 0;
haveemailerrors = 0;
havephoneerrors = 0;

	if (document.frmContact.mySpamTrap.value.length > 0) { 
		haveerrors = 1
	}
	
	if ((document.frmContact.field_blockthebots.value != 4) && (document.frmContact.field_blockthebots.value != 'four')) { 
		document.frmContact.field_blockthebots.style.backgroundColor = '#F1E4E4';
		haveerrors = 1
	}
	else {
		document.frmContact.field_blockthebots.style.backgroundColor = '#FFFFFF';
	}	
	
	if (document.frmContact.field_name.value.length < 1) { 
		document.frmContact.field_name.style.backgroundColor = '#F1E4E4';
		haveerrors = 1
	}
	else {
		document.frmContact.field_name.style.backgroundColor = '#FFFFFF';
	}	


	var strippedPhoneNumber = document.frmContact.field_telephone.value.replace(/[\(\)\.\-\ ]/g, '');

	if (document.frmContact.field_telephone.value.length < 1) { 
		document.frmContact.field_telephone.style.backgroundColor = '#F1E4E4';
		haveerrors = 1
	} else if (isNaN(parseInt(strippedPhoneNumber))) {
		document.frmContact.field_telephone.style.backgroundColor = '#F1E4E4';
		havephoneerrors = 1;
	} else if (!(strippedPhoneNumber.length == 10)) {
		document.frmContact.field_telephone.style.backgroundColor = '#F1E4E4';
		havephoneerrors = 1;
	} else {
		document.frmContact.field_telephone.style.backgroundColor = '#FFFFFF';
		havephoneerrors = 0
	}	
	
	

	if (document.frmContact.field_email.value.length < 1) { 

		document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
		haveerrors = 1

	} else {

		var str = (document.frmContact.field_email.value);
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
			
		if (str.indexOf(at)==-1){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		} else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';		
			haveemailerrors = 1;
		} else if (str.indexOf(at,(lat+1))!=-1){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		 } else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		 } else if (str.indexOf(dot,(lat+2))==-1){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		 } else if (str.indexOf(" ")!=-1){
			document.frmContact.field_email.style.backgroundColor = '#F1E4E4';
			haveemailerrors = 1;
		 } else {
			document.frmContact.field_email.style.backgroundColor = '#FFFFFF';
			haveemailerrors = 0;			 
		
		 }
	 
	}	
	
	if (!haveerrors) {

		document.getElementById( 'validationError' ).setAttribute( 'style', 'display:none' );

	} else {

		document.getElementById( 'validationError' ).setAttribute( 'style', 'display:inline' );

	}

	if (!havephoneerrors) {

		document.getElementById( 'phoneValidationError' ).setAttribute( 'style', 'display:none' );

	} else {
						
		document.getElementById( 'phoneValidationError' ).setAttribute( 'style', 'display:inline' );
								
	}	
	
	if (!haveemailerrors) {
			
		document.getElementById( 'emailValidationError' ).setAttribute( 'style', 'display:none' );

	} else {

		document.getElementById( 'emailValidationError' ).setAttribute( 'style', 'display:inline' );

	}
	
	
	if ((haveerrors) || (haveemailerrors) || (havephoneerrors)) {

		return (false);
		document.getElementById( 'Submit' ).disabled=false;		

	} else {
	
		document.getElementById( 'Submit' ).disabled=true;		
		
	}
}
