function ratings_toggle(){
	// todo: optimize this script and markup
	var parent = $(this).parents(".b-rating-main");
	$("ul", parent).hide(); // hide all blocks
	$(".s-" + this.className.split("-")[2], parent).show(); // show needed block
	$(".title", $(this).parent()).hide(); // hide all control "title" spans
	$("a", $(this).parent()).show(); // show all control links
	$(this).hide(); // hide clicked link
	$(this).next().show(); // show "title" span instead of clicked link
	return false;
}

$(function(){
	$(".b-rating-main [class^='s-trigger']").click(ratings_toggle);

	// todo: В будущем вытащить галку в скрипт карты
	$("#ui_newwin").change(function() {
		document.cookie = "ui_newwin=" + ($(this).attr("checked") ? "1" : "0");
		ui_newwin = $(this).attr("checked"); // global var to handle state
	});

	(function(){
		// set initial state of ui_newwin checkbox
		var cookie_pos = document.cookie.search(/ui_newwin/);
		ui_newwin = false;
		if (cookie_pos >= 0) {
			var cookie_val = Boolean(Number(document.cookie.substr(cookie_pos + 10, 1))); // 10 - is a length of 'ui_newwin='
			$("#ui_newwin").attr("checked", cookie_val);
			ui_newwin = cookie_val;
		}
	})();
});

/* Yandex sitesearch search form script */
(function(Lego){ if (!Lego) Lego = window.Lego = {}; Lego.clean = function(a) { var p = a.previousSibling; if (p) { a.onblur = function() { if (!a.value) { p.style.top = ""; } }; p.style.top = "-9999px"; } }; Lego.cleanIfNotEmpty = function(ids) { var e = []; for (var i = 0; i < ids.length; i++) { e[i] = document.getElementById(ids[i]); }; var f = function() { for (var i = 0; i < e.length; i++) { if (e[i].value) { Lego.clean(e[i]); } } }; setInterval(f, 100); }; })(window.Lego);