function getPubhouse(id_pubhouse) {
	txt       = document.forms.filter.txt.value;
	pubhouses = document.getElementById("select-pubhouse");
	document.forms.diagram.txt.value = txt;
	pubhouses.innerHTML = "<center>Загрузка... <img src='http://img.labirint.ru/design/upload.gif'></center>";
	JsHttpRequest.query(
		"/obmb/diagram/getpubhouse.php",
		{ "txt": txt },
		function (result, errors) 
		{
			pubhouses = document.getElementById("select-pubhouse");
			if (result.err=='no')
			{
				pubhouses.innerHTML = result.html;
				document.forms.filter.id_pubhouse.value=id_pubhouse;
				document.getElementById('id_p').focus();
				var a = document.forms.filter.id_pubhouse.value;
				if(a>0){
					document.getElementById('but').disabled = false;
				}
				else{
					document.getElementById('but').disabled = true;
				}
			}
			else
			{
				pubhouses.innerHTML = result.log;
			}
		},
		true
	);
}


function shoping(id_tov, check, retail) {
	if (check=="") {check=0;}
	var imho=0
	if (check>1) {	var imho=check}
	if (retail>1000) var charity=retail;
	else var charity=0;
	
	if (check==1) {
		var urlnavi="/buy.php?check=1&s=1&id=" + id_tov + "&charity=" + charity;
		window.location=urlnavi;
		if (charity==0) {
			if (document.getElementById('basket-in-cart-a')) {
				var bcount=parseInt(document.getElementById('basket-in-cart-a').innerHTML)
				document.getElementById('basket-in-cart-a').innerHTML=bcount+1;
			}
			var buy="buy"+id_tov;
			for (i=0;i<document.getElementsByTagName('span').length; i++) {
				qq=document.getElementsByTagName('span')[i];
				if (qq.id==buy) {qq.innerHTML=((retail ==1 )  ? '<a href=\"/retail/basket/\">В корзине</a>' : '<a href=\"/basket/\">В корзине</a>');}
			}
		}
	}
	else {
		JsHttpRequest.query(
			"/buy.php",
			{ "id": id_tov,
			  "imho": imho,
			  "s": 1,
			  "charity": charity},
			function (result, errors) 
			{
				if (result.err=='no')
				{	
					//if (result.books_limit==0) {
						if (document.getElementById('basket-in-cart-a')) {
							var bcount=parseInt(document.getElementById('basket-in-cart-a').innerHTML)
							
							document.getElementById('basket-in-cart-a').innerHTML = bcount + 1;
						}
						
						if (document.getElementById('basket-in-dreambox-a') && result.put_book == 1) {
							var bcount=parseInt(document.getElementById('basket-in-dreambox-a').innerHTML)
							document.getElementById('basket-in-dreambox-a').innerHTML = bcount + 1;
						}
						
						if (document.getElementById('fullsumprice') && document.getElementById('discsumprice').innerHTML && result.fullsumcena && result.sumcena) {
							document.getElementById('fullsumprice').innerHTML = result.fullsumcena;
							document.getElementById('discsumprice').innerHTML = result.sumcena;
						}
						
						var buy="buy"+id_tov;
						var buychar="buychar"+id_tov+charity;
						for (i=0;i<document.getElementsByTagName('span').length; i++) {
							qq=document.getElementsByTagName('span')[i];
							if (qq.id==buy) {
								if (check==20) qq.innerHTML=((retail ==1 )  ? '<a href=\"/retail/basket/\">В корзине</a>' : '<a target=\"_blank\" href=\"/basket/\">В корзине</a>');
								else qq.innerHTML=((retail ==1 )  ? '<a href=\"/retail/basket/\">В корзине</a>' : '<a href=\"/basket/\">В корзине</a>');
							}
							if (qq.id==buychar) {
								if (check==20) qq.innerHTML=((retail ==1 )  ? '<a href=\"/retail/basket/\">В корзине</a>' : '<a target=\"_blank\" href=\"/basket/\">В корзине</a>');
								else qq.innerHTML=((retail ==1 )  ? '<a href=\"/retail/basket/\">В корзине</a>' : '<a href=\"/basket/\">В корзине</a>');
							}
						}
					//}
					//else {
					//	alert("В корзину нельзя положить более 250 товаров!");
					//}
					
				}
				else {
					var buy="buy"+id_tov;
					for (i=0;i<document.getElementsByTagName('span').length; i++) {
						qq=document.getElementsByTagName('span')[i];
						if (qq.id==buy) {qq.innerHTML='<a href=\"/helpgopage/support/\">Купить</a>';}
					}	
				}
			},
			true
		);
	}
}


function shoping2(id_tov) { 

	JsHttpRequest.query(
		"/buy.php",
		{ "ido": id_tov,
		  "s": 1},
		function (result, errors) 
		{
			if (result.err=='no')
			{
				if (document.getElementById('basket-in-cart-a')) {
					var bcount=parseInt(document.getElementById('basket-in-cart-a').innerHTML)
					document.getElementById('basket-in-cart-a').innerHTML=bcount+1;
				}
				
				var buy="buyof"+id_tov;
				document.getElementById(buy).innerHTML="<a href=\"/basket/\">В корзине</a>";
			}
		},
		true
	);
}

function getSubGenres(more_genre) {
	if (document.getElementById('gl'+more_genre).innerHTML.length>0) {
		document.images['gi'+more_genre].src='http://img.labirint.ru/design/plus.gif';
		document.getElementById('gl'+more_genre).innerHTML='';
		document.getElementById('gl'+more_genre).style.display='none';
	}
	else {
		document.images['gi'+more_genre].style.visibility="hidden";
	
		JsHttpRequest.query(
			"/catalog/genretree.php",
			{ "more_genre": more_genre},
			function (result, errors) 
			{
				if (result.err=='no')
				{
					document.getElementById('gl'+more_genre).style.display='block';
					document.images['gi'+more_genre].style.visibility="visible";
					document.images['gi'+more_genre].src='http://img.labirint.ru/design/minus.gif';
					document.getElementById('gl'+more_genre).innerHTML=result.html;	
				}
			},
			true
		);
	}
}



