function loadXMLDoc(ajax_page,put_vars,caching){
var url="/index_ajax.php?ajax_page="+ajax_page;
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){
if(req.responseJS){
for(var id in req.responseJS){
if(document.getElementById(id)){
document.getElementById(id).innerHTML=req.responseJS[id];
}}}
if(typeof(AJAX_DEBUG)=='boolean'&&AJAX_DEBUG==true){
if(req.responseText){
var divDBG=document.getElementById('ajax-debug');
if(!divDBG){
divDBG=document.createElement("div");
divDBG.id="ajax-debug";
divDBG.style.position="absolute";
divDBG.style.overflown="hidden";
divDBG.style.left=0+"px";
divDBG.style.top=0+"px";
divDBG.style.top=0+"px";
divDBG.style.backgroundColor="White";
divDBG.style.margin="10px";
divDBG.style.padding="4px";
divDBG.style.border="3px dashed red";
document.body.appendChild(divDBG);
}
if(divDBG){
divDBG.innerHTML=req.responseText;
}}}}}
if(typeof(caching)!='boolean')caching=true;
req.caching=caching;req.open('POST',url,true);
req.send(put_vars);
}

function hashFormFields(of){
var hsh=new Object();
for(var i=0;i<of.length;i++){
var sb=of[i].name;
if(!(/submit/i.test(of[i].type))){
if((/radio/i.test(of[i].type))){
if(of[i].checked){hsh[sb]=of[i].value;
}}else{
hsh[sb]=of[i].value;
}}}return hsh;
}

function clearFormFields(of,val){
var val=val||0;for(var i=0;i<of.length;i++){
var sb=of[i].name;
if(!(/submit/i.test(of[i].type))&&!(/hidden/i.test(of[i].type))){
if((/checkbox/i.test(of[i].type))){
if(of[i].checked){
of[i].checked=false;
}}else{
of[i].value=val;
}}}
return false;
}

function Favorites(id,action){
var url="/index_ajax.php?ajax_page=favorites";
var v=new Array();
v["id"]=id;
v["action"]=action;
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){window.location.reload();
}
}

if(typeof(caching)!='boolean')caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}


function Mystatusbook(id,status){
var url="/index_ajax.php?ajax_page=mystatusbook";
//if(user=='off') alert('Необходимо зарегистрироваться.');
//alert(status);

var v=new Array();
v["id"]=id;
v["status"]=status;
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){
document.getElementById('test').innerHTML=req.responseText;
//alert('!!!');
}
}

if(typeof(caching)!='boolean') caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function dellist(id,action){var url="/index_ajax.php?ajax_page=dellist";var f=new Array();f["id"]=id;f["action"]=action;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){window.location.reload();}}
if(typeof(caching)!='boolean')caching=true;req.caching=caching;req.open('POST',url,true);req.send(f);return false;}function doRating(id,vote,user,ip,litera){var url="/index_ajax.php?ajax_page=rating";var vs=new Array();vs["id"]=id;vs["vote"]=vote;vs["user"]=user;vs["ip"]=ip;vs["litera"]=litera;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){window.location.reload();}}
if(typeof(caching)!='boolean')caching=true;req.caching=caching;req.open('POST',url,true);req.send(vs);return false;}function ShowOrHide(id){var block=document.getElementById(id);var style=window.getComputedStyle(block,"");block.style.display=(style.display=='none')?'block':'none';}

