function $(id){
	return document.getElementById(id);
}
function Disabled(m,i){
  $(i).disabled=m;
}
function GetAnim(){
  var nDiv=document.createElement('DIV');
  nDiv.style.width=document.body.scrollWidth;
  nDiv.style.height=document.body.scrollHeight;
  nDiv.style.position='absolute';
  nDiv.style.top='0px';
  nDiv.style.left='0px';
  nDiv.style.textAlign='center';
  nDiv.innerHTML='<img src="themes/'+Theme+'/image/load.png" style="margin-top:'+(document.body.offsetHeight/2-10)+'px;">';
  document.body.appendChild(nDiv);
  return nDiv;
}
function Ajax(){
	function Init(){
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){}
		try{
			return new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){}
		try{
			return new XMLHttpRequest();
		}catch(e){}
	return null;
}
	var ajax=Init();
	var onready;
	var onerror;
	var anim;
	return {
		POST:function(){
			ajax.open('POST',this.URI);
			onready=this.ONREADY;
			onerror=this.ONERROR;
			if(onready){
        anim=GetAnim();
				ajax.onreadystatechange=function(){
					if(ajax.readyState==4){
						if(ajax.status>200){
							if(onerror){
								onerror(ajax.status);
							}
						}else{
							onready(ajax.responseText);
							document.body.removeChild(anim);
						}
					}
				}
			}
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.send(this.REQUEST ? this.REQUEST : null);
		},
		GET:function(){
		ajax.open('GET',this.URI);
		onready=this.ONREADY;
		onerror=this.ONERROR;
		if(onready){
      anim=GetAnim();
			ajax.onreadystatechange=function(){
				if(ajax.readyState==4){
					if(ajax.status>200){
						if(onerror){
							onerror(ajax.status);
						}
					}else{
						onready(ajax.responseText);
						document.body.removeChild(anim);
					}
				}
			}
		}
		ajax.send(null);
		}
	}
}
function RAntiBot(){
  var aimg=document.getElementsByTagName('IMG');
  for(var i=0;i<aimg.length;i++){
    if(aimg[i].getAttribute('src').match('AntiBot')){
      aimg[i].src='?act2=AntiBot&rnd='+Math.ceil(Math.random()*20000);
      break;
    }
  }
}
function LAuth(){
  var ajax=new Ajax();
  ajax.URI='?act2=Loging';
  ajax.REQUEST='ALogin='+encodeURIComponent($('ALogin').value)+'&APass='+encodeURIComponent($('APass').value)+($('AMem').checked ? '&AMem=true' : '');
  ajax.ONREADY=function(text){
    if(text=='Ok'){
      location.reload();
    }else{
      $('ANotif').innerHTML='Ошибка, логин или пароль неверен';
    }
  }
  ajax.POST();
}
function Voting(){
  var AVItem=document.getElementsByTagName('input');
  for(var i=0;i<AVItem.length;i++){
    if(AVItem[i].getAttribute('type')=='radio' && AVItem[i].getAttribute('name')=='voting'){
      if(AVItem[i].checked){
        var ajax=new Ajax();
        ajax.URI='?act2=Voting';
        ajax.REQUEST='vitem='+AVItem[i].getAttribute('value');
        ajax.ONREADY=VResult;
        ajax.POST();
        break;
      }
    }
  }
}
function VResult(){
  var ajax=new Ajax();
  ajax.URI='?act2=VotingResult';
  ajax.ONREADY=function(text){
    $('IVoting').innerHTML=text;
  }
  ajax.GET();
}