function sumPM(id, ido, idc, quant) {
	if (document.getElementById('del'+id) && id) {
		if (quant == 0) document.getElementById('del'+id).checked=1;
		if (document.getElementById('del'+id).checked && quant>0) document.getElementById('del'+id).checked=0;
	}
	
	if (document.getElementById('delo'+ido) && ido) {
		if (quant == 0) document.getElementById('delo'+ido).checked=1;
		if (document.getElementById('delo'+ido).checked && quant>0) document.getElementById('delo'+ido).checked=0;
	}
	
	if (document.getElementById('delc'+idc) && idc) {
		if (quant == 0) document.getElementById('delc'+idc).checked=1;
		if (document.getElementById('delc'+idc).checked && quant>0) document.getElementById('delc'+idc).checked=0;
	}
	
	JsHttpRequest.query(
		"/basket/sumPM.php",
		{ "id": id,
		  "ido": ido,
		  "idc": idc,
		  "quant": quant},
		function (result, errors) 
		{
			
			if (result.err=='no')
			{
				if(document.getElementById('summassa')) {document.getElementById('summassa').innerHTML='<strong>масса:</strong>&nbsp;<span class=\"plashka-number\">' + result.massa + '</span>&nbsp;г.';}
				if(document.getElementById('sumprice1')) {document.getElementById('sumprice1').innerHTML='<strong>Cтоимость:</strong>&nbsp;<span class=\"plashka-number\">' + result.scena + '</span>&nbsp;р.';}
				if(document.getElementById('sumprice1_discount')) {document.getElementById('sumprice1_discount').innerHTML=result.scena;}
				
				if (result.nprice!='' && id>0 && document.getElementById('k'+id)) {document.getElementById('k'+id).innerHTML='&nbsp;' + result.nprice;}
				
				if (id>0 && document.getElementById('q'+id)) {
					if (result.quant_msg!='') {
						//document.getElementById('q'+id).value= result.quant;
						document.getElementById('quant_msg').innerHTML= "<div style='padding:10px 20px;'>"+result.quant_msg+"</div>";
						document.getElementById('quant_msg').style.display= 'block';
					}
					else {
						document.getElementById('quant_msg').innerHTML= '';
						document.getElementById('quant_msg').style.display= 'none';
					}
				}
				
				if (document.getElementById('fullsumprice') && document.getElementById('discsumprice').innerHTML && result.fullsumcena && result.sumcena) {
					  document.getElementById('fullsumprice').innerHTML = result.fullsumcena;
					  document.getElementById('discsumprice').innerHTML = result.sumcena;
				  }
				
				if (idc>0 && document.getElementById('qc'+idc)) {
					if (result.quant_msg!='') {
						//document.getElementById('qc'+idc).value= result.quant;
						document.getElementById('quant_msg').innerHTML= "<div style='padding:10px 20px;'>"+result.quant_msg+"</div>";
						document.getElementById('quant_msg').style.display= 'block';
					}
					else {
						document.getElementById('quant_msg').innerHTML= '';
						document.getElementById('quant_msg').style.display= 'none';
					}
				}
				
				if (document.getElementById('corpdiscount')) {
					if (result.bolshe20==1) {
						document.getElementById('corpdiscount').innerHTML = '<div style=\"padding: 20px 0px 0px 0px;\">Активирована <b>10%</b> корпоративная скидка на товары в количестве от 20 штук.</div>';
					}
					else {
						document.getElementById('corpdiscount').innerHTML = '';
					}
				}
				
				if (result.scenaNoDis!='' && document.getElementById('sumprice_no_discount')) {document.getElementById('sumprice_no_discount').innerHTML=result.scenaNoDis;}
				if (document.getElementById('sertif_str')) document.getElementById('sertif_str').innerHTML=result.sertif_str;
				
				if (document.getElementById('viva')) {
					if (result.show_viva=='') {
						document.getElementById('viva').style.display='none';
						document.getElementById('viva').innerHTML='';
						//document.forms.asd.wantVia.checked=0;
					}
					else {
						document.getElementById('viva').innerHTML=result.show_viva;
						document.getElementById('viva').style.display='block';
					}
				}
				
				if (document.getElementById('AudioConsal')) {
					if (result.metka_AudioConsal==1) document.getElementById('AudioConsal').style.display= 'block';
					else document.getElementById('AudioConsal').style.display= 'none';
				}
				if (document.getElementById('charity_present')) {
					if (result.havecharity>0) document.getElementById('charity_present').style.display= 'block';
					else document.getElementById('charity_present').style.display= 'none';
				}
				if (document.getElementById('egmont_bonus')) { // && result.egmont_bonuses
					document.getElementById('egmont_bonus').innerHTML = result.egmont_bonuses;
					
					if (!result.egmont_bonuses && document.getElementById('bonus_list').innerHTML == '') document.getElementById('bonus').style.display= 'none';
					else document.getElementById('bonus').style.display= 'block';
				}
				if (document.getElementById('woman_day')) {
					if (result.woman_day==1) document.getElementById('woman_day').style.display= 'block';
					else document.getElementById('woman_day').style.display= 'none';
				}
			}
		},
		true
	);
}

function BookSumPM(id, quant) {
	JsHttpRequest.query(
		"/basket/sumPM.php",
		{ "id_basket": id,
		  "quant": quant},
		function (result, errors) 
		{
			
			if (result.err=='no')
			{
				if(document.getElementById('summassa')) {document.getElementById('summassa').innerHTML='<strong>масса:</strong>&nbsp;<span class=\"plashka-number\">' + result.massa + '</span>&nbsp;г.';}
				if(document.getElementById('sumprice1')) {document.getElementById('sumprice1').innerHTML='<strong>Cтоимость:</strong>&nbsp;<span class=\"plashka-number\">' + result.scena + '</span>&nbsp;р.';}
				if(document.getElementById('sumprice1_discount')) {document.getElementById('sumprice1_discount').innerHTML=result.scena;}
				
				if (result.nprice!='' && id>0 && document.getElementById('k'+id)) {document.getElementById('k'+id).innerHTML='&nbsp;' + result.nprice;}
				
				if (id>0 && document.getElementById('q'+id)) {
					if (result.quant_msg!='') {
						document.getElementById('quant_msg').innerHTML= "<div style='padding:10px 20px;'>"+result.quant_msg+"</div>";
						document.getElementById('quant_msg').style.display= 'block';
					}
					else {
						document.getElementById('quant_msg').innerHTML= '';
						document.getElementById('quant_msg').style.display= 'none';
					}
				}
				
				if (document.getElementById('fullsumprice') && document.getElementById('discsumprice').innerHTML && result.fullsumcena && result.sumcena) {
					  document.getElementById('fullsumprice').innerHTML = result.fullsumcena;
					  document.getElementById('discsumprice').innerHTML = result.sumcena;
				  }
				
				if (result.scenaNoDis!='' && document.getElementById('sumprice_no_discount')) {document.getElementById('sumprice_no_discount').innerHTML=result.scenaNoDis;}
				if (document.getElementById('sertif_str')) document.getElementById('sertif_str').innerHTML=result.sertif_str;
				
				if (document.getElementById('viva')) {
					if (result.show_viva=='') {
						document.getElementById('viva').style.display='none';
						document.getElementById('viva').innerHTML='';
					}
					else {
						document.getElementById('viva').innerHTML=result.show_viva;
						document.getElementById('viva').style.display='block';
					}
				}
				
				
			}
		},
		true
	);
}


