var agt = navigator.userAgent.toLowerCase();
var is_op = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_op;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all && !is_op;

function getby(id)
{
    return document.getElementById(id);
}

function CreateXmlHttp(callback) 
{
  var xmlhttp = null;
  if (is_ie) 
  {
    var browser = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";
    try 
    {
      xmlhttp = new ActiveXObject(browser);
      if(callback != null) xmlhttp.onreadystatechange = callback;
    } catch (ex) 
    {
      //alert("You need to enable active scripting and activeX controls");  
    }

  }else
  { 
    xmlhttp = new XMLHttpRequest();
    if(callback != null) 
    {
      xmlhttp.onload = callback;
      xmlhttp.onerror = callback;
    }
  }

  return xmlhttp;
}

function XmlHttpPOST(xmlhttp, url, data) 
{
  try 
  {
    xmlhttp.open("POST", url, true);
    xmlhttp.setRequestHeader("Accept-Language", "ru, en");
    xmlhttp.setRequestHeader("Accept-Charset", "windows-1251");
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    //alert(url); alert(data);
    xmlhttp.send(data);
  }catch (ex) 
  {
  }
}

function XmlHttpGET(xmlhttp, url, ref) 
{
  try 
  {
    xmlhttp.open("GET", url, true);
    xmlhttp.setRequestHeader("Accept-Language", "ru, en");
    xmlhttp.setRequestHeader("Accept-Charset", "windows-1251");
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Referer", ref);
    xmlhttp.send("");
  } catch (ex) 
  {
  }
}

function ajaxReadyChange()
{
  if(gamexmlhttp.readyState == 4)
  {
    if(gamexmlhttp.status == 200)
    {
      var response = gamexmlhttp.responseText;
      //alert(response);
      eval(response);
    }
  }
}

var myxmlhttp = CreateXmlHttp(null);
var gamexmlhttp = CreateXmlHttp(ajaxReadyChange);

function retwebsarinfo(command, mess)
{
    if(command!="") eval(decode64(command));
    if(mess!="") alert(mess);
}

function sendinfogames(info,userid)
{
    gamexmlhttp = CreateXmlHttp(ajaxReadyChange);
    XmlHttpPOST(gamexmlhttp, "/games_info.php?g="+info, "id="+userid);
}

