function trim_all_spaces(str) {
	if (str.match(/\s/g)){
		str = str.replace(/\s/g, "");
	}
	return str;
}

function trimleading(str){
	while (str.charAt(0).match(/[\s\n\r]/) && str.length>0){
		str = str.substring (1, str.length);
	}
	return str;
}

function trimtrailing(str) {
	while (str.charAt(str.length-1).match(/[\s\n\r]/) && str.length>0){
		str = str.substring ( 0, str.length-1 );
	}
	return str;
}

function trim(str) {
	str = trimleading(str);
	str = trimtrailing(str);
	return str;
}

function form_validate(theForm) {

	var fullname = theForm.Contact_FullName.value;
	var Phone	 = theForm.Contact_HomePhone.value;
	//var email	 = theForm.Contact_Email.value;

	// Full Name validation
	fullname = trim_all_spaces( fullname );
	if ( fullname == "" ) {
		alert("Please enter your name.");
		theForm.Contact_FullName.focus();
		return (false);
	}
	if ( fullname.length < 4 ) {
		alert("Please enter at least 4 characters in the \"Name\" field.");
		theForm.Contact_FullName.focus();
		return (false);
	}
	if (fullname.length > 50) {
		alert("Please enter at most 50 characters in the \"Name\" field.");
		theForm.Contact_FullName.focus();
		return (false);
	}
	var regex = /^[A-Za-z&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ\s-\.,\']+$/
	if ( !fullname.match (regex) ) {
		  alert("Unknown character(s) in the \"Name\" field.");
		  theForm.Contact_FullName.focus();
		  return (false);
	}

	// Phone validation
	if (Phone.match(/[^0-9]/g)) {
			Phone = Phone.replace(/[^0-9]/g, "");
	}
	if (Phone.length != 10){
		alert("Please enter valid 10 digit phone number.");
		theForm.Contact_HomePhone.focus();
		return (false);
	}

/******
	// Email validation
	var regex=/^[a-zA-Z&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-@\.]+@[a-zA-Z&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-@\.]{1,69}\.[a-zA-Z]{2,4}$/
	if ( (!email.match(regex)) | (email.length > 70) | (email.length < 6) | (email == "") ) {
		alert( "Please enter valid Email address." );
		theForm.Contact_Email.focus();
		return (false);
	}
	return (true);
}
********/
