$(document).ready(function() {
			var search_menu = $('div.tabs > div');

			$('div.tabs ul.search_menu a').click(function() {
				// Выделение пункта в левом меню

				var tabNum = '';
				var listItems = $('div.main_menu li');

                // Ебливый IE6 глючит при присвоении значения сразу после объявления переменной
				tabNum = $(this).attr('href');

				listItems.removeClass('selected');

				switch(tabNum) {					case '#first':
                        listItems.eq(2).addClass('selected');
						break;
					case '#second':
                        listItems.eq(3).addClass('selected');
						break;
					case '#third':
                        listItems.eq(4).addClass('selected');
						break;				}
                // Подготовка формы

				var globalregion = 0;
				var globallocation = 0;
				globalregion = $("#posted_region").val();
				globallocation = $("#posted_location").val();

				search_menu.hide();
				search_menu.filter(this.hash).show();
				$('div.tabs ul.search_menu a').removeClass('selected');
				$(this).addClass('selected');
				$("#regions1 option[value =" + globalregion + "]").attr(
						"selected", "true");
				$("#regions2 option[value =" + globalregion + "]").attr(
						"selected", "true");
				$("#regions3 option[value =" + globalregion + "]").attr(
						"selected", "true");
				if (globalregion != 0) {
					$("#locations1").removeAttr("disabled")
							.html($("#regionslocations .sub_" + globalregion)
									.clone()).prepend("<option value=\"0\" selected=\"true\">...</option>");;
					$("#locations2").removeAttr("disabled")
							.html($("#regionslocations .sub_" + globalregion)
									.clone()).prepend("<option value=\"0\" selected=\"true\">...</option>");;
					$("#locations3").removeAttr("disabled")
							.html($("#regionslocations .sub_" + globalregion)
									.clone()).prepend("<option value=\"0\" selected=\"true\">...</option>");;
					$("#locations1 option[value =" + globallocation + "]")
							.attr("selected", "true");
					$("#locations2 option[value =" + globallocation + "]")
							.attr("selected", "true");
					$("#locations3 option[value =" + globallocation + "]")
							.attr("selected", "true");
				}

				if (globallocation != 0) {
					$("#locations1 option[value =" + globallocation + "]")
							.attr("selected", "true");
					$("#locations2 option[value =" + globallocation + "]")
							.attr("selected", "true");
					$("#locations3 option[value =" + globallocation + "]")
							.attr("selected", "true");
				}
				return false;
			});

			$("a[rel^='prettyPhoto']").prettyPhoto();

});