function psumPM(id, ido, idc, quant) {

	JsHttpRequest.query(
		"/pbasket/sumPM.php",
		{ "id": id,
		  "ido": ido,
		  "idc": idc,
		  "quant": quant},
		function (result, errors) 
		{
			if (result.err=='no')
			{
				if(document.getElementById('summassa')) {document.getElementById('summassa').innerHTML='<strong>масса:</strong>&nbsp;<span class=\"plashka-number\">' + result.massa + '</span>&nbsp;г.';}
				if(document.getElementById('sumprice1')) {document.getElementById('sumprice1').innerHTML='<strong>Cтоимость:</strong>&nbsp;<span class=\"plashka-number\">' + result.scena + '</span>&nbsp;р.';}
				if(document.getElementById('sumprice1_discount')) {document.getElementById('sumprice1_discount').innerHTML=result.scena;}
				
				if (result.nprice!='' && id>0 && document.getElementById('k'+id)) {document.getElementById('k'+id).innerHTML='&nbsp;' + result.nprice;}
				
				if (document.getElementById('corpdiscount')) {
					if (result.bolshe20==1) {
						document.getElementById('corpdiscount').innerHTML = '<div style=\"padding: 20px 0px 0px 0px;\">Активирована <b>10%</b> корпоративная скидка на товары в количестве от 20 штук.</div>';
					}
					else {
						document.getElementById('corpdiscount').innerHTML = '';
					}
				}
				
				if (result.scenaNoDis!='' && document.getElementById('sumprice_no_discount')) {document.getElementById('sumprice_no_discount').innerHTML=result.scenaNoDis;}
				document.getElementById('sertif_str').innerHTML=result.sertif_str;
				
				if (document.getElementById('viva')) {
					if (result.show_viva==1) {
						document.getElementById('viva').style.display='block';
					}
					else {
						document.getElementById('viva').style.display='none';
						document.forms.asd.wantVia.checked=0;
					}
				}
			}
		},
		true
	);
}




// Запись в базу статистики по отказавшимся от больших обложек
function big_pics_stat(UserSes, dontshow) { 
	JsHttpRequest.query(
		"/catalog/big_pics_stat.php",
		{ "UserSes": UserSes,
		  "dontshow": dontshow },
		function (result, errors) { },
		true
	);
}


// Голосование - оценка книги
function sendvote(id_books, votemark) { 
	//votediv = document.getElementById("product-voting-body");
	//votediv.innerHTML = "<img src='http://img.labirint.ru/design/upload.gif'> Загрузка...";

	JsHttpRequest.query(
		"/catalog/vote.ajax.php",
		{ 	"book":id_books,
			"votemark":votemark },
		function (result, errors) {
			if (result.err=='no')
			{
				document.getElementById("rate").innerHTML = result.rate;
				document.getElementById("countmarks").innerHTML = "Всего: " + result.countmarks;
				document.getElementById("count-marks-label").innerHTML = "Ваша оценка: " + result.your_mark;
				your_mark = result.your_mark * 1;
				outstar();
			}
		},
		true
	);
}


function disagreement(oneStepInf) { 

	//JsHttpRequest.query(
//		"/basket/user_disagreement.php",
//		{ 	"oneStepInf":oneStepInf	},
//		function (result, errors) {
//			if (result.err=='no')
//			{
//				//alert(result.mess);
//			}
//		},
//		true
//	);
}

function send_mailticket(id_order) {
	JsHttpRequest.query(
		"/cabinet/send_mailticket.php",
		{ 	"id_order":id_order	},
		function (result, errors) {
			if (result.err=='no')
			{
				//alert(result.mess);
			}
		},
		true
	);
}

var is_typing = 0;
var is_sended = 0;

function list_timeout(path, e, adm){
	is_typing++;
	var txt = document.forms.list_search.lit.value;
	var text_k = e.keyCode;
	//alert(text_k);
	if(text_k != 16 && text_k != 17 && text_k != 18 && text_k != 13 && text_k != 20 && text_k != 192 && text_k != 37 && text_k != 38 && text_k != 39 && text_k != 40 && text_k != 116){
		setTimeout("waaait('"+path+"', "+is_typing+", '"+adm+"')", 500);
	}
}

function waaait(path, n, adm) {
	if (is_typing == n) { list_change(path, adm); }
}

function list_change(path, adm){
	
	txt  = document.forms.list_search.lit.value;
	if(txt.length > 2){
		text = document.getElementById("list_text");
		var list = document.getElementById("list_rows");
		list.innerHTML = "<br><br><center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload_big.gif'></center>";
		
		JsHttpRequest.query(
			adm + "/catalog/list_change.php",
			{ "txt"  : txt,
			  "path" : path,
			  "adm"	 : adm
			},
			function (result, errors) 
			{
				list = document.getElementById("list_rows");
				if (result.err=='no')
				{
					list.innerHTML = '';
					list.innerHTML = result.html;
				}
				else
				{
					pubhouses.innerHTML = result.log;
				}
			},
			true
		);
	}
}

