function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
	var c = ca[i];
	while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function setSiteWidth() {
    var el = document.getElementById("pageBounds");
    if(typeof(window.innerWidth != 'number')) 
	{
        if (document.documentElement.clientWidth > 910) {
            el.style.width = "auto";
        } else {
            el.style.width = "900px";
        }
    }
}
window.onresize = function () {
    setSiteWidth();
}
window.onload = function () {
    setSiteWidth();
	
	cookie = readCookie('CID');
	
	currentCID = document.RequestInfoForm.cid.value;
	
	if (currentCID == "1502" && cookie != null)
	{
	  	document.RequestInfoForm.cid.value = cookie;
	}
	
}


// Validation function called by image submit buttons
		function checkForm(theForm) {
			if(ldFormValidate(theForm)) {return true;}
			return false;}

		function ldFormValidate(frm,fldName,stepid) {
			

frm.state.required = true;
frm.state.requiredError = 'State is required.';
frm.state.disallowEmptyValue = true;
frm.state.disallowEmptyValueError = 'State is required.';


frm.programs.required = true;
frm.programs.requiredError = 'Program of Interest is required.';
frm.programs.disallowEmptyValue = true;
frm.programs.disallowEmptyValueError = 'Program of Interest is required.';

frm.firstname.required = true;
frm.firstname.requiredError = 'First Name is required.';
frm.firstname.disallowEmptyValue = true;
frm.firstname.disallowEmptyValueError = 'First Name is required.';


frm.address.required = true;
frm.address.requiredError = 'Address is required.';
frm.address.disallowEmptyValue = true;
frm.address.disallowEmptyValueError = 'Address is required.';


frm.daytimephone.patternText = 'us phone number';
frm.daytimephone.patternError = 'Valid Daytime Phone is required.';

frm.lastname.required = true;
frm.lastname.requiredError = 'Last Name is required.';
frm.lastname.disallowEmptyValue = true;
frm.lastname.disallowEmptyValueError = 'Last Name is required.';

frm.email.patternText = 'email';
frm.email.patternError = 'Valid Email is required.';

frm.zip.maxlength = 12;
frm.zip.maxlengthError = 'Zip/Postal Code must be no more than 12 characters.';

frm.zip.required = true;
frm.zip.requiredError = 'Zip Code is required.';
frm.zip.disallowEmptyValue = true;
frm.zip.disallowEmptyValueError = 'Zip Code is required.';


frm.city.required = true;
frm.city.requiredError = 'City is required.';
frm.city.disallowEmptyValue = true;
frm.city.disallowEmptyValueError = 'City is required.';


frm.StartDate.required = true;
frm.StartDate.requiredError = 'Preferred Enrollment Term is required.';
frm.StartDate.disallowEmptyValue = true;
frm.StartDate.disallowEmptyValueError = 'Preferred Enrollment Term is required.';

frm.yearhsged.required = true;
frm.yearhsged.requiredError = 'Year of High School Graduation or GED Completion is required.';
frm.yearhsged.disallowEmptyValue = true;
frm.yearhsged.disallowEmptyValueError = 'Year of High School Graduation or GED Completion is required.';

frm.LevelOfEducation.required = true;
frm.LevelOfEducation.requiredError = 'Highest Level of Education is required.';
frm.LevelOfEducation.disallowEmptyValue = true;
frm.LevelOfEducation.disallowEmptyValueError = 'Highest Level of Education is required.';



				if (fldName == 'undefined') fldName = null;
				if (stepid == 'undefined') stepid = null;

				var errors = getFormErrors(frm,fldName,stepid);

				if (errors.length > 0 && frm.isselectsubmit.value == 0) {
					var errorMessage = 'The form was not submitted due to the following problem' + ((errors.length > 1) ? 's' : '') + ':\n\n';
					for (var errorIndex = 1; errorIndex < errors.length; errorIndex++) {
						errorMessage += '* ' + errors[errorIndex] + '\n';
						if (errorIndex == 1) ;
					}
					errorMessage += '\nPlease fix ' + ((errors.length > 1) ? 'these' : 'this') + ' problem' + ((errors.length > 1) ? 's' : '') + ' and resubmit the form.';
					alert(errorMessage);

					frm.elements[errors[0]].focus();
					//frm.elements[errors[0]].select();
					return false;
				}
				else {
					return true;
				}
			
		}

		function changeCampusProgram() {
			var thisform = document.RequestInfoForm;
			var campus = thisform.bid.value;
				if (campus != '') {
					thisform.isselectsubmit.value=1;
					thisform.action='index.cfm?event=l.lp';
					thisform.submit();
				}
		}

		 /*to force a refresh regardless of bid field value use:*/
		/*
		function changeProgram() {
		var thisform = document.RequestInfoForm;
		thisform.isselectsubmit.value=1;
		thisform.action='index.cfm?event=l.lp';
		thisform.submit();
	}
		*/
