function validate_join()  { 
	with(document.contactus)
	{
		theObj   = eval("document.contactus.to");
		document.contactus.actionitem.value = theObj[theObj.selectedIndex].value;
		if(document.contactus.actionitem.value == "Select Destination"){
	        	alert("Please Select a Destination.");
			return false;
    		}
    
		from.value = AllTrim(from.value);
		if(from.value == '')
		{
			from.select()
			from.focus();
			alert("From is a required field.")
			return false;
		}

		if (!VerifyEmail(from.value)) {
			alert ("Please enter a valid From email address.");
			from.select()
			from.focus();
			return false;
		}

		subject.value = AllTrim(subject.value);
		if(subject.value == '')
		{
			subject.select()
			subject.focus();
			alert("Subject is a required field.")
			return false;
		}

		message.value = AllTrim(message.value);
		if(message.value == '')
		{
			message.select()
			message.focus();
			alert("Question is a required field.")
			return false;
		}
		action.value = "SendContact"
		document.contactus.submit();
	}
	return true;
}
function LTrim(str) {
	for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
	return str.substring(k,str.length);
}

function RTrim(str) {
	for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
	return str.substring(0,j+1);
}

function AllTrim(str) {
	return LTrim(RTrim(str));
}

function VerifyEmail(theField) {
    var validChars = "@0123456789-_.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var allValid = true;
	var numAts = 0;
	var extension = "";

	for (var i = 0;  i < theField.length;  i++ )
	{
		ch = theField.charAt(i)
		for ( j = 0;  j < validChars.length;  j++ )
		{
			if ( ch == validChars.charAt(j) ) break
			if ( j == (validChars.length - 1))
			{
				allValid = false
				break
			}
		}
	    if ( ch == "@" )	numAts++
	}

	extension = "." + theField.charAt(theField.length-3) + theField.charAt(theField.length-2) + theField.charAt(theField.length-1) 
	extension = extension.toLowerCase();

	if ( numAts != 1 )
		allValid = false;

	if (!(extension == ".com" || extension == ".gov" || extension == ".net" || extension == ".org" || extension == ".edu" || extension == "..ca" || extension == "..us"))
		allValid = false;
	if ( !allValid )
		return false;

	return true;
}