function commentVote(id_comment, voting, best, thanks){
	//alert("id_comment = "+id_comment);
	//alert("voting = "+voting);
	var voting_div = document.getElementById("comment_vote" + id_comment);
	var user_mark  = document.getElementById("user_mark" + id_comment);
	var comm_mark  = document.getElementById("comment_mark" + id_comment);
	if(best == 1){
		var best_table = document.getElementById("best");
	}
	voting_div.innerHTML = "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"> Загрузка...&nbsp; <img style=\"float: none; border: 0px solid #cccccc; margin:0;\" src='http://img.labirint.ru/design/upload_old.gif'></center>";
	
	JsHttpRequest.query(
		"/catalog/commentVote.ajax.php",
		{
		  "id_comment" : id_comment,
		  "voting"	   : voting,
		  "best"       : best
		},
		function (result, errors) {
			//voting = document.getElementById("list_rows");
			
			if (result.err=='no'){
				voting_div.innerHTML   = '';
				voting_div.innerHTML   = result.html;
				user_mark.innerHTML    = result.user_thanks;
				user_mark.style.color  = result.user_thanks_color;
				user_mark.style.weight = 'bold';

				
				comm_mark.innerHTML    = result.comment_thanks;
				comm_mark.style.color  = result.comment_thanks_color;
				comm_mark.style.weight = 'bold';



				if(best == 1){
					best_table.innerHTML   = result.best;
				}
				
			}
			else{
				voting_div.innerHTML = result.log;
			}
		},
		true
	);
}

function deleteCommentPic(id_comment, id_pic){
	var commentPic  = document.getElementById("commentPic" + id_pic);
	var commentPics = document.getElementById("commentPics");
	commentPic.innerHTML = "<div style=\"font: 12px Arial, Helvetica, sans-serif;\"> Удаление...&nbsp; <img style=\"float: none; border: 0px solid #cccccc; margin:0;\" src='http://img.labirint.ru/design/upload.gif'></div>";
	
	JsHttpRequest.query(
		"/catalog/commentDelPic.ajax.php",
		{
		  "id_comment" : id_comment,
		  "id_pic"	   : id_pic
		},
		function (result, errors) {			
			if (result.err=='no'){
				commentPic.innerHTML     = '';
				commentPic.innerHTML     = result.html;
				commentPics.style.border = result.border;
			}
			else{
				commentPic.innerHTML = result.log;
			}
		},
		true
	);
}

function be_Paid(id_order,param){	
	JsHttpRequest.query(
		"/cabinet/be_paid.php",
		{
		  "id_order" : id_order
		},

		function (result, errors) {
			if (result.err=='no')
			{
				if (param==1) document.forms.form1.submit();
			}
		},
		true
	);
}

function CabinetMess(id_order,mess) {
	document.getElementById('MessForm').style.visibility='hidden';
	document.getElementById('MessForm').style.position='absolute';
	document.getElementById('MessTXT').innerHTML="<center><img src='http://img.labirint.ru/design/upload.gif'></center>";
	
	JsHttpRequest.query(
		"/cabinet/cabinet_mess.php",
		{ 	"id_order":id_order, "mess": mess	},
		function (result, errors) {
			if (result.err=='no')
			{	
					document.forms.newMessForm.mess.value='';
					document.getElementById('MessTXT').innerHTML="Сообщение отправлено.<br/>Окно автоматически закроется через 3 секунды<br/><br/><input type='button' value=\"Закрыть\" class='red-button' onClick='document.getElementById(\"newMess\").style.visibility=\"hidden\";'/>";
					setTimeout("document.getElementById('newMess').style.visibility='hidden'; document.getElementById('MessTXT').innerHTML='';", 3000);
			}
			else {
				document.forms.newMessForm.mess.value='';
				document.getElementById('MessTXT').innerHTML="Не верный номер заказа.<br/><br/><input type='button' value=\"Закрыть\" class='red-button' onClick='document.getElementById(\"newMess\").style.visibility=\"hidden\"; document.getElementById(\"MessForm\").style.visibility=\"visible\";'/>";
			}
		},
		true
	);
}

function subscribeSearch(){
	var txt     = document.getElementById('search_lit').value;
	var type    = document.getElementById('search_item').value;
	var showall = document.getElementById('show-subscribe-genres');
	
	showall.style.display = type == 'genres' ? 'block' : 'none';
	
	if(txt.length > 1){
	
		var text       = document.getElementById('result_select');	
		text.innerHTML = "<center style=\"font: 12px Arial, Helvetica, sans-serif; padding: 55px 0 0 0;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
		
		JsHttpRequest.query(
			"/catalog/subscribeSearch.ajax.php",
			{ 
			  "txt"  : txt,
			  "type" : type
			},
			function (result, errors) 
			{
				if (result.err=='no')
				{
					text.innerHTML = '';
					text.innerHTML = result.html;
				}
				else
				{
					text.innerHTML = result.log;
				}
			},
			true
		);
	}
}

function typeTimeOut(f, e){
	is_typing++;
	var text_k = e.keyCode;
	if(text_k != 16 && text_k != 17 && text_k != 18 && text_k != 20 && text_k != 192 && text_k != 37 && text_k != 38 && text_k != 39 && text_k != 40 && text_k != 116){
		setTimeout("type_waaait("+is_typing+", "+f+")", 500);
	}
}

function type_waaait(n, f) {
	
	if (is_typing == n) { f(); }
}

function catalogSearch() {

	var txt     = document.getElementById('search_lit').value;
	var type    = document.getElementById('search_item').value;

	if(txt.length > 1){
		
		$("#search_lit").attr("class", "ajax_input_dis");
		ccount = 0;
		startBar('search_lit');
	
		var text       = document.getElementById('result_select');	
		text.innerHTML = "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
		
		JsHttpRequest.query(
			"/partner/catalogSearch.ajax.php",
			{ 
			  "txt"  : txt,
			  "type" : type
			},
			function (result, errors) 
			{
				if (result != undefined && result.err == undefined) {
					text.innerHTML = '';
					if (result.err == undefined) {
						$("<div></div>")
							.html("<b>Результат поиска: </b> <br />Нажмите \"+\" для добавления в список Карусели<br /><br />")
							.appendTo($(text));
						for (var ret_item in result.ret) {
							var cont = $("<div></div>").appendTo($(text));
							$("<img />")
								.attr("src", "http://img.labirint.ru/design/user_tags_plus.gif")
								.attr("title", "Добавить в список Карусели")
								.attr("class", "image_button")
								.attr("id", ret_item)
								.click( 
									function () {
										itemAddToList(this, this.id);
									})
								.appendTo($(cont));
							$("<span></span>")
								.attr("value", ret_item)
								.text(result.ret[ret_item])
								.appendTo($(cont));
							$("<a></a>")
								.attr("href", "/" + type + "/" + ret_item + "/")
								.attr("title", "Страница с товарами")
								.attr("target", "_blank")
								.appendTo($(cont))
								.append(
									$("<img />")
										.attr("src", "http://img.labirint.ru/design/popup.png")
										.attr("title", "Страница с товарами")
										.attr("class", "popup")
										.attr("width", 11)
										.attr("height", 10)
									);
						}
						if (result.more) {
							$("<span></span>")
								.attr("class", "more")
								.text(".....")
								.appendTo($(text));
						}
					}
				}
				else {
					text.innerHTML = result.err;
				}
			
				$("#search_lit").attr("class", "ajax_input");
				stopBar('search_lit');
			},
			true
		);
	}
}

