function index_sample_go(p) {
	qv=document.getElementById('index_sample'+p).innerText?document.getElementById('index_sample'+p).innerText:document.getElementById('index_sample'+p).firstChild.nodeValue;
	if (document.getElementById('q').value==qv) document.getElementById('index_search_form').submit();
	else {
		document.getElementById('q').value=qv;
		document.getElementById('q').focus();
	}
}
function index_show(p) {
	if (window.opera) document.write(p);
	else document.write('<div title="Скопировать этот индекс в буфер обмена" onclick="index_copy(this);">'+p+'</div>');
}
function index_copy(p) {
	var f=0;
	if (window.clipboardData&&window.clipboardData.setData) {
		var ind=p.innerHTML;
		window.clipboardData.setData('Text',ind);
		if (window.clipboardData.getData('Text')==ind) {
			alert('Индекс '+ind+' успешно скопирован в буфер обмена.');
			f=1;
		}
	}
	if (f==0) {
		if (typeof (window.getSelection)=='function') {
			window.getSelection().selectAllChildren(p);
		}
		else {
			var r=document.body.createTextRange();
			r.moveToElementText(p);
			r.select();
		}
	}
}
function index_doma(p) {
//	if (document.getElementById('d'+p).style.display=='block') document.getElementById('d'+p).style.display='none';
//	else document.getElementById('d'+p).style.display='block';
//	document.getElementById('footer').style.bottom=0;
	if (p!='') {
		if (document.getElementById('d'+p).style.display=='block') document.getElementById('d'+p).style.display='none';
		else {
			if (document.getElementById('d'+p).innerHTML=='') {
				document.getElementById('d'+p).innerHTML='Подождите, пожалуйста, несколько секунд...';
				document.getElementById('d'+p).style.display='block';
				var req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
				req.onreadystatechange = function() {
					if (req.readyState == 4) {
						var rt=req.responseText;
						if (rt!='') document.getElementById('d'+p).innerHTML=rt;
						else document.getElementById('d'+p).innerHTML='Информация не найдена.';
					}
				}
				req.open('GET', '/index.py?a=default&sa=ujax_doma&id='+p, true);
				req.send(null);
			}
			else document.getElementById('d'+p).style.display='block';
		}
	}



}
function check_search_q(p) {
	f=0;
	if (p.value.length<3) {
		alert('Пожалуйста, введите поисковый запрос: 6 цифр индекса или название населённого пункта или улицы (как минимум 3 символа).');
		f=1;
	}
	else if (/^[0-9]+$/.test(p.value) && p.value.length!=6) {
		alert('Пожалуйста, введите все 6 цифр индекса.');
		f=1;
	}
	if (f==1) {
		p.focus();
		return false;
	}
	else return true;
}
