function $ (Id) {
	return document.getElementById(Id);
}

function turnVisibility (o, b) {
	o.style.display = b ? b : 'none';
}

function play (S, s, b) {
	return b ? (S + ' ' + s) : S.split(' '+s).join('');
}

function scan (o) {
	if (!o) return;
	var a = o.getElementsByTagName('A');
	var l = a.length;
	for (var i = 0; i < l; i++) if (/^\/?dept\/[a-z]+/.test(a[i].pathname)) {
		a[i].href = 'mailto:'+a[i].pathname.split('dept/').pop()+'@spbnet.ru';
	}
}

function word_wrap (s, l, d) {
    var r = new RegExp("(.{"+l+"}\\S*)", "g");
	return s.replace(r, '$1'+d);
}

function escape_tags (s) {
	return 'string' == typeof s ? s.split('<').join('&lt;').split('>').join('&gt;') : s;
}

function search (k, s) {
	if ('string' == typeof s) {
		var p = ('?' == s.substr(0, 1) ? s.substr(1) : s).split('&');
		var l = p.length;
		for (var i = 0; i < l; i++) {
			if (p[i]) {
				var r = p[i].split('=');
				if (unescape(r[0]) == k) {
					return 'undefined' == typeof r[1] ? '' : unescape(r[1]);
				}
			}
		}
	}
	return null;
}