function otherSubscribe(type, elem){
	if(elem.checked == true) addToSubscribe(type)
	else DelFromSubscribe(type, 1)
}

function addToGenreSubscribe(id){
	addToSubscribe('genres', id);
	if(!confirm('Жанр добавлен. Продожить?')){
		document.getElementById('hidden-genres').style.display = 'none';
	}
}

function addToSubscribe(type, id){
		
	var list = document.getElementById('result_list');	
	var type = !type ? document.getElementById('search_item').value : type;
	var id   = !id   ? document.getElementById('result').value      : id;
	
	list.innerHTML += "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
	
	id = id ? id : -100;
	
	JsHttpRequest.query(
		"/catalog/subscribeAddItem.ajax.php",
		{ 
		  "act"  : "add",
		  "id"   : id,
		  "type" : type
		},
		function (result, errors) 
		{
			if (result.err=='no')
			{
				list.innerHTML = '';
				list.innerHTML = result.html;
			}
			else
			{
				list.innerHTML = result.log;
			}
		},
		true
	);
}

function DelFromSubscribe(type, id){
		
	var list = document.getElementById('result_list');	
	list.innerHTML += "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
	
	JsHttpRequest.query(
		"/catalog/subscribeAddItem.ajax.php",
		{ 
		  "act"  : "del",
		  "id"   : id,
		  "type" : type
		},
		function (result, errors) 
		{
			if (result.err=='no')
			{
				list.innerHTML = '';
				list.innerHTML = result.html;
			}
			else
			{
				list.innerHTML = result.log;
			}
		},
		true
	);
}

/* корзина sms*/
function chkSmsNumer() {
	var phone = '7' + $('#smsphone_code').val() + $('#smsphone_end').val();

	phone = !isNaN(phone) && phone.length==11 && phone.substr(0,2)=='79' ? phone : null;

	if (phone) {
		$("#phonesdiv").attr("class", "phoneg");
		$("#phonestat").html("верный формат");
	}
	else {
		$("#phonesdiv").attr("class", "phoneb");
		$("#phonestat").html("не соответствует формату");
	}
	
	return phone;
}

function changeSmsNumber(e) {
	var text_k = e.keyCode;
	if(text_k != 16 && text_k != 18 && text_k != 13 && text_k != 20 && text_k != 192 && text_k != 37 && text_k != 38 && text_k != 39 && text_k != 40 && text_k != 116){
		chkSmsNumer();
	}
}

function saveNumber() {
	var phone = chkSmsNumer();
	if (!phone) {
		alert('Неверный формат телефона!');
		return false;
	}
	$("#sendSMS").addClass("content_upload");
	JsHttpRequest.query(
		"/basket/chekPhone4SMS.php", { "phone": phone, "save": 1 },
		function(result, errors) {
			if (result.err != 'no') {
				if (result.err) alert(result.err);
			}
			else {
				clearWindow("sendSMS");
				$('#smscbx').attr('checked', 1);
			}
			$("#sendSMS").removeClass("content_upload");
		},
		true
	);
}

function smsChange() {
	if ($('#smscbx').attr("checked")) {
		var phone = chkSmsNumer();
		if (!phone) {
			$('#smscbx').attr("checked", "");
			overlayWindow("sendSMS");
		}
		else saveNumber();
	}
}
/* конец корзина sms*/

function dont_puBooks(dontshow) {
	if (dontshow) dont_put=1; 
	else dont_put=0; 
	
	JsHttpRequest.query(
		"/cabinet/dont_putBooks.php",
		{"dont_put"  : dont_put},
		function (result, errors) {},
		true
	);
}


function geoTargetingTimeOut(type,e){
	is_typing++;
	var text_k = e.keyCode;

	if(text_k != 16 && text_k != 17 && text_k != 18 && text_k != 13 && text_k != 20 && text_k != 192 && text_k != 37 && text_k != 38 && text_k != 39 && text_k != 40 && text_k != 116){
		setTimeout("geoTargeting_waaait('"+type+"',"+is_typing+")", 500);
	}
}

function geoTargeting_waaait(type,n) {
	if (is_typing == n) { geoTargetingSearch(type, 0); }
}

function geoTargetingSearch(type, id_rule){
	var txt      = document.getElementById(type).value;
	var id_rule  = id_rule > 0 ? id_rule : null;
	
	if(txt.length){
		
		var text = document.getElementById('result_' + type);
		
		text.innerHTML = "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
		JsHttpRequest.query(
			"geoTargeting.ajax.php",
			{ 
			  "txt"     : txt,
			  "type"    : type,
			  "id_rule" : id_rule
			},
			function (result, errors) 
			{
				if (result.err=='no')
				{
					if(id_rule){
						document.getElementById(type).value = '';	
					}
					
					text.innerHTML = '';
					text.innerHTML = result.html;
				}
				else
				{
					text.innerHTML = result.log;
				}
			},
			true
		);
	}
}


function showChildGenre(id){
	var div = document.getElementById('genre'+id);	
	div.innerHTML += "<br><center style=\"font: 12px Arial, Helvetica, sans-serif;\"><img src='http://img.labirint.ru/design/upload.gif'></center>";
		
	JsHttpRequest.query(
		"/catalog/subscribeGenres.ajax.php",
		{ 
		  "id"  : id,
		  "act" : "show"
		},
		function (result, errors) 
		{
			if (result.err=='no')
			{				
				div.innerHTML = '';
				div.innerHTML = result.html;
			}
			else
			{
				div.innerHTML = result.log;
			}
		},
		true
	);
}

function hidChildGenre(id){
	var div = document.getElementById('genre'+id);	
	var hid = document.getElementById('genrehid'+id);
	
	hid.innerHTML = '';
	
	JsHttpRequest.query(
		"/catalog/subscribeGenres.ajax.php",
		{ 
		  "id"  : id,
		  "act" : "hid"
		},
		function (result, errors) 
		{
			if (result.err=='no')
			{				
				div.innerHTML = '';
				div.innerHTML = result.html;
			}
			else
			{
				div.innerHTML = result.log;
			}
		},
		true
	);
}

