function Trim(orgString){
  return LTrim(RTrim(orgString))
}

function LTrim(orgString){
  return orgString.replace(/^\s+/,'')
}

function RTrim(orgString){
  return orgString.replace(/\s+$/,'')
}

function SubmitInfocontactform(){
	var cCont;
	cCont = 1;

	if ((cCont==1) && (Trim(document.contactform.firstname.value).length == 0)){
		cCont = 0;
		alert('Please fill in the first name field.');
	}

	if ((cCont==1) && (Trim(document.contactform.lastname.value).length == 0)){
		cCont = 0;
		alert('Please fill in the last name field.');
	}

	if ((cCont==1) && (Trim(document.contactform.address.value).length == 0)){
		cCont = 0;
		alert('Please fill in the address field.');
	}

	if ((cCont==1) && (Trim(document.contactform.city.value).length == 0)){
		cCont = 0;
		alert('Please fill in the city field.');
	}

	if ((cCont==1) && (Trim(document.contactform.state.value).length == 0)){
		cCont = 0;
		alert('Please fill in the state field.');
	}

	if ((cCont==1) && (Trim(document.contactform.zip.value).length < 5)){
		cCont = 0;
		alert('Please fill in a 5 digit zip code.');
	}

	if ((cCont==1) && (Trim(document.contactform.phone.value).length == 0)){
		cCont = 0;
		alert('Please fill in the phone field.');
	}

	if ((cCont==1) && (Trim(document.contactform.email.value).length == 0)){
		cCont = 0;
		alert('Please fill in the email field.');
	}

	if ((cCont==1) && (Trim(document.contactform.campus.value).length == 0)){
		cCont = 0;
		alert('Please fill in the campus field.');
	}

	if ((cCont==1) && (Trim(document.contactform.program.value).length == 0)){
		cCont = 0;
		alert('Please fill in the program field.');
	}

	if ((cCont==1) && (Trim(document.contactform.hsgraduation.value).length == 0)){
		cCont = 0;
		alert('Please fill in the Year of high school graduation/GED field.');
	}

	if (cCont == 1){
		return true;
	} else {
		return false;
	}
}

function SubmitInfocontactform2(){
	var cCont;
	cCont = 1;

	if ((cCont==1) && (Trim(document.contactform.firstname.value).length == 0)){
		cCont = 0;
		alert('Please fill in the first name field.');
	}

	if ((cCont==1) && (Trim(document.contactform.lastname.value).length == 0)){
		cCont = 0;
		alert('Please fill in the last name field.');
	}

	if ((cCont==1) && (Trim(document.contactform.address.value).length == 0)){
		cCont = 0;
		alert('Please fill in the address field.');
	}

	if ((cCont==1) && (Trim(document.contactform.city.value).length == 0)){
		cCont = 0;
		alert('Please fill in the city field.');
	}

	if ((cCont==1) && (Trim(document.contactform.state.value).length == 0)){
		cCont = 0;
		alert('Please fill in the state field.');
	}

	if ((cCont==1) && (Trim(document.contactform.zip.value).length < 5)){
		cCont = 0;
		alert('Please fill in a 5 digit zip code.');
	}

	if ((cCont==1) && (Trim(document.contactform.phone.value).length == 0)){
		cCont = 0;
		alert('Please fill in the phone field.');
	}

	if ((cCont==1) && (Trim(document.contactform.email.value).length == 0)){
		cCont = 0;
		alert('Please fill in the email field.');
	}

	if ((cCont==1) && (Trim(document.contactform.referral_name.value).length == 0)){
		cCont = 0;
		alert('Please fill in the referral name field.');
	}

	if ((cCont==1) && (Trim(document.contactform.ref_phone_number.value).length == 0)){
		cCont = 0;
		alert('Please fill in the referral phone number field.');
	}

	if ((cCont==1) && (Trim(document.contactform.ref_email.value).length == 0)){
		cCont = 0;
		alert('Please fill in the referral email field.');
	}

	if (cCont == 1){
		return true;
	} else {
		return false;
	}
}


function updateStartDate() {
	var campus = document.getElementById('campus').value;
	var program = document.getElementById('program').value;
	var startdate = document.getElementById('startdate');
	startdate.innerHTML = ""
	option1 = new Option("", "", false, false);
	startdate.options[startdate.options.length] = option1;
	var xmlDoc

	if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
	else // Internet Explorer 5/6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
	xhttp.open("GET","/courses.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	courselist=xmlDoc.documentElement.getElementsByTagName("course");
	for (i=0;i<courselist.length;i++) {
		if (courselist[i].attributes.item(0).nodeValue == campus && courselist[i].attributes.item(1).nodeValue == program) {
			optionlist = courselist[i].getElementsByTagName("option");
			for (j=0;j<optionlist.length;j++) {
				option1 = new Option(optionlist[j].childNodes.item(0).nodeValue, optionlist[j].childNodes.item(0).nodeValue, false, false);
				startdate.options[startdate.options.length] = option1;
			}
		}
	}
	return false;
}


