var xmlHttp = false;
try {xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');}
catch (e) {
	try {xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');}
	catch (e) {
		if (window.XMLHttpRequest){
			xmlHttp = new XMLHttpRequest();
		}
	}
}
var err_beg = "<div class='new-reg-message'><div class='err-title'>Ошибка!</div><a class='err-close' href='#' onclick='clos(); return false;' title='Закрыть'></a><p>";
var err_reg_beg = "<div class='new-reg-message'><div class='err-title'>Ошибка!</div><a class='err-close' href='#' onclick='noscroll_clos(); return false;' title='Закрыть'></a><p>";
var err_end = "</p></div>";
var err1 = err_beg + "• Все поля обязательны для заполнения!" + err_end;
var err_reg1 = err_reg_beg + "• Все поля обязательны для заполнения!" + err_end;
var err2 = err_beg + "• Введите текст комментария!" + err_end;
var err3 = err_beg + "• Введите текст для поиска!" + err_end;
var err4 = err_beg + "• Введите email-адрес!" + err_end;
var err5 = err_beg + "• Введите новый пароль!" + err_end;
var err6 = err_beg + "• Введите заголовок поста!" + err_end;
var err7 = err_beg + "• Введите описание поста!" + err_end;
var err8 = err_beg + "• Введите краткое содержание поста!" + err_end;
var err9 = err_beg + "• Введите полное содержание поста!" + err_end;
var err10 = err_beg + "• Введите список тегов поста!" + err_end;
var err11 = err_beg + "• Для оценки постов нужно <a href='#' onclick='authShow(); clos(); return false;'>авторизироваться</a> на сайте!" + err_end;
var err12 = err_beg + "• Введите имя и фамилию!" + err_end;
var err13 = err_beg + "• Введите старый и новый пароли!" + err_end;
var err14 = err_beg + "• Введите текст ответа!" + err_end;
var err15 = err_beg + "• Для того, что бы задать новый вопрос, нужно <a href='#' onclick='authShow(); clos(); return false;'>авторизироваться</a> на сайте!" + err_end;
var err16 = err_beg + "• Для того, что бы отправить новую работу в &laquo;Показуху&raquo;,<br />нужно <a href='#' onclick='authShow(); clos(); return false;'>авторизироваться</a> на сайте!" + err_end;
var err17 = err_beg + "• Для оценки работ нужно <a href='#' onclick='authShow(); clos(); return false;'>авторизироваться</a> на сайте!" + err_end;
var err18 = err_beg + "• Автор не может оценивать свои работы!" + err_end;
var err19 = err_beg + "• Для скачивания этого файла нужно <a href='#' onclick='authShow(); clos(); return false;'>авторизироваться</a> на сайте!" + err_end;
var authok_beg = "<div class='new-reg-message'><div class='ok-title'>Ок!</div><a class='ok-close' href='#' onclick='closReload(); return false;' title='Закрыть'></a><p>";
var authok_end = "</p></div>";
var authok1 = authok_beg + "• Вы успешно зарегистрированы на сайте! Авторизация произойдет автоматически!" + authok_end;
var authok2 = authok_beg + "• Вы успешно авторизированы на сайте!" + authok_end;
var editok_beg = "<div class='new-reg-message'><div class='ok-title'>Ок!</div><a class='ok-close' href='#' onclick='clos(); return false;' title='Закрыть'></a><p>";
var editok_end = "</p></div>";
var editok1 = editok_beg + "• Новые имя и фамилия успешно сохранены!" + editok_end;
var warning_beg = "<div class='new-reg-message'><div class='err-title'>Внимание!</div><a class='err-close' href='#' onclick='clos(); return false;' title='Закрыть'></a><p>"
var warning_end = "</p></div>";

function auth(){
	if ((document.getElementById("login").value == document.getElementById("login").defaultValue) || (document.getElementById("login").value == null) || (document.getElementById("login").value == '')){loadingOff(); popupShow(err1); return false;}
	if ((document.getElementById("password").value == document.getElementById("password").defaultValue) || (document.getElementById("password").value == null) || (document.getElementById("password").value == '')){loadingOff(); popupShow(err1); return false;}
	
	if (document.getElementById("remember").checked){rememberMe = 1;}
	else {rememberMe = 0;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
        	if (xmlHttp.responseText == 1){
        		loadingOff();
           		popupPageShow(authok2);
        	}
        	else {
        		loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
    	}
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=authorize&login=" + encodeURIComponent(document.getElementById("login").value) + "&password=" + encodeURIComponent(document.getElementById("password").value) + "&remember=" + rememberMe);
}
function un_auth(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			loadingOff();
        	closReload();
    	}
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=un_authorize");
}
function add_post(){
	if ((document.getElementById("title").value == document.getElementById("title").defaultValue) || (document.getElementById("title").value == null) || (document.getElementById("title").value == '')){popupShow(err6); return false;}
	if ((document.getElementById("descr").value == document.getElementById("descr").defaultValue) || (document.getElementById("descr").value == null) || (document.getElementById("descr").value == '')){popupShow(err7); return false;}
	if ((document.getElementById("short").value == document.getElementById("short").defaultValue) || (document.getElementById("short").value == null) || (document.getElementById("short").value == '')){popupShow(err8); return false;}
	if ((document.getElementById("full").value == document.getElementById("full").defaultValue) || (document.getElementById("full").value == null) || (document.getElementById("full").value == '')){popupShow(err9); return false;}
	if ((document.getElementById("tags").value == document.getElementById("tags").defaultValue) || (document.getElementById("tags").value == null) || (document.getElementById("tags").value == '')){popupShow(err10); return false;}
	var pubOnMain = 1;
	if (document.getElementById("pubOnMain").checked){pubOnMain = 1;}
	else {pubOnMain = 0;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
       		loadingOff();
       		document.location.reload(true);
    	}
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=addpost&title=" + encodeURIComponent(document.getElementById("title").value) + "&description=" + encodeURIComponent(document.getElementById("descr").value) + "&short=" + encodeURIComponent(document.getElementById("short").value) + "&full=" + encodeURIComponent(document.getElementById("full").value) + "&tags=" + encodeURIComponent(document.getElementById("tags").value) + "&cat=" + encodeURIComponent(document.getElementById("selected").innerHTML) + "&mainpub=" + pubOnMain);
}
function comm_add(comm_post){
	if ((document.getElementById("comm").value == document.getElementById("comm").defaultValue) || (document.getElementById("comm").value == null) || (document.getElementById("comm").value == '')){popupShow(err2); return false;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText); return false;
			}
			else {
				loadingOff();
				comm_refresh(comm_post, true, true);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_add&post_id=" + encodeURIComponent(comm_post) + "&comm=" + encodeURIComponent(document.getElementById("comm").value));
}
function ansver_add(ansver_quest){
	if ((document.getElementById("ansver").value == document.getElementById("ansver").defaultValue) || (document.getElementById("ansver").value == null) || (document.getElementById("ansver").value == '')){popupShow(err14); return false;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText); return false;
			}
			else {
				loadingOff();
				ansver_refresh(ansver_quest, true, true);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=ansver_add&quest_id=" + encodeURIComponent(ansver_quest) + "&ansver=" + encodeURIComponent(document.getElementById("ansver").value));
}
function works_comm_add(work){
	if ((document.getElementById("work-comment").value == document.getElementById("work-comment").defaultValue) || (document.getElementById("work-comment").value == null) || (document.getElementById("work-comment").value == '')){popupShow(err2); return false;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText); return false;
			}
			else {
				loadingOff();
				works_comm_refresh(work, true, true);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=works_comm_add&work_id=" + encodeURIComponent(work) + "&comm=" + encodeURIComponent(document.getElementById("work-comment").value));
}
var delCom = Array();
function comm_del(comm_id, comm_post){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

				var delMess = document.createElement("div");
				delMess.id = "comm_"+comm_id;
				delMess.setAttribute("class", "deleted-comm");
				delMess.innerHTML = "Комментарий удален. <a href='#' onclick='recover_comm(" + comm_id + ", " + comm_post + "); return false;'>Восстановить...</a>";
				
				delCom[comm_id] = document.getElementById("comm_"+comm_id);
				delCom[comm_id].parentNode.replaceChild(delMess, delCom[comm_id]);
				
				document.getElementById("comm_count").innerHTML = xmlHttp.responseText;
				
           		return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_del&id=" + comm_id + "&pid=" + comm_post);
}

function recover_comm(comm_id, comm_post){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

           		var data = eval("(" + xmlHttp.responseText + ")");

				if (data.error){
					return false;
				}
				if (data.count) {
					delMess = document.getElementById("comm_"+comm_id);
					delMess.parentNode.replaceChild(delCom[comm_id], delMess);
					document.getElementById("comm_count").innerHTML = data.count;
					return false;
				}
				
				return false;				
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover_comm&id=" + comm_id + "&pid=" + comm_post);
}

var delAnsver = Array();
function ansver_del(ansver_id, ansver_quest){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

				var delMess = document.createElement("div");
				delMess.id = "ansver_"+ansver_id;
				delMess.setAttribute("class", "deleted-comm");
				delMess.innerHTML = "Ответ удален. <a href='#' onclick='recover_ansver(" + ansver_id + ", " + ansver_quest + "); return false;'>Восстановить...</a>";
				
				delAnsver[ansver_id] = document.getElementById("ansver_"+ansver_id);
				delAnsver[ansver_id].parentNode.replaceChild(delMess, delAnsver[ansver_id]);
				
				document.getElementById("ansver_count").innerHTML = xmlHttp.responseText;
				
           		return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=ansver_del&id=" + ansver_id + "&qid=" + ansver_quest);
}
var delWorksComm = Array();
function works_comm_del(works_comm_id, work){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

				var delMess = document.createElement("div");
				delMess.id = "works_comm_"+works_comm_id;
				delMess.setAttribute("class", "deleted-comm");
				delMess.innerHTML = "Коммент удален. <a href='#' onclick='recover_works_comm(" + works_comm_id + ", " + work + "); return false;'>Восстановить...</a>";
				
				delWorksComm[works_comm_id] = document.getElementById("works_comm_"+works_comm_id);
				delWorksComm[works_comm_id].parentNode.replaceChild(delMess, delWorksComm[works_comm_id]);
				
				document.getElementById("works_comm_count").innerHTML = xmlHttp.responseText;
				
           		return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=works_comm_del&id=" + works_comm_id + "&wid=" + work);
}

function recover_ansver(ansver_id, ansver_quest){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

           		var data = eval("(" + xmlHttp.responseText + ")");

				if (data.error){
					return false;
				}
				if (data.count) {
					delMess = document.getElementById("ansver_"+ansver_id);
					delMess.parentNode.replaceChild(delAnsver[ansver_id], delMess);
					document.getElementById("ansver_count").innerHTML = data.count;
					return false;
				}
				
				return false;				
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover_ansver&id=" + ansver_id + "&qid=" + ansver_quest);
}
function recover_works_comm(works_comm_id, work){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

           		var data = eval("(" + xmlHttp.responseText + ")");

				if (data.error){
					return false;
				}
				if (data.count) {
					delMess = document.getElementById("works_comm_"+works_comm_id);
					delMess.parentNode.replaceChild(delWorksComm[works_comm_id], delMess);
					document.getElementById("works_comm_count").innerHTML = data.count;
					return false;
				}
				
				return false;				
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover_works_comm&id=" + works_comm_id + "&wid=" + work);
}
var delComAdm = Array();
function adm_comm_del(comm_id){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				//comm_refresh(comm_post, true, true);
				//document.getElementById("comm_"+comm_id).innerHTML = "удален";
				
				var delMess = document.createElement("div");
				delMess.id = "comm_"+comm_id;
				delMess.setAttribute("class", "adm-deleted-comm");
				delMess.innerHTML = "Комментарий удален. <a href='#' onclick='recover_comm_adm(" + comm_id + "); return false;'>Восстановить...</a>";
								
				delComAdm[comm_id] = document.getElementById("comm_"+comm_id);
				delComAdm[comm_id].parentNode.replaceChild(delMess, delComAdm[comm_id]);
				
				document.getElementById("adm_comm_count").innerHTML = xmlHttp.responseText;
				
           		return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_del&id=" + comm_id + "&adm=true");
}
function recover_comm_adm(comm_id){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();

				var data = eval("(" + xmlHttp.responseText + ")");

				if (data.error){
					return false;
				}
				if (data.count){
					delMess = document.getElementById("comm_"+comm_id);
					delMess.parentNode.replaceChild(delComAdm[comm_id], delMess);
					document.getElementById("adm_comm_count").innerHTML = data.count;
					return false;
				}
				
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover_comm&id=" + comm_id + "&adm=true");
}
function comm_next(comm_post, comm_start, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("comm_list").innerHTML += data.comm_list;
				document.getElementById("comm_next").innerHTML = data.comm_next;
				if (top == true) document.getElementById("comm_top").innerHTML = data.comm_top;
				if (add == true) document.getElementById("comm_add").innerHTML = data.comm_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_show&comm_post=" + comm_post + "&comm_start=" + comm_start);
}
function ansvers_next(ansver_quest, ansvers_start, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("ansvers_list").innerHTML += data.ansvers_list;
				document.getElementById("ansvers_next").innerHTML = data.ansvers_next;
				if (top == true) document.getElementById("ansver_top").innerHTML = data.ansver_top;
				if (add == true) document.getElementById("ansver_add").innerHTML = data.ansver_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=ansvers_show&ansver_quest=" + ansver_quest + "&ansvers_start=" + ansvers_start);
}
function works_comm_next(work, works_comm_start, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("works_comm_list").innerHTML += data.works_comm_list;
				document.getElementById("works_comm_next").innerHTML = data.works_comm_next;
				if (top == true) document.getElementById("works_comm_top").innerHTML = data.works_comm_top;
				if (add == true) document.getElementById("works_comm_add").innerHTML = data.works_comm_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=works_comm_show&work=" + work + "&works_comm_start=" + works_comm_start);
}
function adm_comm_next(comm_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("adm_comm_list").innerHTML += data.adm_comm_list;
				document.getElementById("adm_comm_next").innerHTML = data.adm_comm_next;
				document.getElementById("adm_comm_top").innerHTML = data.adm_comm_top;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=adm_comm_show" + "&comm_start=" + comm_start);
}
function comm_refresh(comm_post, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("comm_list").innerHTML = data.comm_list;
				document.getElementById("comm_next").innerHTML = data.comm_next;
				if (top == true) document.getElementById("comm_top").innerHTML = data.comm_top;
				if (add == true) document.getElementById("comm_add").innerHTML = data.comm_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_show&comm_post=" + comm_post);
}
function ansver_refresh(ansver_quest, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("ansvers_list").innerHTML = data.ansvers_list;
				document.getElementById("ansvers_next").innerHTML = data.ansvers_next;
				if (top == true) document.getElementById("ansver_top").innerHTML = data.ansver_top;
				if (add == true) document.getElementById("ansver_add").innerHTML = data.ansver_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=ansvers_show&ansver_quest=" + ansver_quest);
}
function works_comm_refresh(work, top, add){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("works_comm_list").innerHTML = data.works_comm_list;
				document.getElementById("works_comm_next").innerHTML = data.works_comm_next;
				if (top == true) document.getElementById("works_comm_top").innerHTML = data.works_comm_top;
				if (add == true) document.getElementById("works_comm_add").innerHTML = data.works_comm_add;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=works_comm_show&work=" + work);
}
function go_to(url_enc){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText);
            	return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=go&url=" + url_enc);
}
function download(p, f){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			loadingOff();
			if (xmlHttp.responseText == "auth"){
				popupShow(err19);
				return false;
            }
			else {
           		popupShow(xmlHttp.responseText);
            	return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=download&p=" + p + "&f=" + f);
}
function download_get_url(p, f){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
           		document.getElementById("download_url").innerHTML = xmlHttp.responseText;
            	return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=download_get_url&p=" + p + "&f=" + f);
}
function recover(){
	if ((document.getElementById("email").value == document.getElementById("email").defaultValue) || (document.getElementById("email").value == null) || (document.getElementById("email").value == '')){popupShow(err4); return false;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover&email=" + encodeURIComponent(document.getElementById("email").value));
}
function savepass(uid, hash){
	if ((document.getElementById("password").value == document.getElementById("password").defaultValue) || (document.getElementById("password").value == null) || (document.getElementById("password").value == '')){popupShow(err5); return false;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=savepass&uid=" + uid + "&hash=" + hash + "&newpass=" + encodeURIComponent(document.getElementById("password").value));
}
function reg(){
	if ((document.getElementById("login").value == document.getElementById("login").defaultValue) || (document.getElementById("login").value == null) || (document.getElementById("login").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("password").value == document.getElementById("password").defaultValue) || (document.getElementById("password").value == null) || (document.getElementById("password").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("email").value == document.getElementById("email").defaultValue) || (document.getElementById("email").value == null) || (document.getElementById("email").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("name").value == document.getElementById("name").defaultValue) || (document.getElementById("name").value == null) || (document.getElementById("name").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("family").value == document.getElementById("family").defaultValue) || (document.getElementById("family").value == null) || (document.getElementById("family").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("captcha").value == document.getElementById("captcha").defaultValue) || (document.getElementById("captcha").value == null) || (document.getElementById("captcha").value == '')){popupShow(err_reg1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText == 1){
				loadingOff();
				popupPageShow(authok1);
				return false;
			}
			else {
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=reg&login=" + encodeURIComponent(document.getElementById("login").value) + "&password=" + encodeURIComponent(document.getElementById("password").value) + "&email=" + encodeURIComponent(document.getElementById("email").value) + "&captcha=" + encodeURIComponent(document.getElementById("captcha").value) + "&name=" + encodeURIComponent(document.getElementById("name").value) + "&family=" + encodeURIComponent(document.getElementById("family").value));
}
function popupShow(text) {
	if (document.getElementById("popupContent")){
		document.getElementById("popupContent").innerHTML = text;
		popupLayerHeight();
		return false;
	}
	else{
		var popupOverlay = document.createElement("div");
		popupOverlay.id = "popupOver";
		popupOverlay.className = "popup-overlay";
		var popupContent = document.createElement("div");
		popupContent.id = "popupContent";
		popupContent.innerHTML = text;
	
		var popup = document.createElement("div");
		popup.id = "popup";
		popup.className = "popup";
		popup.appendChild(popupContent);
	
		var popupLayer = document.createElement("div");
		popupLayer.id = "popupLayer";
		popupLayer.className = "popup-layer";
		popupLayer.appendChild(popup);
	
		popup.style.display='block';
		popupContent.style.display='block';
		popupOverlay.style.display='block';
		popupLayer.style.display='block';
		
		insertBef = document.getElementsByTagName("div")[0];
		document.body.insertBefore (popupLayer, insertBef);
		document.body.insertBefore (popupOverlay, insertBef);
		
		popupLayerHeight();
		 
		popup.style.opacity='0.0';
		popupOverlay.style.opacity='0.0';
		z = new tst(0.8,0.0,0.3,popupOverlay); z.appear();
		z = new tst(1,0.0,0.3,popup); z.appear();
		
		addEvent(window, "resize", popupLayerHeight);
		
		//bodyScrollOff();
		
	}
}

function popupLayerHeight(){
	bodyScrollOff();
	document.body.style.overflow = "auto";
	document.getElementById('popupLayer').style.marginTop = 0.1 * document.body.clientHeight + 'px'; 
	document.getElementById('popupLayer').style.height = document.body.clientHeight + 'px';

	if (document.body.clientHeight <= (document.getElementById('popup').clientHeight + parseInt(document.getElementById('popupLayer').style.marginTop))){
		
		document.getElementById('popupLayer').style.marginTop = document.body.clientHeight - document.getElementById('popup').clientHeight + 'px';
		if (parseInt(document.getElementById('popupLayer').style.marginTop) <= 0){
			document.getElementById('popupLayer').style.marginTop = 0 + 'px';
		}
		
		if (document.body.clientHeight <= parseInt(document.getElementById('popup').clientHeight)){
			document.getElementById('popupLayer').style.height = document.body.clientHeight + 'px';
			bodyScrollOn();
			document.body.style.overflow = "hidden";
		}
	}
}

function popupPageLayerHeight(){
	bodyScrollOff();
	document.body.style.overflow = "auto";
	document.getElementById('popupPageLayer').style.marginTop = 0.1 * document.body.clientHeight + 'px';
	document.getElementById('popupPageLayer').style.height = document.body.clientHeight + 'px';
	if (document.body.clientHeight <= (document.getElementById('popupPage').clientHeight + parseInt(document.getElementById('popupPageLayer').style.marginTop))){
		document.getElementById('popupPageLayer').style.marginTop = document.body.clientHeight - document.getElementById('popupPage').clientHeight + 'px';
		if (parseInt(document.getElementById('popupPageLayer').style.marginTop) <= 0){
			document.getElementById('popupPageLayer').style.marginTop = 0 + 'px';
		}
		
		if (document.body.clientHeight <= parseInt(document.getElementById('popupPage').clientHeight+1)){
			document.getElementById('popupPageLayer').style.height = document.body.clientHeight + 'px';
			bodyScrollOn();
			document.body.style.overflow = "hidden";
		}
	}
}

function clos(){
	document.getElementById("popup").style.opacity='1';
	document.getElementById("popupOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popup")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupOver")); z.disappear();
	setTimeout(function(){
		document.getElementById("popupLayer").parentNode.removeChild (document.getElementById("popupLayer"));
		document.getElementById("popupOver").parentNode.removeChild (document.getElementById("popupOver"));
		remEvent(window, "resize", popupLayerHeight);
		//document.body.style.overflow = 'auto';
		bodyScrollOn();
	}, 200);
}
function noscroll_clos(){
	document.getElementById("popup").style.opacity='1';
	document.getElementById("popupOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popup")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupOver")); z.disappear();
	setTimeout(function(){
		document.getElementById("popupLayer").parentNode.removeChild (document.getElementById("popupLayer"));
		document.getElementById("popupOver").parentNode.removeChild (document.getElementById("popupOver"));
		remEvent(window, "resize", popupLayerHeight);
	}, 200);
}
function closReload(){
	document.getElementById("popupPage").style.opacity='1';
	document.getElementById("popupPageOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popupPage")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupPageOver")); z.disappear();
	setTimeout(function(){
		document.location.reload(true);
	}, 300);
}
function clos2Reload(){
	document.getElementById("popupPage").style.opacity='1';
	document.getElementById("popupPageOver").style.opacity='0.8';
	document.getElementById("popup").style.opacity='1';
	document.getElementById("popupOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popupPage")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupPageOver")); z.disappear();
	z = new tst(1,0.0,0.2,document.getElementById("popup")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupOver")); z.disappear();
	setTimeout(function(){
		document.location.reload(true);
	}, 300);
}
function reg_clos(){
	document.getElementById("popup").style.opacity='1';
	document.getElementById("popupOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popup")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupOver")); z.disappear();
	setTimeout(function(){
		document.getElementById("popupLayer").parentNode.removeChild (document.getElementById("popupLayer"));
		document.getElementById("popupOver").parentNode.removeChild (document.getElementById("popupOver"));
		document.getElementById('captcha-img').src='/index.php?act=captcha&rnd='+Math.random();
	}, 200);
}

function zoomingOn(forZoom) {
	loadingOn();
	
	var imag = new Image();
	imag.src = forZoom.src.replace(".png", "-full.png");
	
	zot = setInterval(function(){
		if (imag.width != 0){
			loadingOff();
			
			zoomingShow(imag.src, imag.width, imag.height);
			clearInterval(zot);
		}
	}, 100);
}

function zoomThumb(forZoom) {
	loadingOn();
	
	var imag = new Image();
	imag.src = forZoom.src.replace("s_", "l_");
	
	ztt = setInterval(function(){
		if (imag.width != 0){
			loadingOff();
			
			zoomingShow(imag.src, imag.width, imag.height);
			clearInterval(ztt);
		}
	}, 100);
}

function zoomingShow(imgSrc, imgWidth, imgHeight){
	var popupOverlay = document.createElement("div");
	popupOverlay.id = "popupOver";
	popupOverlay.className = "popup-overlay";
	
	var popupContent = document.createElement("div");
	popupContent.id = "popup-zoomContent";
	popupContent.innerHTML = "<img href='#' onclick='clos(); return false;' src='" + imgSrc + "' width='" + imgWidth + "px' height='" + imgHeight + "px' /><br /><br />[ кликните по изображению для закрытия ]";
	
	var popup = document.createElement("div");
	popup.id = "popup";
	popup.className = "popup-zoom";
	popup.appendChild(popupContent);
	
	var popupLayer = document.createElement("div");
	popupLayer.id = "popupLayer";
	popupLayer.className = "popup-layer";
	popupLayer.appendChild(popup);
	
	popup.style.display='block';
	popupContent.style.display='block';
	popupOverlay.style.display='block';
	popupLayer.style.display='block';
	
	insertBef = document.getElementsByTagName("div")[0];
	document.body.insertBefore (popupLayer, insertBef);
	document.body.insertBefore (popupOverlay, insertBef);
	
	popupLayerHeight();
	
	popup.style.opacity='0.0';
	popupOverlay.style.opacity='0.0';
	z = new tst(0.8,0.0,0.2,popupOverlay); z.appear();
	z = new tst(1,0.0,0.2,popup); z.appear();
	
	addEvent(window, "resize", popupLayerHeight);

	//bodyScrollOff();
}

function authShow(){
	loadingOn();
    xmlHttp.open('POST', "/index.php", true);
    xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupPageShow(xmlHttp.responseText);
				document.getElementById('vk_auth').style.height = "105px";
				if (document.getElementById('auth-vk')){
			
					setTimeout(function(){
						document.getElementById('vk_auth').style.height = "105px";
						document.getElementById('auth-vk').appendChild(document.getElementById('vk_auth'));
						document.getElementById('vk_auth').style.display = "block";
						document.getElementById('vk_auth').style.opacity='0.0';
						popupPageLayerHeight();
						
						setTimeout(function(){
							z = new tst(1,0.0,0.05,document.getElementById('vk_auth')); z.appear();
						}, 300);
					}, 100);
				}
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=auth_info");
}
function recoverShow(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
		
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
			
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=recover_page");
}
function regShow(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=reg_page");
}
function profileShow(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				checkSet();
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=profile_page");
}
function invitesLinkShow(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=my_invites_link_page");
}
function invitesShow(invites_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (invites_start) xmlHttp.send("act=my_invites_page&start=" + invites_start);
	else xmlHttp.send("act=my_invites_page");
}
function invitedShow(){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (xmlHttp.responseText == "err"){return false;}
				else {
					if (document.getElementById('auth-vk')){
						document.getElementById('vk_auth').style.display = "none";
						document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
					}
					popupPageShow(xmlHttp.responseText);
					return false;
				}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=invited_page");
}
function commentsShow(comm_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (comm_start) xmlHttp.send("act=my_comments_page&start=" + comm_start);
	else xmlHttp.send("act=my_comments_page");
}
function worksCommentsShow(comm_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (comm_start) xmlHttp.send("act=my_works_comments_page&start=" + comm_start);
	else xmlHttp.send("act=my_works_comments_page");
}
function questsShow(quest_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (quest_start) xmlHttp.send("act=my_quests_page&start=" + quest_start);
	else xmlHttp.send("act=my_quests_page");
}
function ansversShow(ansver_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (ansver_start) xmlHttp.send("act=my_ansvers_page&start=" + ansver_start);
	else xmlHttp.send("act=my_ansvers_page");
}
function worksShow(work_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (work_start) xmlHttp.send("act=my_works_page&start=" + work_start);
	else xmlHttp.send("act=my_works_page");
}
function postsCommsShow(post_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (post_start) xmlHttp.send("act=posts_comms_page&start=" + post_start);
	else xmlHttp.send("act=posts_comms_page");
}
function worksCommsShow(work_start){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
			
				if (document.getElementById('auth-vk')){
					document.getElementById('vk_auth').style.display = "none";
					document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
				}
				popupPageShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (work_start) xmlHttp.send("act=works_comms_page&start=" + work_start);
	else xmlHttp.send("act=works_comms_page");
}
function popupPageShow(text) {
	if (document.getElementById("popupPageContent")){
		document.getElementById("popupPageContent").innerHTML = text;
		popupPageLayerHeight();
		return false;
	}
	else{
		var popupPageOverlay = document.createElement("div");
		popupPageOverlay.id = "popupPageOver";
		popupPageOverlay.className = "popup-page-overlay";
        var popupPageContent = document.createElement("div");
		popupPageContent.id = "popupPageContent";
		popupPageContent.innerHTML = text;
	
		var popupPage = document.createElement("div");
		popupPage.id = "popupPage";
		popupPage.className = "popup-page";
		popupPage.appendChild(popupPageContent);
	
		var popupPageLayer = document.createElement("div");
		popupPageLayer.id = "popupPageLayer";
		popupPageLayer.className = "popup-page-layer";
		popupPageLayer.appendChild(popupPage);
	
		popupPage.style.display='block';
		popupPageContent.style.display='block';
		popupPageOverlay.style.display='block';
		popupPageLayer.style.display='block';
		
		insertBef = document.getElementsByTagName("div")[0];
		document.body.insertBefore (popupPageLayer, insertBef);
		document.body.insertBefore (popupPageOverlay, insertBef);
		
		popupPageLayerHeight();
		
		popupPage.style.opacity='0.0';
		popupPageOverlay.style.opacity='0.0';
		z = new tst(0.8,0.0,0.3,popupPageOverlay); z.appear();
		z = new tst(1,0.0,0.3,popupPage); z.appear();
		
		addEvent(window, "resize", popupPageLayerHeight);
		
		//bodyScrollOff();
	}
}

function closPage() {
	document.getElementById("popupPage").style.opacity='1';
	document.getElementById("popupPageOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popupPage")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupPageOver")); z.disappear();
	setTimeout(function(){
		document.getElementById("popupPageLayer").parentNode.removeChild (document.getElementById("popupPageLayer"));
		document.getElementById("popupPageOver").parentNode.removeChild (document.getElementById("popupPageOver"));
		remEvent(window, "resize", popupPageLayerHeight);
		//document.body.style.overflow = 'auto';
		bodyScrollOn();
	}, 200);
}
function closAuthPage() {
	document.getElementById("popupPage").style.opacity='1';
	document.getElementById("popupPageOver").style.opacity='0.8';
	z = new tst(1,0.0,0.2,document.getElementById("popupPage")); z.disappear();
	z = new tst(0.8,0.0,0.2,document.getElementById("popupPageOver")); z.disappear();
	setTimeout(function(){
		if (document.getElementById('auth-vk')){
			document.getElementById('vk_auth').style.display = "none";
			document.getElementById('vk_auth_hidden').appendChild(document.getElementById('vk_auth'));
		}
		document.getElementById("popupPageLayer").parentNode.removeChild (document.getElementById("popupPageLayer"));
		document.getElementById("popupPageOver").parentNode.removeChild (document.getElementById("popupPageOver"));
		remEvent(window, "resize", popupPageLayerHeight);
		//document.body.style.overflow = 'auto';
		bodyScrollOn();
	}, 200);
}
function like_yes(post_id, like_btn){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (xmlHttp.responseText == "auth"){
					popupShow(err11);
					return false;
            	}
            	else {
            		like_btn.parentNode.innerHTML = xmlHttp.responseText;
            		return false;
          	  	}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=like_yes&post_id=" + post_id);
}
function like_no(post_id, like_btn){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (xmlHttp.responseText == "auth"){
					popupShow(err11);
					return false;
           	 	}
           	 	else {
            		like_btn.parentNode.innerHTML = xmlHttp.responseText;
            		return false;
            	}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=like_no&post_id=" + post_id);
}
function like_work_yes(work_id, like_btn){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (xmlHttp.responseText == "auth"){
					popupShow(err17);
					return false;
            	}
            	else if (xmlHttp.responseText == "author"){
					popupShow(err18);
					return false;
            	}
            	else {
            		like_btn.parentNode.innerHTML = xmlHttp.responseText;
            		return false;
          	  	}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=like_work_yes&work_id=" + work_id);
}
function like_work_no(work_id, like_btn){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				if (xmlHttp.responseText == "auth"){
					popupShow(err17);
					return false;
            	}
            	else if (xmlHttp.responseText == "author"){
					popupShow(err18);
					return false;
            	}
           	 	else {
            		like_btn.parentNode.innerHTML = xmlHttp.responseText;
            		return false;
            	}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=like_work_no&work_id=" + work_id);
}
function profileFIOSave(){
	if ((document.getElementById("name").value == null) || (document.getElementById("name").value == '')){popupShow(err12); return false;}
	if ((document.getElementById("family").value == null) || (document.getElementById("family").value == '')){popupShow(err12); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText == 1){
				loadingOff();
				popupShow(editok1);
				return false;
			}
			else {
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=prof_fio_sav&name=" + encodeURIComponent(document.getElementById("name").value) + "&family=" + encodeURIComponent(document.getElementById("family").value));
}
function profilePassSave(){
	if ((document.getElementById("new_pass").value == document.getElementById("new_pass").defaultValue) || (document.getElementById("new_pass").value == null) || (document.getElementById("new_pass").value == '')){popupShow(err13); return false;}
	if ((document.getElementById("old_pass").value == document.getElementById("old_pass").defaultValue) || (document.getElementById("old_pass").value == null) || (document.getElementById("old_pass").value == '')){popupShow(err13); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=prof_pass_sav&old_pass=" + encodeURIComponent(document.getElementById("old_pass").value) + "&new_pass=" + encodeURIComponent(document.getElementById("new_pass").value));
}
function profileVkSave(){
	if ((document.getElementById("login").value == document.getElementById("login").defaultValue) || (document.getElementById("login").value == null) || (document.getElementById("login").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("password").value == document.getElementById("password").defaultValue) || (document.getElementById("password").value == null) || (document.getElementById("password").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("email").value == document.getElementById("email").defaultValue) || (document.getElementById("email").value == null) || (document.getElementById("email").value == '')){popupShow(err_reg1); return false;}
	if ((document.getElementById("captcha").value == document.getElementById("captcha").defaultValue) || (document.getElementById("captcha").value == null) || (document.getElementById("captcha").value == '')){popupShow(err_reg1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupShow(xmlHttp.responseText);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=prof_vk_sav&login=" + encodeURIComponent(document.getElementById("login").value) + "&password=" + encodeURIComponent(document.getElementById("password").value) + "&email=" + encodeURIComponent(document.getElementById("email").value) + "&captcha=" + encodeURIComponent(document.getElementById("captcha").value));
}
function vk_show_check(){
	if (document.getElementById("vk_show").checked){vk_show = 1;}
	else {vk_show = 0;}
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				
				document.getElementById("vk_show_container").innerHTML = xmlHttp.responseText;
				checkSet();
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=vk_show_check&show=" + vk_show);
}

function loadingOn(){
	if (document.getElementById("loadingBoxBg")){
		return false;
	}
	var loadingBox = document.createElement("div");
	loadingBox.id = "loadingBox";
	loadingBox.className = "loadingBox";
	
	var loadingBoxBg = document.createElement("div");
	loadingBoxBg.id = "loadingBoxBg";
	loadingBoxBg.className = "loadingBoxBg";
	
	loadingBoxBg.appendChild(loadingBox);
	
	insertBef = document.getElementsByTagName("div")[0];
	document.body.insertBefore (loadingBoxBg, insertBef);
	
	//setTimeout(loadingOff, 7000);
}

function loadingOff(){
	if (document.getElementById("loadingBoxBg")){
		document.getElementById("loadingBoxBg").parentNode.removeChild (document.getElementById("loadingBoxBg"));
	}
}

function newQueShow(que_cat){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				var data = eval("(" + xmlHttp.responseText + ")");
				if (data.error == "1"){
					popupShow(err15);
					return false;
				}
				else {
					popupPageShow(data.ok);
					return false;
				}
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (que_cat) xmlHttp.send("act=new_que_show&cat=" + que_cat);
	else xmlHttp.send("act=new_que_show");
}
function newWorkShow(work_cat){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				var data = eval("(" + xmlHttp.responseText + ")");
				if (data.error == "1"){
					popupShow(err16);
					return false;
				}
				else {
					popupPageShow(data.ok);
					return false;
				}
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	if (work_cat) xmlHttp.send("act=new_work_show&cat=" + work_cat);
	else xmlHttp.send("act=new_work_show");
}
function addQuest(){
	if ((document.getElementById("title").value == document.getElementById("title").defaultValue) || (document.getElementById("title").value == null) || (document.getElementById("title").value == '')){popupShow(err1); return false;}
	if ((document.getElementById("description").value == document.getElementById("description").defaultValue) || (document.getElementById("description").value == null) || (document.getElementById("description").value == '')){popupShow(err1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				var data = eval("(" + xmlHttp.responseText + ")");
				if (data.quest){
					document.location.href = data.quest;
				}
				else {
					popupShow(data.error);
					return false;
				}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=add_quest&title=" + encodeURIComponent(document.getElementById("title").value) + "&description=" + encodeURIComponent(document.getElementById("description").value) + "&category=" + encodeURIComponent(document.getElementById("selected").innerHTML) + "&cost=" + encodeURIComponent(document.getElementById("selected_cost").innerHTML));
}
function addWork(){
	if ((document.getElementById("title").value == document.getElementById("title").defaultValue) || (document.getElementById("title").value == null) || (document.getElementById("title").value == '')){popupShow(err1); return false;}
	if ((document.getElementById("description").value == document.getElementById("description").defaultValue) || (document.getElementById("description").value == null) || (document.getElementById("description").value == '')){popupShow(err1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				var data = eval("(" + xmlHttp.responseText + ")");
				if (data.work){
					document.location.href = data.work;
				}
				else {
					popupShow(data.error);
					return false;
				}
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=add_work&title=" + encodeURIComponent(document.getElementById("title").value) + "&description=" + encodeURIComponent(document.getElementById("description").value) + "&category=" + encodeURIComponent(document.getElementById("selected").innerHTML));
}

function bestClose(ansver_id, quest_id){
	popupShow(warning_beg + "• Вы уверены, что этот ответ лучший? Он решает ваш вопрос? Если уверены &ndash; вопрос будет закрыт и помечен как решенный, автору лучшего ответа будут начислены призовые баллы.</p><p>• Данное действие нельзя отменить!</p><p>• Если не уверены &ndash; закройте это окошко!</p><p>• Если уверены &ndash; <a href='#' onclick='bestCloseYes(" + ansver_id + ", " + quest_id + "); return false;'>кликните сюда</a>." + warning_end);
	return false;
}

function bestCloseYes(ansver_id, quest_id){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText == "ok"){
				loadingOff();
       			document.location.reload(true);
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=close_quest&quest=" + quest_id + "&ansver=" + ansver_id);
}

function questDel(quest_id){
	popupShow(warning_beg + "• Вы уверены, что хотите удалить данный вопрос?</p><p>• Данное действие нельзя отменить!</p><p>• Если не уверены &ndash; закройте это окошко!</p><p>• Если уверены &ndash; <a href='/index.php?act=quest_del&id=" + quest_id + "'>кликните сюда</a>." + warning_end);
	return false;
}

function workDel(work_id){
	popupShow(warning_beg + "• Вы уверены, что хотите удалить эту работу?</p><p>• Данное действие нельзя отменить!</p><p>• Если не уверены &ndash; закройте это окошко!</p><p>• Если уверены &ndash; <a href='/index.php?act=work_del&id=" + work_id + "'>кликните сюда</a>." + warning_end);
	return false;
}

function questEditShow(quest_id){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupPageShow(xmlHttp.responseText);
				textareaAutoHeight(document.getElementById("description"), 200);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=edit_que_show&id=" + quest_id);
}

function workEditShow(work_id){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				popupPageShow(xmlHttp.responseText);
				textareaAutoHeight(document.getElementById("description"), 200);
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=edit_work_show&id=" + work_id);
}

function editQuest(qid){
	if ((document.getElementById("title").value == null) || (document.getElementById("title").value == '')){popupShow(err1); return false;}
	if ((document.getElementById("description").value == null) || (document.getElementById("description").value == '')){popupShow(err1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				document.location.href = xmlHttp.responseText;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=edit_quest&id=" + qid + "&title=" + encodeURIComponent(document.getElementById("title").value) + "&description=" + encodeURIComponent(document.getElementById("description").value) + "&category=" + encodeURIComponent(document.getElementById("selected").innerHTML));
}

function editWork(wid){
	if ((document.getElementById("title").value == null) || (document.getElementById("title").value == '')){popupShow(err1); return false;}
	if ((document.getElementById("description").value == null) || (document.getElementById("description").value == '')){popupShow(err1); return false;}
	
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
				document.location.href = xmlHttp.responseText;
				return false;
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=edit_work&id=" + wid + "&title=" + encodeURIComponent(document.getElementById("title").value) + "&description=" + encodeURIComponent(document.getElementById("description").value) + "&category=" + encodeURIComponent(document.getElementById("selected").innerHTML));
}

function saveTooltips(work_id){
	if ((document.getElementById("moder_comm").value == document.getElementById("moder_comm").defaultValue) || (document.getElementById("moder_comm").value == null) || (document.getElementById("moder_comm").value == '')){popupShow(err2); return false;}
	
	loadingOn();
	
	var tooltip = new Object();
	var childNodeArray = document.getElementById('imgBox').childNodes;
	for (var i = 0; i < childNodeArray.length; i ++){
		childNodeArray[i].id.search(/(imgPopup_)(\d*)/i);
		if (RegExp.$1 == "imgPopup_"){
			tooltip[RegExp.$2] = new Object();
			tooltip[RegExp.$2]['left'] = parseInt(document.getElementById('imgPopup_'+RegExp.$2).style.left);
			tooltip[RegExp.$2]['top'] = parseInt(document.getElementById('imgPopup_'+RegExp.$2).style.top);
			tooltip[RegExp.$2]['text'] = document.getElementById('imgPopup_'+RegExp.$2).tooltip;
		}
	}

    var json_tooltip = JSON.stringify(tooltip);
	
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText = "ok"){
				loadingOff();
				
				//popupShow(xmlHttp.responseText);
       			document.location.reload(true);
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=save_tooltips&work=" + work_id + "&tooltips=" + json_tooltip + "&moder_comm=" + encodeURIComponent(document.getElementById("moder_comm").value));
}

function rgb2hex(r,g,b){
  return Number(r).toString(16).toUpperCase().replace(/^(.)$/,'0$1') + 
         Number(g).toString(16).toUpperCase().replace(/^(.)$/,'0$1') +
         Number(b).toString(16).toUpperCase().replace(/^(.)$/,'0$1');
}

function comm_all(anchor){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("comm_list").innerHTML = data.comm_list;
				document.getElementById("comm_next").innerHTML = "";
				scrollToLink(anchor);
				var i = 255;
 				var tColorIn = setInterval(function(){
					document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
					if (i == 240){
						clearInterval(tColorIn);
						var tColorOut = setInterval(function(){
							document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
							if (i == 255) clearInterval(tColorOut);
							i++;
						}, 500);
					}
					i--;
				}, 50);
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=comm_show&comm_post=" + parseInt(document.getElementById("pid").innerHTML) + "&all=true");
}

function work_comm_all(anchor){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("comm_list").innerHTML = data.comm_list;
				document.getElementById("comm_next").innerHTML = "";
				scrollToLink(anchor);
				var i = 255;
 				var tColorIn = setInterval(function(){
					document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
					if (i == 240){
						clearInterval(tColorIn);
						var tColorOut = setInterval(function(){
							document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
							if (i == 255) clearInterval(tColorOut);
							i++;
						}, 500);
					}
					i--;
				}, 50);
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=works_comm_show&work=" + parseInt(document.getElementById("wid").innerHTML) + "&all=true");
}

function quest_ansvers_all(anchor){
	loadingOn();
	xmlHttp.open('POST', "/index.php", true);
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
			if (xmlHttp.responseText){
				loadingOff();
          	  	var data = eval("(" + xmlHttp.responseText + ")");
				document.getElementById("comm_list").innerHTML = data.comm_list;
				document.getElementById("comm_next").innerHTML = "";
				scrollToLink(anchor);
				var i = 255;
 				var tColorIn = setInterval(function(){
					document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
					if (i == 240){
						clearInterval(tColorIn);
						var tColorOut = setInterval(function(){
							document.getElementById(anchor).parentNode.parentNode.parentNode.style.background = "#"+rgb2hex(i,i,i);
							if (i == 255){
								clearInterval(tColorOut);
								document.getElementById(type+num).parentNode.parentNode.parentNode.style.background = "";
							}
							i++;
						}, 500);
					}
					i--;
				}, 50);
			}
		}
	}
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("act=act=ansvers_show&ansver_quest=" + parseInt(document.getElementById("qid").innerHTML) + "&all=true");
}

