function show_metadata_file_upload(file_field_id)
{
	var file_upload_element = jQuery('#metadata_file_upload_'+file_field_id);

	if (file_upload_element.hasClass('d-none'))
	{
		popup_wrap_window(file_upload_element);
		file_upload_element.removeClass('d-none');
		jQuery('#metadata_file_upload_div_'+file_field_id).html('<iframe src="/intranet/common/metadata_file.php?action=upload&element='+file_field_id+'" frameborder="0" style="border: 0px solid #fff; width: 100%; height: 180px;" scrolling="no"></iframe>');
	} else
	{
		file_upload_element.addClass('d-none');
	}
}

function set_metadata_uploaded_file(file_field_id, file_id, file_title)
{
	var input_element = document.getElementById(file_field_id);
	if (!input_element)
		alert("Internal error, unable to put uploaded file");
	var input_element2 = document.getElementById(file_field_id + '_id');
	if (!input_element2)
		alert("Internal error, unable to put uploaded file");

	input_element.value = file_title;
	input_element2.value = file_id;
}

jQuery(function(){
	popup_wrap_window(jQuery('#metadata_file_upload'));
	jQuery('.js-file-upload').on('click', '.js-rmv-file', function(e) {
		e.preventDefault;
		jQuery(this).siblings('.js-file-name, .js-file-id').val('');
		return false;
	})
});
