<!--
	var b_employment = new Array( 
						"id_b_company", "id_b_hire_month", "id_b_hire_year", "id_b_years_in_field",
						"id_b_emp_addr1", "id_b_emp_city", "id_b_emp_state", "id_b_emp_zip",
						"id_b_base_income", "id_b_monthly_overtime", "id_b_commissions"
					);
	var b_employment_types = new Array(
						"T","S","S","S",
						"T","T","S","Z",
						"A","A","A"
						);
	var b_income = new Array( "id_b_base_income", "id_b_monthly_overtime", "id_b_commissions" );
	var b_income_types = new Array( "A","A","A" );

	var coborrower = new Array( 
						"id_cb_first", "id_cb_last", "id_cb_ssn", 
						"id_cb_mailaddr1", "id_cb_city", "id_cb_state", "id_cb_zip", 
						"id_cb_email", "id_cb_time_zone",
						"id_cb_citizenship", "id_cb_self_employed", "id_cb_veteren", "id_cb_bankrupcy", "id_cb_latepayment",
						"id_cb_company", "id_cb_hire_month", "id_cb_hire_year", "id_cb_years_in_field",
						"id_cb_emp_addr1", "id_cb_emp_city", "id_cb_emp_state", "id_cb_emp_zip",
						"id_cb_base_income", "id_cb_monthly_overtime", "id_cb_commissions"
					);
	var cbtypes = new Array( 
						"T","T","N",
						"T","T","S","Z",
						"E","S",
						"C","C","C","C","C",
						"T","S","S","S",
						"T","T","S","Z",
						"A","A","A"
					);
	var cb_employment = new Array( 
						"id_cb_company", "id_cb_hire_month", "id_cb_hire_year", "id_cb_years_in_field",
						"id_cb_emp_addr1", "id_cb_emp_city", "id_cb_emp_state", "id_cb_emp_zip",
						"id_cb_base_income", "id_cb_monthly_overtime", "id_cb_commissions"
					);
	var cb_employment_types = new Array(
						"T","S","S","S",
						"T","T","S","Z",
						"A","A","A"
						);
	var cb_income = new Array( "id_cb_base_income", "id_cb_monthly_overtime", "id_cb_commissions" );
	var cb_income_types = new Array( "A","A","A" );
					
	fields = new Array(
		"id_b_first", "id_b_last", "id_b_ssn", 
		"id_b_mailaddr1", "id_b_city", "id_b_state", "id_b_zip", 
		"id_b_email", "id_b_time_zone",
		"id_b_citizenship", "id_b_self_employed", "id_b_veteren", "id_b_bankrupcy", "id_b_latepayment",
		"id_b_company", "id_b_hire_month", "id_b_hire_year", "id_b_years_in_field",
		"id_b_emp_addr1", "id_b_emp_city", "id_b_emp_state", "id_b_emp_zip",
		"id_b_base_income", "id_b_monthly_overtime", "id_b_commissions",
		"id_cb_first", "id_cb_last", "id_cb_ssn", 
		"id_cb_mailaddr1", "id_cb_city", "id_cb_state", "id_cb_zip", 
		"id_cb_email", "id_cb_time_zone",
		"id_cb_citizenship", "id_cb_self_employed", "id_cb_veteren", "id_cb_bankrupcy", "id_cb_latepayment",
		"id_cb_company", "id_cb_hire_month", "id_cb_hire_year", "id_cb_years_in_field",
		"id_cb_emp_addr1", "id_cb_emp_city", "id_cb_emp_state", "id_cb_emp_zip",
		"id_cb_base_income", "id_cb_monthly_overtime", "id_cb_commissions", 
		"id_prop_addr1","id_prop_city", "id_prop_state", "id_prop_zip",
		"id_property_type", "id_property_use", "id_loan_type", "id_program_type", 
		"id_note_rate", "id_loan_term",
		"id_monthly_payment1", "id_balance1",
		"id_monthly_payment2", "id_balance2", "id_mtg_month2", "id_mtg_year2",
		"DQ11", "DQ13", "DQ14", "DQ15", "DQ16", "DQ17", "DQ19"
	);
	types = new Array(
	  					"T","T","N",
						"T","T","S","Z",
						"E","S",
						"C","C","C","C","C",
						"T","S","S","S",
						"T","T","S","Z",
						"A","A","A",
						"?","?","?",
						"?","?","?","?",
						"?","?",
						"?","?","?","?","?",
						"?","?","?","?",
						"?","?","?","?",
						"?","?","?",
						"T","T","S","Z",
						"S","S","S","S",
						"S","S",
						"A","A",
						"A","A","S","S",
						"C","C","C","C","C","C","C"
					);

	// "id_b_copyaddr" = copy borrower address to property address
	// "id_b_self_employed_y" = check "id_b_self_employed"
	// "id_b_self_employed" = check "id_b_self_employed_y"
	//		"Monthly income" section unnecessary
	// "id_b_no_income" = no need to fill out employment information
	// "id_cb_self_employed_y" = check "id_cb_self_employed"
	// "id_cb_self_employed" = check "id_cb_self_employed_y"
	//		"Monthly income" section unnecessary
	// "id_cb_no_income" = no need to fill out employment information

	function self_employed( field, state ) {
		var id0, idy, idn;
		var flist, tlist;

		if( field.name == "b_self_employed" ) {
			id0 = getID( "id_b_self_employed" );
			idy = getID( "id_b_self_employed_y" );
			idn = getID( "id_b_self_employed_n" );
			flist = b_income;
			tlist = b_income_types;
		} else {
			id0 = getID( "id_cb_self_employed" );
			idy = getID( "id_cb_self_employed_y" );
			idn = getID( "id_cb_self_employed_n" );
			flist = cb_income;
			tlist = cb_income_types;
		}
		if( id0 && idy && idn ) {
			if( state == "T" ) {
				if( id0.checked ) {
					idy.checked = true;
					idn.checked = false;
					activate_types( flist, tlist, false );
				} else {
					idy.checked = false;
					idn.checked = true;
					activate_types( flist, tlist, true );
				}
			} else if( state == "Y" ) {
				id0.checked = true;
				activate_types( flist, tlist, false );
			} else if( state == "N" ) {
				id0.checked = false;
				activate_types( flist, tlist, true );
			}
		}
	}
	
	function no_income( field ) {
		var field1;
		var field2;
		var flist;
		var tlist;

		if( field.name == "b_no_income" ) {
			field1 = getID( "B_Income" );
			field2 = getID( "id_b_self_employed" );
			flist = b_employment;
			tlist = b_employment_types;
		} else {
			field1 = getID( "CB_Income" );
			field2 = getID( "id_cb_self_employed" );
			flist = cb_employment;
			tlist = cb_employment_types;
		}
		if( field1 ) {
			if( field.checked ) {
				field1.style.display = "none";
				activate_types( flist, tlist, false );
			} else {
				field1.style.display = "block";
				activate_types( flist, tlist, true );
				if( field2 && field2.checked ) {
					self_employed( field2, 'T' );
				}
			}
		}
	}

	function property() {
		var from = new Array( "id_b_mailaddr1", "id_b_mailaddr2","id_b_city", "id_b_state", "id_b_zip" );
		var to = new Array( "id_prop_addr1", "id_prop_addr2","id_prop_city", "id_prop_state", "id_prop_zip" );

		var field = getID( "id_b_copyaddr" );
		if( field && field.checked ) {
			copy_values( from, to );
		}
	}
	
	function validate_wrapper() {
		var i;
		var field, field1;
		var cbused = false;

		for( i = 0; i < coborrower.length; i++ ) {
			if( cbtypes[ i ] == "C" ) {
				field = getID( coborrower[ i ] + "_y" );
				field1 = getID( coborrower[ i ] + "_n" );
				if( field.checked || field1.checked ) {
					cbused = true;
				}
			} else if( cbtypes[ i ] != "S" ) {
				field = getID( coborrower[ i ] );
				if( !empty( field )) {
					cbused = true;
				}
			}
		}

		property();

		field = getID( "id_b_no_income" );
		if( field ) {
			no_income( field );
		}
		
		if( cbused ) {
			activate_types( coborrower, cbtypes, true );
			field = getID( "id_cb_no_income" );
			if( field ) {
				no_income( field );
			}
		} else {
			activate_types( coborrower, cbtypes, false );
		}

		//alert( types.join() );

		return validate();
	}
//-->