function add_user_tag(form, id_books) {
	var tag = form.tag.value;
	
	JsHttpRequest.query(
		"/catalog/userTags.ajax.php",
		{ 	"func"     : "addTag", 
			"id_books" : id_books, 
			"tag"      : tag },
		function (result, errors) 
		{
			if (result.err == undefined) {
				var cont = document.getElementById("tags-add-cont");
				var user_tags_main = document.getElementById("user-tags-main");
				
				if (document.getElementById("tags-added") == undefined) {
					var tags_added = document.createElement("div");
					tags_added.setAttribute("id", "tags-added");
					cont.insertBefore(tags_added, cont.firstChild);

					var tags_added_head = document.createElement("span");
					tags_added_head.setAttribute("id", "tags-added-head");
					tags_added.appendChild(tags_added_head);
					tags_added_head.innerHTML = "Добавлены: ";
					
					if (document.getElementById("all-tags") == undefined) {
						user_tags_main.className = "";
						
						var user_tags_bottom = document.getElementById("user-tags-bottom");
						var all_tags = document.createElement("div");
						all_tags.setAttribute("class", "right");
						user_tags_bottom.appendChild(all_tags);
						var all_tags_link = document.createElement("a");
						all_tags_link.setAttribute("href", "/tags/books/" + id_books + "/");
						all_tags_link.innerHTML = "Все метки...";
						all_tags.appendChild(all_tags_link);
					}
					else
					{
						var tn1 = document.createTextNode(", ");
						user_tags_main.appendChild(tn1);
					}
					
					var tag_added = document.createTextNode(result.tag3);
					tags_added.appendChild(tag_added);
				}
				else {
					var tags_added = document.getElementById("tags-added");
					if (tags_added.lastChild.nodeValue != undefined) {
						tags_added.lastChild.nodeValue = ", " + result.tag3 + " ";
					}
					else {
						var tag_added = document.createTextNode(", " + result.tag3 + " ");
						tags_added.appendChild(tag_added);
					}
					
					var tn1 = document.createTextNode(", ");
					user_tags_main.appendChild(tn1);
				}
				
				var added_delimg = document.createElement("img");
				added_delimg.setAttribute("src", "http://img.labirint.ru/design/user_tags_minus.gif");
				added_delimg.setAttribute("title", "Удалить метку");
				added_delimg.className = "imgbutton";
				tags_added.appendChild(added_delimg);
				var id = result.id;
				added_delimg.onclick = function() { del_user_tag(added_delimg, id); }
				
				var added_tag_link = document.createElement("a");
				added_tag_link.setAttribute("href", "/usertags/" + result.tagurl + "/");
				added_tag_link.innerHTML = result.tag2;
				user_tags_main.appendChild(added_tag_link);
				
				form.tag.value = "";
			}
			else {
				alert(result.err);
			}
		},
		true
	);
}

function del_user_tag(delimg, id) {

	JsHttpRequest.query(
		"/catalog/userTags.ajax.php",
		{ 	"func" : "delTag", 
			"id"   : id },
		function (result, errors) 
		{
			if (result.err == undefined) {
				var tags_added = document.getElementById("tags-added");
				if (delimg && delimg.previousSibling != undefined) {
					var txt = delimg.previousSibling;

					if (txt.previousSibling != undefined && txt.previousSibling.id == "tags-added-head" && delimg.nextSibling != undefined) {
						delimg.nextSibling.nodeValue = delimg.nextSibling.nodeValue.substring(2);
					}
					
					tags_added.removeChild(delimg);
					tags_added.removeChild(txt);
				}
			}
			else {
				alert(result.err);
			}
		},
		true
	);
}

function sendInquirer(id, result){
	var inquirer = document.getElementById('inquirer-questions');
	var anons    = document.getElementById('inquirer-anons');
	var arr  = Array();
	var arr2 = Array();
	var name0;
	var i = 1;
	
	$("input[@name^=que]:checked").each(
		function () {
			name = $(this).attr("name");
			name = name.replace('que','');
			if(name == name0){
				arr[name][i] = $(this).attr("value");
				i++;
			}
			else{
				arr[name] = Array();	
				arr[name][0] = $(this).attr("value");
			}
			
			name0 = name; 
		}
	);	
	
	$("textarea[@name^=que]").each(
		function () {
			if($(this).attr("value")){
				name = $(this).attr("name");
				name = name.replace('que','')
				arr[name] = Array();
				arr[name][0] = $(this).attr("value");
			}
		}
	);			
		
	if(arr.length > 0){
		
		inquirer.style.height = "500px"; 
		inquirer.innerHTML    = "<center style=\"font: 12px Arial, Helvetica, sans-serif; vertical-align: middle;\"><img style='vertical-align: middle; margin-top: 200px;' src='http://img.labirint.ru/design/upload_big.gif'></center>";
		
		JsHttpRequest.query(
			"/catalog/inquirer.ajax.php",
			{ 	"func"   : "delTag", 
				"id"     : id,
				"que"    : arr,
				"result" : result
			},
		function (result, errors) {
			if (result.err=='no')
			{
				inquirer.innerHTML    = '';
				inquirer.innerHTML    = result.html;
				//anons.innerHTML       = '';
				inquirer.style.height = "auto"; 
			}
			else
			{
				inquirer.innerHTML = result.log;
			}
		},
		
		true
		);
	}
	else{
		alert('Ничего не выбрано');	
	}
}

function rShowChildGenre(id) {
	var div = $("#genre" + id);
	
	if (div.children("div:last").length > 0) {
		if (div.children("div:last").css("display") == "none") {
			div.children("div:last").css("display", "block");
			div.children("img:first").attr("src", "http://img.labirint.ru/design/minus.gif");
		}
		else {
			div.children("div:last").css("display", "none");
			div.children("img:first").attr("src", "http://img.labirint.ru/design/plus.gif");
		}
	}
	else {
		JsHttpRequest.query(
			"/partner/selectGenres.ajax.php",
			{ "id"  : id },
			function (result, errors) 
			{
				if (result != undefined && result.err == undefined) {
					if (result.err == undefined) {
						$("img:first", div).attr("src", "http://img.labirint.ru/design/minus.gif");
						div.append(result.html);
					}
				}
				else {
					text.innerHTML = result.err;
				}
			},
			true
		);
	}
}

