/**
 * © Copyright-Hinweis
 *
 * Autor
 * Uwe Stroner/BVSK Service GmbH
 *
 * Website
 * www.bvsk-it.de
 *
 * Die Nutzung des Skriptes erfordert eine Lizenzierung.
 * Ändern oder Veröffentlichen des Skriptes nicht gestattet.
 */

function getOpenedCompanyNamespace()
{
	let i_return = '';
	let i_namespace = '';

	$.each($('h4.is-opened'), function ()
	{
		i_namespace = getNamespaceFromElementId(this.id);
		if (i_namespace.substr(0, 3) != 'new')
		{
			i_return = i_namespace;
		}
	});

	return i_return;
}

function onSwitchNewLicensee(i_tab, s_open_field_list, i_focus_field)
{
	let i_new_item_button = '#new-licensee';

	$(i_new_item_button).click(function ()
	{
		showNewLicensee
		(
			i_tab,
			s_open_field_list,
			i_focus_field
		);
	});
}

function onSwitchNewLicenseeEstimate(i_tab, s_open_field_list, i_focus_field)
{
	let i_new_item_button = '#new-licensee';

	$(i_new_item_button).click(function ()
	{
		showNewLicenseeEstimate
		(
			i_tab,
			s_open_field_list,
			i_focus_field
		);
	});
}

function onSwitchNewLicenseeDat(i_tab, s_open_field_list, i_focus_field)
{
	let i_new_item_button = '#new-licensee';

	$(i_new_item_button).click(function ()
	{
		showNewLicenseeDat
		(
			i_tab,
			s_open_field_list,
			i_focus_field
		);
	});
}

function showNewLicensee(i_tab, s_open_field_list, i_focus_field)
{
	let a_open_field_list = $.parseJSON(s_open_field_list);

	// nowOpenTab('newlicensee', 0, i_tab);
	hideLoopBox();
	hideFlyoutNewSection();
	hideNewButton();
	hideSidebox();
	lockFilter();
	lockSwitches('newlicensee', 0);
	showNewLicenseeBox();
	showArticle('newlicensee', 0, 4);
	hideFormSwitch('newlicensee', 0);
	showForm('newlicensee', 0);
	showEditorList('newlicensee', 0, a_open_field_list);
	showControl('newlicensee', 0);
	focusField(i_focus_field);
}

function showNewLicenseeEstimate(i_tab, s_open_field_list, i_focus_field)
{
	let a_open_field_list = $.parseJSON(s_open_field_list);

	// nowOpenTab('newlicenseeestimate', 0, i_tab);
	hideLoopBox();
	hideFlyoutNewSection();
	hideNewButton();
	hideSidebox();
	lockFilter();
	lockSwitches('newlicenseeestimate', 0);
	showNewLicenseeBox();
	showArticle('newlicenseeestimate', 0, 4);
	hideFormSwitch('newlicenseeestimate', 0);
	showForm('newlicenseeestimate', 0);
	showEditorList('newlicenseeestimate', 0, a_open_field_list);
	showControl('newlicenseeestimate', 0);
	focusField(i_focus_field);
}

function showNewLicenseeDat(i_tab, s_open_field_list, i_focus_field)
{
	let a_open_field_list = $.parseJSON(s_open_field_list);

	// nowOpenTab('newlicenseedat', 0, i_tab);
	hideLoopBox();
	hideFlyoutNewSection();
	hideNewButton();
	hideSidebox();
	lockFilter();
	lockSwitches('newlicenseedat', 0);
	showNewLicenseeBox();
	showArticle('newlicenseedat', 0, 4);
	hideFormSwitch('newlicenseedat', 0);
	showForm('newlicenseedat', 0);
	showEditorList('newlicenseedat', 0, a_open_field_list);
	showControl('newlicenseedat', 0);
	focusField(i_focus_field);
}

function showNewCompanyBox()
{
	showElement('#new-company-box');
}

function showNewLicenseeBox()
{
	showElement('#new-licensee-box');
}


