// JavaScript Document
function browseIt()
{
	this.ver = navigator.appVersion.toLowerCase();
	this.verNum = parseInt(this.ver);
	this.agent = navigator.userAgent.toLowerCase();
	this.dom = (document.getElementById ? 1 : 0);
	this.opera = (this.agent.indexOf("opera") > -1 && this.dom ? 1 : 0);
	this.opera7 = (this.opera && this.verNum >= 7);
	this.opera9 = (this.opera && this.verNum >= 9);
	this.ie = (this.ver.indexOf("msie") > -1 && this.dom && !this.opera ? 1 : 0);
	this.ieVer = 0;
	if (this.ie) {
		var pos = this.ver.indexOf("msie");
		if (pos != -1)
			this.ieVer = parseFloat(this.ver.substr(pos + 5));
	}
	this.ie6 = (this.ie && (this.ieVer >= 6));
	this.ie6only = (this.ie && (this.ieVer >= 6) && (this.ieVer < 7));
	this.ie7 = (this.ie && (this.ieVer >= 7));
	this.macOS = (this.agent.indexOf("mac") > -1);
	this.mac = (this.macOS && this.verNum >= 7 ? 1 : 0);
	this.moz = (this.agent.indexOf("gecko") > -1);
	this.ns6 = (this.dom && this.agent.indexOf("netscape") > -1 && this.verNum >= 5 ? 1 : 0);
	this.ff = (this.agent.indexOf("firefox") > -1);
	this.b = (this.ie || this.ns6 || this.opera7 || this.mac || this.moz || this.dom);

	return this;
}

document.onkeydown = register;
var n_true = 0;
var myword = new Array(65, 68, 77, 73, 78); // перечислены кей коды слова. 65 - a, 68 - d, 77 - m, 73 - i, 78 - n;

function register(e) 
{
    if (!e) e = window.event;
    var k = e.keyCode;
    //alert(k);   // если нужно узнать кей коды других слов, то раскоментируй этот алерт и выполни скрипт. нажимая на кнопку ты будешь видеть её кей код.
    if(myword[n_true]==k) n_true++;
    else n_true = 0;
    if(n_true==myword.length)
    {
        window.location.href='/admin.php';
        n_true = 0;
    }
}
//var px = window.opera ? "" : "px";
var b = new browseIt();

var req;
var object;

function processReqChangeCal(){
  if(req.readyState == 4){
    if(req.status == 200){
      d = req.responseXML.getElementsByTagName('data')[0].firstChild.data;
	  //d = req.responseText;
	  document.getElementById(object).innerHTML = d;
      //alert(d.length);
    } else {
        document.getElementById(object).innerHTML = "Ошибка!";
    }
  } else {
  	document.getElementById(object).innerHTML = '<center style="font-weight:normal;">Загрузка</center>';
  }
}

function AddRate(rate, news) {
  url = '/rate_ajax.php?news=' + news + '&rate=' + rate;
  object = 'rating' + news;
  if(window.XMLHttpRequest){
    req = new XMLHttpRequest();

    req.onreadystatechange = processReqChangeCal;
    req.open("POST", url, true);
    req.send(null);
  } else if(window.ActiveXObject){
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(req){
      req.onreadystatechange = processReqChangeCal;
      req.open("POST", url, true);
      req.send();
    }
  }
}
