// Use for sending email 

function SendEmail()
{
	//Hide the email address from spiderbots and email harvesters
	var em1 = "AFlint"
	var em2 = "@" 
	var em3 = "LGFlint.com"
	var subject = 'Question from Website';
	
	
var linefeed = "%0A";
var myOldString = document.jsform.message.value;
var myNewString = myOldString.replace(/\n/g, linefeed);	
	
	
	
	var mailer = 'mailto:' + (em1 + em2 + em3) + '?subject=' + subject + '&body=' + 'Name:%20' + 
   					document.jsform.title.value + '%20' + document.jsform.name.value + '%0A %0A' + 
				// 'Email:%20' + document.jsform.email.value + '%0A %0A' + 'Message:%0A' + document.jsform.message.value +'%0A';
				'Email:%20' + document.jsform.email.value + '%0A %0A' + 'Message:%0A' + myNewString +'%0A';
	parent.location = mailer;
	
	clearForms();
} 

function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}

function isValidName(elem, helperMsg){

//alert("enter isValidName()");

	if (document.jsform.name.value.length < 1) {
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}


function madeSelection(elem, helperMsg){

//alert("enter madeSelection()");
	if (document.jsform.title.value.length < 1) {
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	
//alert("enter emailValidator");
	
    if (document.jsform.email.value.match(emailExp)) {	
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
	
}

function formValidator(){
	// Make quick references to our fields
	
	var name = document.getElementById('name');
	var title = document.getElementById('title');
	var email = document.getElementById('email');
	
	// Check each input in the order that it appears in the form!
	if(isValidName(name, "Please enter your name")){
		if(madeSelection(title, "Please choose your title")){
			if(emailValidator(email, "Please enter a valid email address")){
				SendEmail();
			}
		}
	}
	
	return false;
	
}

