function FrontPage_Form1_Validator(theForm){
	
// Canada duplication quick fix
if(theForm.Country.value == "Canada" && theForm.Country.selectedIndex > 5){
	theForm.Country.selectedIndex = 2;
	prepareForm();
}

var postalcode = theForm.Postal_Code1.value;
var postalcode2 = theForm.Postal_Code2.value;

  if (theForm.Title.selectedIndex == 0){
    alert("Please enter your Title.");
    theForm.Title.focus();
    return (false);
  }

  if (theForm.First_Name.value == ""){
    alert("Please enter a value for the First Name field.");
    theForm.First_Name.focus();
    return (false);
  }

  if (theForm.Last_Name.value == ""){
    alert("Please enter a value for the Last Name field.");
    theForm.Last_Name.focus();
    return (false);
  }

   if (theForm.Highest_Degree_Earned.value == "Diploma" || theForm.Highest_Degree_Earned.value == "Associates"){
    alert("You must have a bachelors degree to apply.");
    theForm.Highest_Degree_Earned.focus();
    return (false);
  }

  if (theForm.Highest_Degree_Earned.selectedIndex == 0){
    alert("The first Highest_Degree_Earned option is not a valid selection.  Please choose one of the other options.");
    theForm.Highest_Degree_Earned.focus();
    return (false);
  }

   if (theForm.Country.selectedIndex == 0){
    alert("Please select a Country.");
    theForm.Country.focus();
    return (false);
  }

	if (theForm.Address.value == ""){
  	alert("Please enter a value for the Address field.");
	theForm.Address.focus();
  	return (false);
}

	if (theForm.City.value == ""){
	alert("Please enter a value for the City field.");
	theForm.City.focus();
	return (false);
}

// ***** US VALIDATION *****

if (theForm.Country.value == "United States"){
	if (theForm.us_State.value == "none"){
    	alert("Please enter a value for the us_State field.");
    	theForm.us_State.focus();
    	return (false);
  	}
	if (theForm.Zip1.value == ""){
    	alert("Please enter a value for the Zip field.");
		theForm.Zip1.focus();
    	return (false);
	}
	
}

// ***** CANADA VALIDATION *****

if (theForm.Country.value == "Canada"){
	if (theForm.Province.value == "none"){
    	alert("Please enter a value for the Province field.");
    	theForm.Province.focus();
    	return (false);
  	}
	
	if (theForm.Postal_Code1.value == ""  || theForm.Postal_Code2.value == ""){
    	alert("Please enter a value for the Postal Code field.");
    	theForm.Postal_Code1.focus();
    	return (false);
  	}
	if (postalcode.search(/^[a-zA-Z]\d[a-zA-Z]$/) == -1 || postalcode2.search(/^\d[a-zA-Z]\d$/) == -1){
	  	alert("This is not a valid postal code");
		theForm.Postal_Code1.focus();
		return false;
	}
}


// ***** DAYTIME PHONE VALIDATION *****

if (theForm.Country.value == "Canada"){
	if (theForm.Can_Primary_Phone_1.value == "" || theForm.Can_Primary_Phone_2.value == "" || theForm.Can_Primary_Phone_3.value == ""){
  		alert("Please enter a value for the Primary Phone field.");
		theForm.Can_Primary_Phone_1.focus();
  		return (false);
	}
}
else if (theForm.Country.value == "United States"){
	if (theForm.us_Primary_Phone_1.value == "" || theForm.us_Primary_Phone_2.value == "" || theForm.us_Primary_Phone_3.value == ""){
  		alert("Please enter a value for the Primary Phone field.");
		theForm.us_Primary_Phone_1.focus();
  		return (false);
	}
}else{
	if (theForm.Int_Primary_Phone.value == ""){
  		alert("Please enter a value for the Primary Phone field.");
		theForm.Int_Primary_Phone.focus();
  		return (false);
	}
}

	if (theForm.designation_name[0].checked == false && theForm.designation_name[1].checked == false){
  		alert("Please indicate if you are certified by the ABMS.");
		theForm.designation_name[0].focus();
  		return (false);
	}
	if(theForm.designation_name[0].checked == true && theForm.Specialization.value == ""){
		alert("Please select your ABMS Specialty.");
		theForm.Specialization.focus();
		return false;
	}

//   SET VALUE OF HIDDEN FIELDS 

  if (theForm.Country.value == "Canada"){
	theForm.Region.value = "Canada";
	
	// This is the Canadian Work phone section.  The resulting value is Primary_Phone
	theForm.Primary_Phone.value = theForm.Can_Primary_Phone_1.value + theForm.Can_Primary_Phone_2.value + theForm.Can_Primary_Phone_3.value + " x " + theForm.Can_Primary_Ext.value;
	// This is the Work Phone's extension.  The resulting value is Extension	
	theForm.Extension.value = theForm.Can_Primary_Ext.value;
	
	//This is the Canadian Home phone section.  The resulting value passes as Secondary_Phone
	theForm.Secondary_Phone.value = theForm.Can_Secondary_Phone_1.value + theForm.Can_Secondary_Phone_2.value + theForm.Can_Secondary_Phone_3.value + theForm.Can_Secondary_Ext.value;
	// theForm.Extension.value = theForm.Can_Evening_Ext.value;
	
	//This is the Canadian Cellphone section.  The resulting value passes as cellphone
	//theForm.cellphone.value = theForm.can_cell_1.value + theForm.can_cell_2.value + theForm.can_cell_3.value;
	
	theForm.Zip.value = theForm.Postal_Code1.value + theForm.Postal_Code2.value;
	
	theForm.State.value = theForm.Province.value;
}else if (theForm.Country.value == "United States"){
	theForm.Region.value = "United States";
	
	// This is the USA Work phone section.  The resulting value is Primary_Phone
	theForm.Primary_Phone.value = theForm.us_Primary_Phone_1.value + theForm.us_Primary_Phone_2.value + theForm.us_Primary_Phone_3.value;
	// This is the USA Work Phone's extension.  The resulting value is Extension
	theForm.Extension.value = theForm.us_Primary_Ext.value;
	//This is the USA Home phone section.  The resulting value passes as Secondary_Phone
	theForm.Secondary_Phone.value = theForm.us_Secondary_Phone_1.value + theForm.us_Secondary_Phone_2.value + theForm.us_Secondary_Phone_3.value + theForm.us_Secondary_Ext.value;
	// theForm.Extension.value = theForm.us_Evening_Ext.value;
	
	//This is the USA Cellphone section.  The resulting value passes as cellphone
	//theForm.cellphone.value = theForm.us_cell_1.value + theForm.us_cell_2.value + theForm.us_cell_3.value;
	
	theForm.Zip.value = theForm.Zip1.value + theForm.Zip2.value;
	
	theForm.State.value = theForm.us_State.value;
}else{
	theForm.Region.value = "International";
	
	// This is the International Work phone section.  The resulting value is Primary_Phone
	theForm.Primary_Phone.value = theForm.Int_Primary_Phone.value;
	// This is the International Work Phone's extension.  The resulting value is Extension
	theForm.Secondary_Phone.value = theForm.Int_Secondary_phone.value;
	//This is the International Cellphone section.  The resulting value passes as cellphone
	//theForm.cellphone.value = theForm.Int_Cellular_phone.value;
	theForm.State.value = " ";
}


/* var postal_filter2 = /^\d[a-z]\d$/;

function checkpostal(e){
var returnval=postal_filter.test(e.value)
if (returnval==false){
alert("Please enter a valid Postal Code.")
e.select()
}
return returnval
}
theForm.Postal_Code1.value

*/



// check e-mail

  if (theForm.Email.value == ""){
    alert("Please enter a value for the Email field.");
    theForm.Email.focus();
    return (false);
  }

  return (true);
  
}


