$(function () {

    TOP_COMMON.gtag();

    TOP_COMMON.fixedFooter();

    setTopModelLink();

    /**
     * Model page (EOS R8) Set the link.
     *
     */
    function setTopModelLink() {
        $.getJSON("../../json/top_model12.json", function (data) {
            TOP_COMMON.linkData = data;
            setTopModelCountryData();
        });
    }

    /**
     * Set country
     *
     */
    function setTopModelCountryData() {
        $.getJSON("../../json/country.json", function (data) {
            TOP_COMMON.countryData = data;
            setTopModelLanguageData();
        });
    }

    /**
     * Set the language.
     *
     */
    function setTopModelLanguageData() {
        $.getJSON("../../json/language.json", function (data) {
            TOP_COMMON.languageData = data;
            setTopModelURL();
        });
    }

    /**
     * Set the URL of the model page (EOS R8).
     *
     */
    function setTopModelURL() {
        TOP_COMMON.currentPath = TOP_COMMON.constants.MODEL11_URL;
        TOP_COMMON.init();
        setGAEvent();
    }

    /**
     * Set up google analytics tracking for PDF links.
     *
     */
    function setGAEvent() {
        if(TOP_COMMON.cookie.get("user_accepts_cookies") == "true") {

            $('#item_UserManual_PDF').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'productPagePDF', {
                    'event_category' : 'pdf',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_CC_apple').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'CC_apple',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_CC_google').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'CC_google',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_MFT_apple').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'MFT_apple',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_MFT_google').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'MFT_google',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_DPPEx_apple').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'DPPEx_apple',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_DPPEx_google').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'DPPEx_google',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_PTZ_apple').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'PTZ_apple',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#App_PTZ_google').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'mobilestore', {
                    'event_category' : 'PTZ_google',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#sas_induction_NnIPT').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'sas_induction', {
                    'event_category' : 'NnIPT',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });

            $('#sas_induction_NnUPST').on('click', function() {
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments)};
                gtag('js', new Date());
                gtag('event', 'sas_induction', {
                    'event_category' : 'NnUPST',
                    'event_label' : location.href,
                    'value' : '1'
                });
            });
        }
    }
});