//use global "errors2" string (from validation.js) to report cross-field errors

function initefc(f) {

    f.Student_age.required = true;
    f.Student_age.numeric = true;
    f.Student_age.min = 13;
    f.Student_age.max = 23;
    f.Student_age.label = "Age of This College Student";

    f.Number_parents.required = true;
    f.Number_parents.numeric = true;
    f.Number_parents.min = 1;
    f.Number_parents.max = 2;
    f.Number_parents.Number_parents = true;
    f.Number_parents.label = "Number of Parents";

    f.Family_size.required = true;
    f.Family_size.numeric = true;
    f.Family_size.min = 2;
    f.Family_size.max = 11;
    f.Family_size.label = "Family Size";

    f.Age_older.optional = true;
    f.Age_older.minage = 21;
    f.Age_older.maxage = 100;
    f.Age_older.label = "Age of Older Parent";

    f.Family_members.required = true;
    f.Family_members.numeric = true;
    f.Family_members.min = 1;
    f.Family_members.max = 10;
    f.Family_members.label = "Family Members in College";

    f.Tax_form.required = true;

    f.Tax_adj_gross_income.required = true;
    f.Tax_adj_gross_income.numeric = true;
    f.Tax_adj_gross_income.min = 0; 
    f.Tax_adj_gross_income.max = 10000000;
    f.Tax_adj_gross_income.label = "Parent Adjusted Gross Income";

    f.Tax_paid.required = true;
    f.Tax_paid.numeric = true;
    f.Tax_paid.min = 0; 
    f.Tax_paid.max = 1000000;
    f.Tax_paid.label = "Parent Total Federal Income Tax";

    f.Income_work_A.optional = true;
    f.Income_work_A.numeric = true;
    f.Income_work_A.min = 0; 
    f.Income_work_A.max = 5000000;
    f.Income_work_A.label = "Income from Work Parent 1";

    f.Income_work_B.optional = true;
    f.Income_work_B.numeric = true;
    f.Income_work_B.min = 0; 
    f.Income_work_B.max = 5000000;
    f.Income_work_B.label = "Income from Work Parent 2";

    f.Untaxed_income.optional = true;
    f.Untaxed_income.numeric = true;
    f.Untaxed_income.min = 0;
    f.Untaxed_income.max = 5000000;
    f.Untaxed_income.label = "Parent Untaxed Income and Benefits";

    f.Other_Adj.optional = true;
    f.Other_Adj.numeric = true;
    f.Other_Adj.min = 0;
    f.Other_Adj.label = "Other Adjustments";

    f.Business_equity.optional = true;
    f.Business_equity.numeric = true;
    f.Business_equity.min = 0;
    f.Business_equity.label = "Parent Net Value of Business";

    f.Investment_total.optional = true;
    f.Investment_total.numeric = true;
    f.Investment_total.min = 0;
    f.Investment_total.max = 5000000;
    f.Investment_total.label = "Parent Cash and Investments";

    f.Student_name.optional = true;
    f.Student_name.numeric = false;

    f.Student_adj_gross_income.numeric = true;
    f.Student_adj_gross_income.required = true;
    f.Student_adj_gross_income.min = 0;
    f.Student_adj_gross_income.label = "Student Adjusted Gross Income";

    f.Student_tax_paid.numeric = true;
    f.Student_tax_paid.optional = true;
    f.Student_tax_paid.min = 0;
    f.Student_tax_paid.label = "Student Total Federal Tax";

    f.Student_income_work.numeric = true;
    f.Student_income_work.optional = true;
    f.Student_income_work.min = 0;
    f.Student_income_work.label = "Student Income from Work";

    f.Student_other_income.numeric = true;
    f.Student_other_income.optional = true;
    f.Student_other_income.min = 0;
    f.Student_other_income.max = 5000000;
    f.Student_other_income.label = "Student Untaxed Income and Benefits";

    f.Student_Other_Adj.numeric = true;
    f.Student_Other_Adj.optional = true;
    f.Student_Other_Adj.min = 0;
    f.Student_Other_Adj.max = 5000000;
    f.Student_Other_Adj.label = "Student Other Adjustments";

    f.Student_investment_total.numeric = true;
    f.Student_investment_total.optional = true;
    f.Student_investment_total.min = 0;
    f.Student_investment_total.max = 5000000;
    f.Student_investment_total.label = "Student Cash and Investments";

    var n = 0;
    errors2 = "";
    warnings2 = "";

    if (isblank(f.Student_name.value)) {
	f.Student_name.value = "Student";
    }

	//perform multi-field validations
    if (getval(f.Tax_form) != "Non-filer" && iszero(f.Tax_adj_gross_income)) {
	errors2 += fldname(f.Tax_adj_gross_income) + " must be > 0.\n";
    }

    if (getval(f.Tax_paid) >= getval(f.Tax_adj_gross_income)
	    && (getval(f.Tax_paid) > 0 && getval(f.Tax_adj_gross_income) > 0)) {
	errors2 += fldname(f.Tax_paid)
	    + " must be less than "
	    + fldname(f.Tax_adj_gross_income) + ".\n";
    }

    if ((getval(f.Student_tax_paid) >= getval(f.Student_adj_gross_income))
	    && (getval(f.Student_tax_paid) > 0 && getval(f.Student_adj_gross_income) > 0)) {
	errors2 += fldname(f.Student_tax_paid)
	    + " must be less than "
	    + fldname(f.Student_adj_gross_income)
	    + ".\n";
    }
    if (getval(f.Family_size) < getval(f.Number_parents) + 1) {
	errors2 += fldname(f.Family_size) + " must be greater than " + fldname(f.Number_parents) + ".\n";
    }
    
    if (getval(f.Family_members) > getval(f.Family_size) - getval(f.Number_parents)) {
	errors2 += fldname(f.Family_members) + " in college cannot be greater than " + fldname(f.Family_size)
	    + " minus " + fldname(f.Number_parents) + ".\n";
    }

    if (! f.edchecked_1.checked && ! f.edchecked_2.checked && ! f.edchecked_3.checked
	    && ! f.edchecked_4.checked && ! f.edchecked_5.checked) {
	errors2 += "Please select at least one College Cost type.\n";
    }

} //initefc