function numbersonly(myfield, e, dec){
var key;
var keychar;
if (window.event)
 key = window.event.keyCode;
else if (e)
 key = e.which;
else
 return true;
keychar = String.fromCharCode(key);
if ((key==null) || (key==0) || (key==8) || 
 (key==9) || (key==13) || (key==27) )
 return true;
else if ((("0123456789").indexOf(keychar) > -1))
 return true;
else if (dec && (keychar == "."))
 {
 myfield.form.elements[dec].focus();
 return false;
 }
else
 return false;
}


var degreeList = new Array("Please Select","Abdominal Surgery","Addiction Medicine","Adolescent Medicine (Pediatrics)","Adult Reconstructive Orthopedics","Aerospace Medicine","Allergy And Immunology","Allergy","Anatomic Pathology","Anatomic/Clinical Pathology","Anesthesiology","Blood Banking/Transfusion Medicine","Cardiovascular Disease","Child &amp; Adolescent Psychiatry","Child Neurology","Clinical Cardiac Electrophysiology","Clinical Cytogenetics","Clinical Genetics","Clinical Laboratory Immunology (Allergy &amp; Immunology)","Clinical Molecular Genetics","Clinical Neurophysiology","Clinical Pathology","Clinical Pharmacology","Colon And Rectal Surgery","Cosmetic Surgery","Critical Care Medicine (Anesthesiology)","Critical Care Medicine (Internal Medicine)","Cytopathology","Dermatology","Dermatopathology (Pathology)","Diabetes","Diagnostic Radiology","Emergency Medicine","Endocrinology, Diabetes &amp; Metabolism","Facial Plastic Surgery","Family Medicine","Family Medicine","Family Practice/Psychiatry","Forensic Pathology","Forensic Psychiatry","Gastroenterology","General Practice","General Preventive Medicine","General Surgery","Geriatric Medicine (Family Practice)","Geriatric Medicine (Internal Medicine)","Geriatric Psychiatry","Gynecological Oncology","Gynecology","Hand Surgery (Orthopedics)","Hand Surgery","Head And Neck Surgery","Hematology (Internal Medicine)","Hematology (Pathology)","Hematology/Oncology","Hepatology","Immunology","Infectious Disease","Internal Medicine","Internal Medicine/Pediatrics","Interventional Cardiology","Legal Medicine","Maternal And Fetal Medicine","Medical Genetics","Medical Management","Medical Microbiology","Medical Oncology","Medical Toxicology (Preventive Medicine)","Neonatal-Perinatal Medicine","Nephrology","Neurological Surgery","Neurology","Neuropathology","Neuroradiology","Nuclear Medicine","Nuclear Radiology","Nutrition","Obstetrics &amp; Gynecology","Obstetrics","Occupational Medicine","Ophthalmology","Orthopedic Surgery Of The Spine","Orthopedic Surgery","Osteopathic Manipulative Medicine","Other Specialty","Otolaryngology","Otology-Neurotology","Pain Management","Pain Medicine","Palliative Medicine","Pediatric Allergy","Pediatric Anesthesiology (Anesthesiology)","Pediatric Cardiology","Pediatric Critical Care Medicine","Pediatric Emergency Med (Emergency Med)","Pediatric Emergency Medicine (Emergency Medicine)","Pediatric Emergency Medicine (Pediatrics)","Pediatric Endocrinology","Pediatric Gastroenterology","Pediatric Hematology/Oncology","Pediatric Infectious Disease","Pediatric Nephrology","Pediatric Orthopedics","Pediatric Otolaryngology","Pediatric Pulmonology","Pediatric Radiology","Pediatric Rheumatology","Pediatric Surgery (Surgery)","Pediatric Urology","Pediatrics","Pharmaceutical Medicine","Physical Medicine And Rehabilitation","Plastic Surgery","Psychiatry","Psychoanalysis","Public Health And General Preventive Medicine","Pulmonary &amp; Critical Care Medicine","Pulmonary Disease","Radiation Oncology","Radiology","Reproductive Endocrinology And Infertility","Reproductive Endocrinology","Rheumatology","Selective Pathology","Sleep Medicine","Sports Medicine (Emergency Medicine)","Sports Medicine (Family Practice)","Sports Medicine (Internal Medicine)","Sports Medicine (Orthopedic Surgery)","Surgical Critical Care (Surgery)","Surgical Oncology","Thoracic Surgery","Transitional Year","Traumatic Surgery","Unspecified","Urgent Care Medicine","Urology","Vascular And Interventional Radiology","Vascular Surgery");


function showDegrees(yn){

var daDiv;
var degreeDiv = "";

if(document.all){
	daDiv = document.all['degrees'];
}
if(document.getElementById){
	daDiv = document.getElementById('degrees');
}

if(yn == "y"){
	for(x=0; x<degreeList.length; x++){
		degreeDiv = degreeDiv + "<option value=";
			if(degreeList[x] != "Please Select"){
				degreeDiv = degreeDiv + degreeList[x];
			}
		degreeDiv = degreeDiv + ">" + degreeList[x] + "</option>";
	}
	
	daDiv.innerHTML = "<font size='2' face='Arial' color='#666666'><b>Please Note:</b> If you have a medical degree and are<br>board-certified in the U.S., you are part of a select group<br>that is <b>exempt</b> from taking the GMAT.<hr size='1' noshade><font color='#666666' size='-1'><strong><font color='#FF3333' face='Arial'><i>*</i></font> <b>What is your ABMS Specialty?</b></font><br><br><select name='Specialization' class='selecta'>" + degreeDiv + "</select>";
}else{
	daDiv.innerHTML = "";
}

//end
}