function init() {
	//disabled corporate fields if com_mailing_check cheked
	sameCorporateAndBusinessAddress();
	initBusinessTabFields();
	initProcessingTabFields();
}

function sameCorporateAndBusinessAddress() {
	var com_mailing_check = getElementById('com_mailing_check');
	changeStatusElement('com_corporate_name', com_mailing_check.checked);
	changeStatusElement('com_mailing_company_address', com_mailing_check.checked);
	changeStatusElement('com_mailing_company_city', com_mailing_check.checked);
	changeStatusElement('com_mailing_company_state', com_mailing_check.checked);
	changeStatusElement('com_mailing_company_zipcode', com_mailing_check.checked);
	changeStatusElement('com_mailing_phone_number', com_mailing_check.checked);
	changeStatusElement('com_mailing_fax_number', com_mailing_check.checked);
}

function initBusinessTabFields() {
	changeStatusBusSiteLevel();
	changeStatusBusSiteReturnPolicy();
	changeStatusBusSiteDeposit();
	changeStatusBusSiteLicense();
	changeStatusBusSiteNameDisplay();
	changeStatusBusSiteLeaveReason();
}

function initProcessingTabFields() {
	changeStatusCombox('proc_entitlement_discover', 'proc_entitlement_discover_mid', 'Y');
	changeStatusCombox('proc_entitlement_amex', 	'proc_entitlement_amex_mid', 'Y');
	changeStatusCombox('proc_entitlement_jcb', 		'proc_entitlement_jcb_mid', 'Y');
	changeStatusCombox('proc_entitlement_ebt_food', 'proc_entitlement_ebt_food_mid', 'Y');
	changeStatusCombox('proc_entitlement_ebt_cash', 'proc_entitlement_ebt_cash_mid', 'Y');	
	changeStatusCombox('proc_entitlement_other', 	'proc_entitlement_other_details', 'Y');	
}

function changeStatusBusSiteLevel() {
	changeStatusCombox('bus_site_occupy', 'bus_site_level_occupied', 'O');
}

function changeStatusBusSiteReturnPolicy() {
	changeStatusCombox('bus_site_return_policy', 'bus_area_site_refund_policy_details', 'O');
}

function changeStatusBusSiteDeposit() {
	changeStatusCombox('bus_site_deposit', 'bus_site_deposit_pct', 'Y');
}

function changeStatusBusSiteLicense() {
	changeStatusCombox('bus_site_license', 'bus_site_license_details', 'N');
}

function changeStatusBusSiteNameDisplay() {
	changeStatusCombox('bus_site_name_display', 'bus_site_name_display_explain', 'O');
}

function changeStatusBusSiteLeaveReason() {
	changeStatusCombox('bus_site_leave_reason', 'bus_site_leave_reason_detail', 'O');
}

function changeStatusCombox(comboxId, inputId, selectedItem) {
	var combox = getElementById(comboxId);
	var input = getElementById(inputId);
	if (combox.value != selectedItem) {
		input.disabled = true;
	} else {
		input.disabled = false;
	}
}

function getElementById(id) {
	var el = document.getElementById(id);
	return el;
}

function changeStatusElement(id, status) {
	var el = getElementById(id);
	el.disabled = (status) ? true : '';
}