﻿window.matchMedia = window.matchMedia ||
function (a, b) {
    var c, d = a.documentElement,
        e = d.firstElementChild || d.firstChild,
        f = a.createElement("body"),
        g = a.createElement("div");
    g.id = "mq-test-1";
    g.style.cssText = "position:absolute;top:-100em";
    f.appendChild(g);
    return function (a) {
        g.innerHTML = '­<style media="' + a + '"> #mq-test-1 { width: 42px; }</style>';
        d.insertBefore(f, e);
        c = g.offsetWidth == 42;
        d.removeChild(f);
        return {
            matches: c,
            media: a
        }
    }
}(document)

window.matchMediaMobile = window.matchMediaMobile ||
function (a, b) {
    var c, d = a.documentElement,
        e = d.firstElementChild || d.firstChild,
        f = a.createElement("body"),
        g = a.createElement("div");
    g.id = "mq-test-1";
    g.style.cssText = "position:absolute;top:-100em";
    f.appendChild(g);
    return function (a) {
        g.innerHTML = '­<style media="' + a + '"> #mq-test-1 { width: 42px; }</style>';
        d.insertBefore(f, e);
        c = g.offsetWidth == 42;
        d.removeChild(f);
        return {
            matches: c,
            media: a
        }
    }
}(document)
