GLOBAL = {}

GLOBAL.isMobile = typeof window.onTouchEnd !== "undefined";

GLOBAL.tap = GLOBAL.isMobile ? "tap" : "click";

$(function () {
    var header = $("#header")
    var headerHeight = header.height()
    var wrapProduct = $(".wrap-fix-product")
    var wrapHeader = $(".wrap-fix-header")
    if (wrapHeader.size() > 0) {
        wrapHeader.height(document.documentElement.clientHeight - wrapHeader.offset().top)
    }
    if (wrapProduct.size() > 0) {
        var wrapProductHeight = document.documentElement.clientHeight - wrapProduct.offset().top
        wrapProduct.height(wrapProductHeight)
        wrapProduct.scroll(function () {
            var height = $(this).scrollTop()
            header.css({
                marginTop: -Math.min(headerHeight, height)
            })
            $(this).height(wrapProductHeight + Math.min(headerHeight, height))
        })
    }
    var withDataHeader = $(".withData")
    if (withDataHeader.size() > 0) {
        withDataHeader.on(GLOBAL.tap, function () {
            if ($(this).hasClass("active")) {
                $(this).removeClass("active")
                $(".relateData").removeClass("show")
            } else {
                $(this).addClass("active")
                $(".relateData").addClass("show")
            }
        })
    }
})