<?php

use Bitrix\Main\Application;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Config\Option;

require_once('classes/Loader.php');

Loc::loadMessages(__FILE__);

class IntecRegionality
{
    protected static $MODULE_ID = 'intec.regionality';
    protected static $MODULE_STATE = 0;

    public static function Initialize()
    {
        static::$MODULE_STATE = CModule::IncludeModuleEx(static::$MODULE_ID);
        static::Validate();
    }

    protected static function Validate()
    {
        if (static::$MODULE_STATE != 1 && static::$MODULE_STATE != 2)
            die(Loc::getMessage('intec.regionality.demo', ['#MODULE_ID#' => static::$MODULE_ID]));
    }

    public static function CrossSiteUse($value = null)
    {
        $name = 'crossSiteUse';

        if ($value === null)
            return Option::get(
                static::$MODULE_ID,
                $name,
                0,
                false
            ) == 1;

        Option::set(
            static::$MODULE_ID,
            $name,
            $value ? 1 : 0,
            false
        );

        return true;
    }
}

?>