	function InitAuthorizedAccessDlg ()
	{
		let ss = sessionStorage.getItem ( 'AuthorizedAccessDlgInitialized' );

		if ( ss == 'true' )
			return;
		
		sessionStorage.setItem ( 'AuthorizedAccessDlgInitialized', true );

		$(document).ready(function () 
		{
			GetAuthorizedAccess ();

			// switchLanguage ( eoDACS.CurrentLanguage );
		});
	}

	function GetAuthorizedAccessOK ( data )
	{
		let tmp = '';

		Object.entries(data).forEach(([id, site]) => {

		const checkIcon = site.checked === "1"
				? '<i class="fa-solid fa-check text-success"></i>'
				: '';

		tmp += '<li class="list-group-item">';
		tmp += 		'<div class="d-flex justify-content-between align-items-center">';
		tmp += 			'<span>'+site.name+'</span>';
		tmp += checkIcon;
		tmp += '</div>';
		tmp += '<ul class="ms-3 mt-2">';

		site.children.forEach ( dep => {
				const classe = dep.selected === "1" ? "okdep" : "kodep";
				tmp += '<li class="'+classe+'">'+dep.name+'</li>';
			});

			tmp += '</ul>';
			tmp += '</li>';
		});		

		let idcOl = document.getElementById ( 'IdcAuthorizedAccessOl' );

		idcOl.innerHTML = tmp;
		return;

	}

	function GetAuthorizedAccessError ( data )
	{
	}

	function GetAuthorizedAccess ()
	{
		let data = {};
		
		var request = $.ajax ({
        		url: 		eoDACS.ServerFolder+"/SubFW/database/GetAuthorizedAccess.php",
        		type: 		"post",
        		dataType: 	"json",
        		data: 		data
    			}
    	)
		.done ( GetAuthorizedAccessOK )
    	.fail ( GetAuthorizedAccessError );
	}