// Start the form with the cursor in the first field in demand_letter_wda.php -- or any other form
function pointToFirstField(theField) {
// Replace field1 in the script with the field name of which you want to place the focus.
	theField.focus(theField);
}

function validateform()
{

// Check for cust_name
	if(document.forms[0].cust_name.value=="") {
		document.forms[0].cust_name.focus();
		window.alert ("Please provide your Full Name");
		return false;
	}

// Check for valid phone number
	var CleanedString=""; 
	var index = 0; 
	var LimitCheck; 
	var InitialString = document.forms[0].phone.value;

// Get the length of the inputted string, to know how many characters to check
	LimitCheck = InitialString.length;
 
// Walk through the inputted string and collect only number characters, appending them to CleanedString
	while (index != LimitCheck) { 
		if (isNaN(parseInt(InitialString.charAt(index)))) { } 
		else { CleanedString = CleanedString + InitialString.charAt(index); } 
		index = index + 1; 
	}
 
// If CleanedString is exactly 10 digits long, then format it and allow form submission
	if (CleanedString.length == 10) { 
		document.forms[0].phone.value = "(" + CleanedString.substring(0,3) + ") " + CleanedString.substring(3,6) + "-" + CleanedString.substring(6,10); 
	}
 
// If CleanedString is not 10 digits longs, show an alert and cancel form submission
//	else { 
//		CleanedString = InitialString; 
//		alert("Phone numbers must have exactly ten digits.");
//		document.forms[0].phone.focus();
//		return false
//	}

// Check for valid email address
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.forms[0].cust_email.value)){
//		return (true)
	} else {
	document.forms[0].cust_email.focus();
	alert("Please provide a valid E-mail Address")
	return (false)
	}

// Check for subject
	if(document.forms[0].subject.value=="") {
		document.forms[0].subject.focus();
		window.alert ("Please provide a Message Subject");
		return false;
	}

// Check for note
	if(document.forms[0].note.value=="") {
		document.forms[0].note.focus();
		window.alert ("Please provide a brief Message");
		return false;
	}
}

