function validateData(form)
{
	var re = / /g;
	var check
  document.theForm.email.value = document.theForm.email.value.replace(re,"");
  check = document.theForm.email.value.replace(re,"");
	
	 var formattedphone;
	 formattedphone = document.theForm.area.value + "-" + document.theForm.firstdigits.value + "-" + document.theForm.lastdigits.value;
	 document.theForm.phone.value = formattedphone;
	
	if (document.theForm.first_name.value == "" )
	{
		alert("Please enter your first name.");
		document.theForm.first_name.focus();
		return false;	
	}
	
	if (document.theForm.last_name.value == "" )
	{
		alert("Please enter your last name.");
		document.theForm.last_name.focus();
		return false;	
	}

	if (document.theForm.address.value == "" )
	{
		alert("Please enter your address.");
		document.theForm.address.focus();
		return false;	
	}

	if (document.theForm.city.value == "" )
	{
		alert("Please enter your city.");
		document.theForm.city.focus();
		return false;	
	}

	if (document.theForm.state.selectedIndex  == 0 )
	{
		alert("Please select your state.");
		document.theForm.state.focus();
		return false;	
	}

	if (document.theForm.country.selectedIndex  == 0 )
	{
		alert("Please select your country.");
		document.theForm.country.focus();
		return false;	
	}

	if (document.theForm.zip.value == "" )
	{
		alert("Please enter your zip code.");
		document.theForm.zip.focus();
		return false;	
	}

	if (IsEmailValid('theForm','email') == false) 
	{
		alert ("Please enter your E-mail address before continuing:  must be in the format of xxxx@xxx.xxx.");
		document.theForm.email.focus();
		return false;
	}

	if (document.theForm.area.value == "" || document.theForm.firstdigits.value == "" || document.theForm.lastdigits.value == "")
	{
		alert("Please enter your evening phone number.");
		document.theForm.area.focus();
		return false;	
	}
	
	if (document.theForm.gradmonth.selectedIndex  == 0 )
	{
		alert("Please select your High School Graduation or G.E.D. MONTH of Completion.");
		document.theForm.gradmonth.focus();
		return false;	
	}	

	if (document.theForm.gradyear.selectedIndex  == 0 )
	{
		alert("Please select your High School Graduation or G.E.D. YEAR of Completion.");
		document.theForm.gradyear.focus();
		return false;	
	}	

	if (document.theForm.campus.selectedIndex  == 0 )
	{
		alert("Please select which AIU Campus you're interested in.");
		document.theForm.campus.focus();
		return false;	
	}	
	
	if (document.theForm.program.selectedIndex  == 0 )
	{
		alert("Please select the type of degree program you're interested in.");
		document.theForm.program.focus();
		return false;	
	}

	if (document.theForm.cbUnderstand.checked == false)
	{
		alert("Please select the checkbox agreeing that you understand that an Admission Advisor \nwill contact you to provide you with additional information related to your specific goals.");
		return false;	
	}
  
  var formattedphone2;
  formattedphone2 = document.theForm.area2.value + "-" + document.theForm.firstdigits2.value + "-" + document.theForm.lastdigits2.value;
  document.theForm.work_phone.value = formattedphone2;
}
function IsEmailValid(FormName,ElemName)
{
	var EmailOk  = true
	var Temp     = document.forms[FormName].elements[ElemName]
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // '@' cannot be in first position
    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
    (Period == Length ) ||             // Must be atleast one valid char after '.'
    (Space  != -1))                    // No empty spaces permitted
  {  
      EmailOk = false
      Temp.focus()
  }
	return EmailOk
}