function CheckReg(action,value){
var url="/index_ajax.php?ajax_page=register";
var v=new Array();
v["value"]=value;
v["action"]=action;
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){document.getElementById(action+"_st").innerHTML=req.responseText;}
}
if(typeof(caching)!='boolean')caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function edituser(action,group,nick,id,status,day){
var url="/index_ajax.php?ajax_page=edituser";
var v=new Array();
v["action"]=action;
v["group"]=group;
v["nick"]=nick;
v["id"]=id;
v["status"]=status;
v["day"]=day;

var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){document.getElementById('reply').innerHTML=req.responseText;}
}
if(typeof(caching)!='boolean')caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function info(action,date){var url="/index_ajax.php?ajax_page=info";var c=new Array();c["action"]=action;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){document.getElementById(action+"_st").innerHTML=req.responseText;if(date=='out')document.getElementById(action+"_st").innerHTML="";}}
req.open('POST',url,true);req.send(c);return false;}
function EnableButton(r){
var form=document.getElementById('senduwaga');
if(r=="nick"){
if(document.res.login.value!=""&&document.res.passw.value!=""){
document.res.butt.disabled=false;
}
}
if(r=="fl"){
document.files.butt.disabled=false;
document.files.butt2.disabled=false;
}
if(form.elements[r].checked==true){
form.txtarea.disabled=false;
form.butt.disabled=false;
}
}
function confirmD(){form=document.getElementById("senduwaga");if(form.bot.checked==false){alert('Поставьте галку, что Вы не бот');return false;}}function addComment(){var url="/index_ajax.php?ajax_page=addcomment";form=document.getElementById("addcomm");var comm=new Array();var text=CKEDITOR.instances.editor.getData();comm["id"]=form.bookid.value;comm["comment"]=text;comm["nick"]=form.nick.value;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){document.getElementById("reply").innerHTML=req.responseText;CKEDITOR.instances.editor.updateElement();CKEDITOR.instances.editor.setData('');}}
req.open('POST',url,true);req.send(comm);}function toNick(a){CKEDITOR.instances.editor.setData('<p><b>To '+a+'</b></p>');}function cetera(){if(window.getSelection){txt=window.getSelection().toString();}else if(document.getSelection){txt=document.getSelection();}else if(document.selection){txt=document.selection.createRange().text;}CKEDITOR.instances.editor.setData('<p><blockquote><b>quote:</b><br><em>'+txt+'</em><blockquote></p>');}function editComments(action,id){var url="/index_ajax.php?ajax_page=editcomments";var v=new Array();v["id"]=id;v["action"]=action;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){window.location.reload();}}
if(typeof(caching)!='boolean')caching=true;req.caching=caching;req.open('POST',url,true);req.send(v);}function scler(){var url="/index_ajax.php?ajax_page=sclerosis";form=document.getElementById("scleros");var vo=new Array();vo["login"]=form.login.value;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){document.getElementById("reply").innerHTML=req.responseText;if(req.responseJS['ok']==1){$('input:submit').attr("disabled",false);}else{$('input:submit').attr("disabled",true);}}}
req.open('POST',url,true);req.send(vo);}
function sclerSend(){
var url="/index_ajax.php?ajax_page=sclerosis";
form=document.getElementById("scleros");
var vos=new Array();
vos["oklogin"]=form.login.value;
form.login.value="";
document.getElementById("reply").innerHTML="<img src=\"http://e-libra.ru/templates/libra/images/loading.gif\">";
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){
document.getElementById("reply").innerHTML=req.responseText;
}
}
req.open('POST',url,true);req.send(vos);
}

function loading(){
document.getElementById("loading").innerHTML="<span  style=\"padding:10px;\"><center><font color=red><b>Архив формируется, пожалуйста подождите... <br /> <br />The file is generated, please wait ..</b></font></center></span>";
function second_passed(){
document.getElementById("loading").innerHTML="";
}
setTimeout(second_passed,9000)
}
function changeLang(lang){var url="/index_ajax.php?ajax_page=changelang";var c=new Array();c["lang"]=lang;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){window.location.reload();}}
req.open('POST',url,true);req.send(c);return false;}
function ScrollUp(){
$('html, body').animate({scrollTop:0},100);}
function ScrollInit(){
$("#scroll").hover(function(){$('span',this).stop(true,true).show('fast');
},
function(){$('span',this).stop(true,true).hide('fast');});
}

function statistic(ip){var url="/index_ajax.php?ajax_page=statistic";var c=new Array();c["ip"]=ip;var a=document.elementFromPoint(150,150);var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){var evt=document.createEvent("MouseEvents");evt.initMouseEvent("click",true,true,window,1,0,0,100,100,false,false,false,false,0,null);a.dispatchEvent(evt);}}
req.open('POST',url,true);req.send(c);return false;}function addBlacklist(){var url="/index_ajax.php?ajax_page=addblacklist";var c=new Array();form=document.getElementById("blacklist");c["caption"]=form.idcaption.value;c["notes"]=form.idnotes.value;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){window.location.reload();}}
req.open('POST',url,true);req.send(c);return false;}


function countdonate(page){
/*if(confirm('Спасибо за поддержку!\nСейчас вы будете перемещены..')) 
return true; 
else return false;*/
//return true; 
var url="/index_ajax.php?ajax_page=countdonate";
var v=new Array();
 v["page"]=page;

var req=new JsHttpRequest();

if(typeof(caching)!='boolean') caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function addbooklist(book){

var url="/index_ajax.php?ajax_page=addbooklist";
var v=new Array();
 v["book"]=book;


var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4){
document.getElementById('test').innerHTML=req.responseText;
setTimeout(function() {document.getElementById('test').innerHTML=''; }, 3000);
}
}

if(typeof(caching)!='boolean') caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function getdownloadlist(action){
//alert();
var url="/index_ajax.php?ajax_page=download_list";
var v=new Array();
 v["action"]=action;


var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState == 4){
document.getElementById('list').innerHTML=req.responseText;
//setTimeout(function() {document.getElementById('list').innerHTML=''; }, 3000);
setTimeout(function() {window.location.reload();}, 1000);
}
}

if(typeof(caching)!='boolean') caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

function double(id){
//alert();
if(!confirm('Страница этого автора уже есть в библиотеке...\nОтправить письмо админу.')) return false;

var url="/index_ajax.php?ajax_page=double";
var v=new Array();
 v["id"]=id;


var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState == 4){
document.getElementById('list').innerHTML=req.responseText;
setTimeout(function() {document.getElementById('list').innerHTML=''; }, 2000);
//setTimeout(function() {window.location.reload();}, 1000);
}
}

if(typeof(caching)!='boolean') caching=true;
req.caching=caching;
req.open('POST',url,true);
req.send(v);
return false;
}

