{
	$fatalFailure = false;

	#####################################
	#### ACTIONS
	#####################################

	$actionFailure = false;

	$id = intval($_REQUEST['id']) ? intval($_REQUEST['id']) : false;
	$copyId = intval($_REQUEST['copy_id']) ? intval($_REQUEST['copy_id']) : false;

	// the following parameter will be present visibly only when copying or creating blank with the same parent
	$parentId = intval($_REQUEST['parent_id']) ? intval($_REQUEST['parent_id']) : '0';
	if(!$parentId && $id)
		$parentId = Helper::getParentId($id);

	$actionSave = isset($_REQUEST['save']);
	$actionApply = isset($_REQUEST['apply']);
	$actionSaveAndAdd = isset($_REQUEST['save_and_add']);
	
	$formSubmitted = ($actionSave || $actionApply || $actionSaveAndAdd) && check_bitrix_sessid();

	$returnUrl = strlen($_REQUEST['return_url']) ? $_REQUEST['return_url'] : '0';

	if($userIsAdmin && !empty($_REQUEST['element']) && $formSubmitted) // form submitted, handling it
	{
		$saveAsId = intval($_REQUEST['element']['ID']);

		global $DB;
		$redirectUrl = false;