function rAddSearchString(form) {
	var search_string = form.search_string.value;

	$(form.search_string).attr("class", "ajax_input_dis");
	ccount = 0;
	startBar('search_string');
	
	JsHttpRequest.query(
		"/partner/catalogSearch.ajax.php",
		{ 
			"txt"  : search_string,
			"type" : "search"
		},
		function (result, errors) 
		{
			if (result != undefined && result.err == undefined) {
				if (result.err == undefined) {
					if ($("#selected_items_head").css("display") == "none") {
						$("#selected_items_head").css("display", "block");
					}
					$("<input type=\"checkbox\" />")
						.attr("name", "items[]")
						.attr("value", search_string)
						.appendTo($("#selected_items"))
						.attr("checked", 1);
					$("#selected_items").append("\"" + search_string + "\" (" + result.c + ")");
					$("<a></a>")
						.attr("href", "/search/?txt=" + search_string)
						.attr("title", "Страница поиска")
						.attr("target", "_blank")
						.appendTo($("#selected_items"))
						.append(
							$("<img />")
								.attr("src", "http://img.labirint.ru/design/popup.png")
								.attr("title", "Страница с товарами")
								.attr("class", "popup")
								.attr("width", 11)
								.attr("height", 10)
							)
						.append($("<br />"));
					$(form.search_string).attr("value", "");
				}
			}
			else {
				alert(result.err);
			}
			
			$(form.search_string).attr("class", "ajax_input");
			stopBar('search_string');
			$(form.search_string).focus();
		},
		true
	);
}

var ccount = 0;
var wwidth = 10;
function startBar(input_name) {
	var tf = $("#" + input_name);
	tf.css("background-position", wwidth + "px 0");
	wwidth -= 20;
	if (!ccount) { setTimeout("startBar('"+input_name+"')", 100); }
}

function stopBar() {
	ccount = 1;
}

function rAddIdBooks(form) {
	var id_books = form.search_string.value;
	
	$(form.search_string).attr("class", "ajax_input_dis");
	ccount = 0;
	startBar('search_string');
	
	JsHttpRequest.query(
		"/partner/catalogSearch.ajax.php",
		{ 
			"txt"  : id_books,
			"type" : "id"
		},
		function (result, errors) 
		{
			if (result != undefined && result.err == undefined) {
				if (result.err == undefined) {
					if ($("#selected_items_head").css("display") == "none") {
						$("#selected_items_head").css("display", "block");
					}
					b=false;
					$("input:checkbox",  "#selected_items").each(
							function () { if ($(this).attr("value")==result.id_books) b=true;}
					);
					if (b==true)
					{
						if (confirm('Уже в списке! Вы точно хотите добавить запись?')==false) b=true;
						else b=false;
					}
					if (b==false && result.rang!=203000000 && result.rang!=205000000)
					{
						if (confirm('Товар "отстутсвует" на складе в данный момент или "ожидается"!\nВы точно хотите добавить этот товар?')==false) b=true;
						else b=false;
					}
					
					if (b==false)
					{
					$("<input type=\"checkbox\" />")
						.attr("name", "items[]")
						.attr("value", result.id_books)
						.appendTo($("#selected_items"))
						.attr("checked", 1);
					$("#selected_items").append(result.id_books + " - " + result.name + " - " + result.price + " руб.");
					$("<a></a>")
						.attr("href", "/books/" + result.id_books + "/")
						.attr("title", "Страница товара")
						.attr("target", "_blank")
						.appendTo($("#selected_items"))
						.append(
							$("<img />")
								.attr("src", "http://img.labirint.ru/design/popup.png")
								.attr("title", "Страница товара")
								.attr("class", "popup")
								.attr("width", 11)
								.attr("height", 10)
							)
						.append($("<br />"));
					}	
					$(form.search_string).attr("value", "");					
				}
			}
			else {
				alert(result.err);
			}
			
			$(form.search_string).attr("class", "ajax_input");
			stopBar('search_string');
			$(form.search_string).focus();
		},
		true
	);
}

function put_book(id_tov) {
	
	JsHttpRequest.query(
		"/buy.php",
		{ "id": id_tov,
		  "put_book": 1},
		function (result, errors) 
		{
			if (result.err=='no')
			{		
				if (document.getElementById('basket-in-dreambox-a') && result.put_book==1) {
					var bcount=parseInt(document.getElementById('basket-in-dreambox-a').innerHTML)
					document.getElementById('basket-in-dreambox-a').innerHTML=bcount+1;
				}
				
				var put="put"+id_tov;
				for (i=0;i<document.getElementsByTagName('span').length; i++) {
					qq=document.getElementsByTagName('span')[i];
					if (qq.id==put) {qq.innerHTML='&nbsp;<a href=\"/cabinet/?vybor=putOrder\" title=\"Перейти в Отложенные\">Отложено</a>';}
				}				
			}
			else {
				var put="put"+id_tov;
				for (i=0;i<document.getElementsByTagName('span').length; i++) {
					qq=document.getElementsByTagName('span')[i];
					if (qq.id==put) {qq.innerHTML='<a href=\"/helpgopage/support/\">Отложить</a>';}
				}	
			}
		},
		true
	);

}

function delivvote(id_order, votemark, type) {

	JsHttpRequest.query(
		"/cabinet/vote.ajax.php",
		{ 	"id_order":id_order,
			"votemark":votemark,
			"type":type},
		function (result, errors) {
			if (result.err=='no')
			{
				document.getElementById("count-marks-label"+id_order+type).innerHTML = "Ваша оценка: " + result.your_mark;
				//document.getElementsByName("delivery_voting")[dv].style.display="none";
				vote_mark[id_order+type] = result.your_mark * 1;
				document.getElementById("delivery_voting_rating"+id_order).innerHTML = (vote_mark[id_order+'a']+vote_mark[id_order+'b']+vote_mark[id_order+'c'])*1;
				deliv_vote_outstar(id_order+type, vote_mark[id_order]);
			}
		},
		true
	);
}

