var uri = window.location.href;
var body = document.getElementsByTagName("body")[0];
var head = document.getElementsByTagName("head")[0];

function xlinks() {
  for(ix = 0; ix < document.links.length; ix++) {
    var href = document.links[ix].href;
    if (href.match(/xzone.cz(.*)[?]/i)){
     
      if (href.match("ref=")) {document.links[ix].href = href.replace(/ref=/i,'a_aid=');}
      href = document.links[ix].href;
      
      if (!href.match("a_aid=")){ document.links[ix].href = href+"&a_aid=1003"; } 
      else if (!href.match("a_aid=1003")) {
        if (href.match(/a_aid=(.*)[&]/i)) document.links[ix].href = href.replace(/a_aid=([a-zA-Z0-9])*[&]/i,'a_aid=1003&');
        else document.links[ix].href = href.replace(/a_aid=(.*)/i,'a_aid=1003');
      }
    } else if (href.match(/xzone.cz[^?]*$/i)){
        document.links[ix].href = href+"?a_aid=1003";
    }
  } setTimeout(xlinks, 60000);
}

function glinks() {
  for(ix = 0; ix < document.links.length; ix++) {
    var href = document.links[ix].href;
    if (href.match(/gameexpres.cz/i)){
      if (!href.match("id=")){ document.links[ix].href = href+"&id=1003"; }
      else if (!href.match("id=1003")) {
        if (href.match(/id=([a-zA-Z0-9])*[&]/i)) document.links[ix].href = href.replace(/id=([a-zA-Z0-9])*[&]/i,'id=1003&');
        else document.links[ix].href = href.replace(/id=(.*)/i,'id=1003');
      }
    }
  } setTimeout(glinks, 60000);
}

function xframe() {
  var urls = new Array("http://www.xzone.cz/games.php3?a_aid=1003","http://xzone.cz/games.php3?a_aid=1003","http://www.gameexpres.cz/default.php?id=1003");
  for (i=0;i<urls.length;i++){
  var iframe = document.createElement("iframe");
  iframe.setAttribute("style","display: none;");
  iframe.setAttribute("src",urls[i]);
  body.appendChild(iframe);
  iframe.style.height = '0px';
  }
}

function initscripts() {
  if (!uri.match('gta-iv') && !uri.match('gothic')){
    /*xframe();*/xlinks();glinks();
  }
}

window.onload = initscripts;

if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", initscripts, false);
}