function $(id) {return document.getElementById(id)}
function crn (n) { return document.createElement(n) }
function crt (n) { return document.createTextNode(n) }
Node.prototype.ac = function (el) { return this.appendChild(el) }
Node.prototype.crapt = function (t) { return this.appendChild(crt(t)) }
Node.prototype.crapn = function (n, t) { return this.appendChild(crt(n).crapt(t)) }
Node.prototype.sa = function (n, v) { return this.setAttribute(n, v) }

function searchForm (t, pl) {
	if ($('top_search_form')) {
		$('top_search_form').parentNode.removeChild($('top_search_form'));
	} else {
		sForm = crn('form');
		sForm.sa('action', pl + (pl) ? '/en/site_search/' : '/site_search/');
		sForm.sa('method', 'get');
		sForm.sa('id', 'top_search_form');

		sIn = crn('input');
		sIn.sa('type', 'text');
		sIn.sa('name', 'search_string');
		sForm.ac(sIn);

		sSub = crn('input');
		sSub.sa('type', 'submit');
		sSub.sa('value', (pl) ? 'Search' : 'Искать');
		sForm.ac(sSub);

		$('page').ac(sForm);
		sIn.focus();
	}

}

