function rightTrim() {
   	return this.replace(/\s+$/gi, "");
}
	
function leftTrim() {
	return this.replace(/^\s*/gi, "");
}
	
String.prototype.rightTrim = rightTrim;
String.prototype.leftTrim = leftTrim;

function validateForm() {

	var strFirstName = document.form1.FirstName.value;
	var strLastName = document.form1.LastName.value;
	var strEMail = document.form1.Email.value;		

	strFirstName = strFirstName.rightTrim().leftTrim();
	strLastName = strLastName.rightTrim().leftTrim();
	strEMail = strEMail.rightTrim().leftTrim();

	if (strFirstName == "") {
		alert("Please enter your first name.");
		document.form1.FirstName.focus();
		return false;
	}

	if (strLastName == "") {
		alert("Please enter your last name.");
		document.form1.LastName.focus();
		return false;
	}

	if (strEMail == "") {
		alert("Please enter your email.");
		document.form1.Email.focus();
		return false;	
	}

	if (!emailCheck(strEMail)) {
		return false;
	}

	if (document.form1.ForeignNational.value=="Yes") {
		if (document.form1.CountryOfCitizenship.value=="") {
			alert("Please enter your country of citizenship.");
			document.form1.CountryOfCitizenship.focus();
			return false;
		}
		if (document.form1.DateOfBirth.value=="") {
			alert("Please enter your date of birth.");
			document.form1.DateOfBirth.focus();
			return false;
		}
		if (document.form1.PlaceOfBirth.value=="") {
			alert("Please enter your place of birth.");
			document.form1.PlaceOfBirth.focus();
			return false;
		}
	}

	if (document.form1.Phone.value=="") {
		if (document.form1.ForeignPhone.value=="") {
			alert("You must either enter a US phone number or a Foreign Phone Number.");
			document.form1.Phone.focus();
			return false;
		}
	}

	if (document.form1.Street.value=="") {
		alert("You must enter your street address.");
		document.form1.Street.focus();
		return false;
	}	
	
	if (document.form1.City.value=="") {
		alert("You must enter your city.");
		document.form1.City.focus();
		return false;
	}		
	
	if (document.form1.Country.value=="USA") {
		if (document.form1.State.value==" ") {
			alert("You must either enter your state.");
			document.form1.State.focus();
			return false;
		}
	}

	if (frames['myIframe'].document.uploadAttachment.Attachment.value != ""){
		alert("You have selected a file to attach to this registation, but you have not attached it yet.  Please click the attach button, then send the email.");
		return false;
	}

	document.form1.submit();
}

function showHide(objectID){
	if (document.getElementById(objectID).style.display=='block') {
		document.getElementById(objectID).style.display='none';
	}else{
		document.getElementById(objectID).style.display='block';
	}
}

function setUpForm() {
	if (document.form1.Abstract.value=="Yes") {
		document.getElementById("AbstractPart").style.display='block';
	}
	if (document.form1.ForeignNational.value=="Yes") {
		document.getElementById("ForeignNational").style.display='block';
	}
}