function isSelectMoreThanZero(curtype)
{
	var b=false;
	var selected_items = document.getElementsByTagName('INPUT');
	for (ind in selected_items)
	if (selected_items[ind].name=='items[]')
	{		
		if (selected_items[ind].checked==1) { b=true; break;}
	}
	if (b==false)	
	{
		$("input:checkbox",  document.forms[2]).each(
			function () {
				if ($(this).attr("checked")==1) b=true;
			}
		);
	}
	if (b==true) return true;
	var mas = Array();
	mas['by_author'] = 'одного автора';
	mas['by_search'] = 'одну поисковую фразу';
	mas['by_pubhouse'] = 'одно издательство';
	mas['by_series'] = 'одну серию';
	mas['by_genre'] = 'один жанр';
	mas['by_sgenre_nov'] = 'один супержанр';
	mas['by_sgenre_rate'] = 'один супержанр';
	mas['by_id'] = 'один товар';
	
	alert('Необходимо выбрать хотя бы ' + mas[curtype] + '!');	
	return false;
}

function adviseVote(id){
	//alert("id_comment = "+id_comment);
	//alert("voting = "+voting);
	var voting_div  = document.getElementById("advise_vote" + id);
	var rating      = document.getElementById("rating" + id);
	
	voting_div.innerHTML = "<center style=\"font: 12px Arial, Helvetica, sans-serif;\"> Загрузка...&nbsp; <img style=\"float: none; border: 0px solid #cccccc; margin:0;\" src='http://img.labirint.ru/design/upload_old.gif'></center>";
	
	JsHttpRequest.query(
		"/catalog/commentVote.ajax.php",
		{
		  "id_comment" : id,
		  "type"	   : "advise"
		},
		function (result, errors) {
			//voting = document.getElementById("list_rows");
			
			if (result.err=='no'){
				voting_div.innerHTML   = result.html;
				voting_div.style.color = '#8C8C8C';
				
				rating.innerHTML    = result.rating;
				rating.style.color  = result.color;
				rating.style.weight = 'bold';			
			}
			else{
				voting_div.innerHTML = result.log;
			}
		},
		true
	);
}


function dont_sendmail(id_contact, mailingType)
{
	JsHttpRequest.query(
		"/cabinet/dont_sendmail.php",
		{"id_contact" : id_contact,
		"mailingType" : mailingType},
		function (result, errors) 
		{
		},
		true
	);                                 
}

function comparing(id_tov, sgenre, retail) 
{
	JsHttpRequest.query(
		"/compare.php",
		{"id" : id_tov, 
		"sgenre" : sgenre},
		function (result, errors) 
		{
			var comp="comp"+id_tov;
			for (i=0;i<document.getElementsByTagName('span').length; i++) 
			{
				qq=document.getElementsByTagName('span')[i];
				if (qq.id==comp) 
				{
					var gnres = Array();
					tit = "Перейти к списку сравнения";
					gnres[-1]="books/";gnres[-2]="video/";gnres[-3]="audio/";gnres[-4]="software/";gnres[-5]="games/";gnres[-6]="office/";gnres[-7]="other/";
					qq.innerHTML=(retail == 1 ? '<a href=\"/retail/compare/'+gnres[sgenre]+'\" class=\"addedincomp\" title=\"'+tit+'\"><nobr>Перейти к сравнению</nobr></a>' : '<a href=\"/compare/'+gnres[sgenre]+'\" class=\"addedincomp\" title=\"'+tit+'\"><nobr>Перейти к сравнению</nobr></a>');
				}
			}
			if (result.err!='no') alert(result.err);
		},
		true
	);
}

function getQIWIBill(id_order)
{
	qiwi_newpay = 'qiwi_'+id_order;
	JsHttpRequest.query(
		"/pay/qiwi/index.php",
		{"id_order" : id_order},
		function (result, errors) 
		{
			if (result.err == 'no' && document.getElementById('qiwi_pay')) {
				if (result.status) document.getElementById('qiwi_pay').innerHTML='Счет на оплату не создан, создать счет можно через <a href="/cabinet/?vybor=hist">Личное пространство</a>';
				else document.getElementById('qiwi_pay').innerHTML='Создан счет для оплаты в системе QIWI';
							
				document.getElementById('qiwi_pay').style.display='block';
			}
			else if (result.err == 'no' && document.getElementById(qiwi_newpay)) {
				if (result.status) document.getElementById(qiwi_newpay).innerHTML='Попробуйте позже';
				else document.getElementById(qiwi_newpay).innerHTML='Создан счет';
			}
		},
		true
	);	
}

function addWish(wish){
	if (document.getElementById('participate_contest_warning')) {
		document.getElementById('participate_contest_warning').innerHTML='';				
		document.getElementById('participate_contest_warning').style.display='none';
	}

	var subscription = '';
	if (wish.subscription1.checked) subscription += wish.subscription1.value;
	if (wish.subscription2.checked) subscription += ','+wish.subscription2.value;
	if (wish.subscription3.checked) subscription += ','+wish.subscription3.value;
	if (wish.subscription4.checked) subscription += ','+wish.subscription4.value;
	if (wish.subscription5.checked) subscription += ','+wish.subscription5.value;
	if (wish.subscription6.checked) subscription += ','+wish.subscription6.value;
	if (wish.subscription7.checked) subscription += ','+wish.subscription7.value;
	if (wish.subscription8.checked) subscription += ','+wish.subscription8.value;
	
	JsHttpRequest.query(
		"/basket/addWish.php",
		{"id_order" : wish.id_order.value,
		"subscription" : subscription,
		"wish_txt" : wish.wish_txt.value,
		"pindex" : wish.pindex.value,
		"country" : wish.country.value,
		"pstate" : wish.pstate.value,
		"city" : wish.city.value,
		"street" : wish.street.value,
		"building" : wish.building.value,
		"building_p" : wish.building_p.value,
		"fflat" : wish.fflat.value,
		"lastName" : wish.lastName.value,
		"firstName" : wish.firstName.value,
		"middleName" : wish.middleName.value},
		function (result, errors) 
		{
			if (result.err == 'no' && document.getElementById('participate_contest')) {
				
				if (result.rez_mess) {
					document.getElementById('participate_contest').innerHTML=result.rez_mess;
					if (document.getElementById('dopinfo')) document.getElementById('dopinfo').style.display='block';
					window.scrollTo(0,0);
				}
				if (result.warning_mess && document.getElementById('participate_contest_warning')) {
					document.getElementById('participate_contest_warning').innerHTML=result.warning_mess;				
					document.getElementById('participate_contest_warning').style.display='block';				
				}
			}
		},
		true
	);	
}