
  var url = "http://www.russia-otdih.ru"; //Адрес Вашего сайта
  var title = "Туристическая компания «Ваш отдых» "; //Название Вашего сайта
  function addFavorite(a) {
    try {
      window.external.AddFavorite(url, title);
    }
    catch (e) {
      try {
        window.sidebar.addPanel (title, url, "");
        }
      catch (e) {
        if (typeof(opera)=="object") {
          a.rel = "sidebar";
          a.title = title;
          a.url = url;
          return true;
        }
        else {
          alert("Нажмите Ctrl-D для добавления в избранное");
        }
      }
    }
    return false;
          }
	
    $(function() {
        $('#gallery a').lightBox();
		var tit = $('.shapka').prev('h1').html();
        var sh = $('.shapka').html();
        if(sh != '')
		{
			$.cookie('title', tit);
            $.cookie('shapka', sh);
		}
    });

	var sel_city_for_sort;
	var sel_san_for_sort;
	var G_start;
	
	function fun_next_el_search(){
	var start = G_start;
	if(start>20)
		{
		$("#prev_search_el").show();
		}
		else
		{
		//$("#prev_search_el").hide();
		}
	var end=G_start+10;
	var col_el_search = $(".el_search").length;
	if(end<col_el_search)
	{
	$(".el_search").hide();
	$(".el_search").slice(start,end).show();
	G_start = end;
	$("#block_info_search").text("("+end+" из "+col_el_search+")");
	}
	else
	{
	$(".el_search").hide();
	$("#block_info_search").text("("+col_el_search+" из "+col_el_search+")");
	$(".el_search").slice(start,col_el_search).show();
	G_start = 0;
	}	
		
	
	}
	
	function open_info_send_zayavka()
	{
	$( '#box_info_send_zayavka' ).dialog({ width: 345 });
	
	}
	function open_recomendation_window()
	{
	$( '#box_info_recomendation' ).dialog();
	}
	function open_garantia_window()
	{
	$( '#box_info_garantia' ).dialog();
	}
	
	function fun_prev_el_search()
	{
	
	var col_el_search = $(".el_search").length;
	var end = G_start-10;
	var start=end-10;
	if(end>0)
	{
	$(".el_search").hide();
	$(".el_search").slice(start,end).show();
	G_start = end;
	$("#block_info_search").text("("+end+" из "+col_el_search+")");
	}
	if(end<0)
	{
	
	end = (Math.floor(col_el_search/10))*10;
	start=end-10;
	$(".el_search").hide();
	$(".el_search").slice(start,end).show();
	G_start = end;
	$("#block_info_search").text("("+end+" из "+col_el_search+")");
	}
	/*else
	{
	$(".el_search").hide();
	$("#block_info_search").text("("+col_el_search+" из "+col_el_search+")");
	$(".el_search").slice(start,col_el_search).show();
	G_start = 0;
	}*/
	}
	
	function avtorization()
	{
		$("#form_login").show();
		$("#forget_pasw").hide();
		$("#registration").hide();
		$("#dialog-modal").dialog( "option", "height", 234 );
	}
	function registration()
	{
	$("#form_login").hide();
		$("#forget_pasw").hide();
		$("#registration").show();
		$("#dialog-modal").dialog( "option", "height",414);
	}
	function forget_pasw()
	{
	$("#form_login").hide();
		$("#forget_pasw").show();
		$("#registration").hide();
		$("#dialog-modal").dialog( "option", "height", 190 );
		/*$( "#dialog-modal" ).dialog({
			height: 150,
			modal: true
		});*/
		/*$("#dialog-modal").css("height","150px !important");
		$("#ui-dialog").css("height","150px !important");*/
	}
	function cancel_login()
	{
	$( "#dialog-modal" ).dialog( "close" );
	}
	function cancel_recomendation_window()
	{
	$( '#box_info_recomendation' ).dialog( "close" );
	}
	function cancel_garantia_window()
	{
	$( '#box_info_garantia' ).dialog( "close" );
	}
	
	function ok_photo_add()
	{
	$( "#dialog-modal_img" ).dialog( "close" );
	}
	function function_load_image(obj)
	{
	$(obj).next().after('<input type="file" name="name_photo[]" onchange="function_load_image(this)"><br>');
	$(obj).removeAttr("onchange");
	}
	
	function fun_cancel_call_back()
	{
	$("#dialog-modal_form_call_back").dialog("close");
	}
	function cancel_send_info_zayavka()
	{
	$("#box_info_send_zayavka").dialog("close");
	}
	
	function fun_back_call()
	{
	$("#dialog-modal_form_call_back" ).dialog({
			height: 388,
			width:500,
			modal: true,
			hide: "explode"
		});
	}
	
	
	/*Сводная таблцица выбор санатория*/
	function san_for_tabler_sort(obj)
	{
		var prop = $(obj).attr("propertis");
		var arr1 = prop.split(";");
		var arr2;
		var id_san = $(obj).val();
		$("select option[value=0]").attr("selected", "selected");
		
		$.ajax({
				   type: "POST",
				   url: "../includes/admin_table_sort.php",
				   data: {id_san:id_san},
				   success: function(msg){
						tinyMCE.get('my_editor').setContent(msg);
					}
					});
		
		for (var i = 0; i < arr1.length; i++) {
			if(arr1[i]!="")
				{
					arr2 = arr1[i].split("=");
					
					$("#"+arr2[0]+" option[value='"+arr2[1]+"']").attr("selected", "selected");
					$("#"+arr2[0]).val(arr2[1]);
				}
		}

	}
	 
	$(function(){
	
	/*
	не стандартный чекбокс
	$(".select_element_no_select").click(function(){
		var input = $(this).find("input");
		var name_input = input.attr("name"); 
		$("input[name="+name_input+"]").parent().removeClass('select_element_select').addClass('select_element_no_select');
		if(!input.attr("checked")) {
        $(this).removeClass('select_element_no_select').addClass('select_element_select');    
        input.attr("checked", true)
    } else {
        $(this).removeClass('select_element_select').addClass('select_element_no_select');    
        input.attr("checked", false)

    }

	})*/

	
	/*Рекомендации на картинке на страницах санаториев*/

	$("#box_san_online_sort_table span").click(function(){

		if($(this).parent().find("input").attr('checked'))
		{
		$(this).parent().find("input").attr('checked', false);
		$(this).css("color","#8C6D50");
		}
		else
		{
		$(this).parent().find("input").attr('checked', 'checked');
		$(this).css("color","#000");
		}
		
	})
	/*Кон таблиц*/
	
	
	$(".toppad2 table img").each(function(){
		var a_href = $(this).parent();
		var obj = $(this);
			if(a_href.attr("href"))
			{
				var href_check = $(this).parent().attr("href");
				$.ajax({
				   type: "POST",
				   url: "otziv.php",
				   data: {href_check_recomendation:href_check},
				   success: function(msg){
						if(msg==1)
						{
						a_href.prepend("<div style='position:relative;text-align:center'><div style='position:absolute; left:-70px; top:-15px; width:100%'><span rel='tooltip' title='«Ваш отдых» рекомендует'><img src='/images/circle_yellow.png' width=45></span></div></div>");
						}
					}
					});
			}
	})
	/*----------------------*/
	$(".el_to_select_r").click(function(){
		var input = $(this).parent().find("input");
		if(!input.attr("checked")) {    
        input.attr("checked", true)
    } else {   
        input.attr("checked", false)

    }
	})
	
	/*фильтр отзывы*/
	$("#filter_otziv").change(function(){
		
		
		sel_type_otziv = $(this).val();
			if(sel_type_otziv!=0)
			{
			$(".otziv_menedger_text[type_otziv!='"+sel_type_otziv+"']").hide();
			$(".otziv_menedger_text[type_otziv='"+sel_type_otziv+"']").show();
			}
			else
			{
			$(".otziv_menedger_text").show();
			}
	})
	
	$("#dob_param_link").click(function(){
	 $("#dob_param_box").toggle(333);
	})
	
	 //Select all anchor tag with rel set to tooltip
    $('a[rel=tooltip]').mouseover(function(e) {
         
        //Grab the title attribute's value and assign it to a variable
        var tip = $(this).attr('title');    
         
        //Remove the title attribute's to avoid the native tooltip from the browser
        $(this).attr('title','');
         
        //Append the tooltip template and its value
        $(this).append('<div id="tooltip"><div class="tipBody">' + tip + '</div></div>');     
         
        //Set the X and Y axis of the tooltip
        $('#tooltip').css('top', e.pageY + 10 );
        $('#tooltip').css('left', e.pageX + 20 );
         
        //Show the tooltip with faceIn effect
        $('#tooltip').fadeIn('500');
        $('#tooltip').fadeTo('10',0.8);
         
    }).mousemove(function(e) {
     
        //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
        $('#tooltip').css('top', e.pageY + 10 );
        $('#tooltip').css('left', e.pageX + 20 );
         
    }).mouseout(function() {
     
        //Put back the title attribute's value
        $(this).attr('title',$('.tipBody').html());
     
        //Remove the appended tooltip template
        $(this).children('div#tooltip').remove();
         
    });
	//Select all anchor tag with rel set to tooltip
    $('span[rel=tooltip]').mouseover(function(e) {
         
        //Grab the title attribute's value and assign it to a variable
        var tip = $(this).attr('title');    
         
        //Remove the title attribute's to avoid the native tooltip from the browser
        $(this).attr('title','');
         
        //Append the tooltip template and its value
        $(this).append('<div id="tooltip"><div class="tipBody">' + tip + '</div></div>');     
         
        //Set the X and Y axis of the tooltip
        $('#tooltip').css('top', e.pageY + 10 );
        $('#tooltip').css('left', e.pageX + 20 );
         
        //Show the tooltip with faceIn effect
        $('#tooltip').fadeIn('500');
        $('#tooltip').fadeTo('10',0.8);
         
    }).mousemove(function(e) {
     
        //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
        $('#tooltip').css('top', e.pageY + 10 );
        $('#tooltip').css('left', e.pageX + 20 );
         
    }).mouseout(function() {
     
        //Put back the title attribute's value
        $(this).attr('title',$('.tipBody').html());
     
        //Remove the appended tooltip template
        $(this).children('div#tooltip').remove();
         
    });
	
	
	
	$("#add_new_photo").css("cursor","pointer");
	$("#add_new_photo").click(function(){
		var id_cu = $("#cabinet_nomer").val();
		
		if(id_cu=="")
		{
		$( "#dialog-modal" ).dialog({
			height: 234,
			modal: true,
			hide: "explode"
		});
		avtorization();
		}
		else
		{
		/*$( "#dialog-modal_img" ).dialog({
			height: 234,
			modal: true,
			hide: "explode"
		});*/
		$("#form_add_media_files").show();
		}
	});
	$("#search_input").keyup(function(){
		var text_i = $("#search_input").val();
			$.ajax({
			type: "POST",
			url: "search.php",
			data: {search_text:text_i},
			success: function(msg){
			$("#result_search_text").html(msg); 
			$("#result_search_text div a").hover(function(){$(this).animate({ backgroundColor: "#a1d8fd" }, 234);},function(){ $(this).animate({ backgroundColor: "white" }, 234);});
			
			var col_el_search = $(".el_search").length;
			if(col_el_search==0)
			{
			$(".el_nav_search").html("Поиск не дал результатов");
			}
			var text_hreff="";
				var col_show_search_on_page = 10;
				G_start = col_show_search_on_page;
				$(".el_search").hide();
				$(".el_search").slice(0,col_show_search_on_page).show();
				var start=0;
				
				if(col_el_search>col_show_search_on_page)
				{
				$(".el_nav_search").html("<span id='prev_search_el' onclick='fun_prev_el_search()'>&#8592;</span>"+"<span id='block_info_search'>("+col_show_search_on_page+" из "+col_el_search+")</span><span id='next_search_el' onclick='fun_next_el_search()'>&#8594;</span>"); 
				//$("#prev_search_el").hide();
				}
			}
			});
	})
	
	
	
	
	$("#box_san_online_z span").css("cursor","pointer");
	$("#box_san_online_z span").click(function(){

		if($(this).parent().find("input").attr('checked'))
		{
		$(this).parent().find("input").attr('checked', false);
		$(this).css("color","#8C6D50");
		}
		else
		{
		$(this).parent().find("input").attr('checked', 'checked');
		$(this).css("color","#000");
		}
		
	})
	$("#box_san_online_z input").click(function(){
		if($(this).attr('checked'))
		{
		
		$(this).parent().find("span").css("color","#000");
		}
		else
		{
		$(this).parent().find("span").css("color","#8C6D50");
		}
	})
	
	
	/*$("#add_button_k_s").click(function(){
			//$("#main_block_k_s").after("<tr>"+$("#main_block_k_s").html()+"</tr>");
		})*/
	$("#bufer_for_san_online_z").html($("#box_san_online_z").html());
	$("#select_city_onlinez").change(function(){
		var s_c_o = $("#select_city_onlinez").val();
		if(s_c_o!=0)
		{
		$("#box_san_online_z").html("");
		$("#bufer_for_san_online_z div[city='"+s_c_o+"']").each(function(){$("#box_san_online_z").append("<div>"+$(this).html()+"</div>");});
		$("#box_san_online_z span").click(function(){
	
	
	
		if($(this).parent().find("input").attr('checked'))
		{
		$(this).parent().find("input").attr('checked', false);
		$(this).css("color","#8C6D50");
		}
		else
		{
		$(this).parent().find("input").attr('checked', 'checked');
		$(this).css("color","#000");
		}
		
	})
	$("#box_san_online_z input").click(function(){
		if($(this).attr('checked'))
		{
		
		$(this).parent().find("span").css("color","#000");
		}
		else
		{
		$(this).parent().find("span").css("color","#8C6D50");
		}
	})
		}
		else
		{
		$("#box_san_online_z").html($("#bufer_for_san_online_z").html());
		$("#box_san_online_z span").click(function(){
	
	
	
		if($(this).parent().find("input").attr('checked'))
		{
		$(this).parent().find("input").attr('checked', false);
		$(this).css("color","#8C6D50");
		}
		else
		{
		$(this).parent().find("input").attr('checked', 'checked');
		$(this).css("color","#000");
		}
		
	})
	$("#box_san_online_z input").click(function(){
		if($(this).attr('checked'))
		{
		$(this).parent().find("span").css("color","#000");
		}
		else
		{
		$(this).parent().find("span").css("color","#8C6D50");
		}
	})
		}
	})
	
	
	
	$( "#datepicker" ).datepicker();
	$( "#datepicker" ).datepicker( "option", "dateFormat", 'dd.mm.yy' );
	$( "#datepicker" ).datepicker( "option", "firstDay", 1 );
	$( "#datepicker" ).datepicker( "option", "monthNames", ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'] );
	$( "#datepicker" ).datepicker( "option", "dayNamesMin", ['Вс','Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'] );
	
	var text_buf_menu=$("#el_content_menu .shapka").html();
	$("#box_res_menu").html(text_buf_menu);
	$("#el_content_menu").remove();
	
	var select_val = $("#sort_rating_city").val();
	
		if(select_val==0)
		{
		$("#table_rating tr").not("tr .h_bwr").removeClass('el_rating_hide').addClass('el_rating').show();
		$("#text_in_header_table_rating").text("Рейтинг всех санаториев");
		}
		else
		{
		$("#table_rating tr[city!='"+select_val+"']").not("tr .h_bwr").removeClass('el_rating').addClass('el_rating_hide').hide();
		$("#table_rating tr[city='"+select_val+"']").not("tr .h_bwr").removeClass('el_rating_hide').addClass('el_rating').show();
	
			if(select_val==6)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Анапы ");
			}
			if(select_val==8)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Геленджика ");
			}
			if(select_val==2)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Ессентуки ");
			}
			if(select_val==4)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Железноводска ");
			}
			if(select_val==1)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Кисловодска ");
			}
			if(select_val==3)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Пятигорска ");
			}
			if(select_val==5)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Сочи ");
			}
			if(select_val==7)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Туапсе ");
			}
			
		
		}
	
	configure_page_menu_rating();
	$("#sort_rating_city").change(function(){var select_val = $("#sort_rating_city").val();
	
		if(select_val==0)
		{
		$("#table_rating tr").not("tr .h_bwr").removeClass('el_rating_hide').addClass('el_rating').show();
		$("#text_in_header_table_rating").text("Рейтинг всех санаториев");
		}
		else
		{
		$("#table_rating tr[city!='"+select_val+"']").not("tr .h_bwr").removeClass('el_rating').addClass('el_rating_hide').hide();
		$("#table_rating tr[city='"+select_val+"']").not("tr .h_bwr").removeClass('el_rating_hide').addClass('el_rating').show();
	
			if(select_val==6)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Анапы ");
			}
			if(select_val==8)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Геленджика ");
			}
			if(select_val==2)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Ессентуки ");
			}
			if(select_val==4)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Железноводска ");
			}
			if(select_val==1)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Кисловодска ");
			}
			if(select_val==3)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Пятигорска ");
			}
			if(select_val==5)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Сочи ");
			}
			if(select_val==7)
			{
			$("#text_in_header_table_rating").text("Рейтинг санаториев Туапсе ");
			}
			
		
		}
		configure_page_menu_rating();
	})
	
	
		
	var cur_page;
	cur_page = $("#cur_page").val();
	if (typeof cur_page != 'undefined')
	{
	/*
	var obj = $(".shapka-element a:contains('Преимущества санатория')");
	obj.text("Oтзывы");
	obj.attr({href:"/show_otziv.php?page="+cur_page});
	*/
	
	/*var obj_parent = obj.parent();
	obj.remove();
	obj_parent.html("<span onclick='scrollBottom()' style='color:#3372B2;text-decoration:underline;cursor:pointer;'>Oтзывы</span>");*/
	//obj.attr({href:"#"});
	//obj.onclick(function(){scrollBottom();})
	}
	
	/*Блок установки кол-ва в отзывы*/

	if($(".shapka-element").length)
	{
	
	var obj = $(".shapka-right .shapka-element a:odd");
	var obj_f = $(".shapka-left .shapka-element a:odd");
	var href = obj.attr("href");
	var href_f = obj_f.attr("href");
	var mas_id1 = href.split('=');
	var mas_id = href_f.split('=');	
	
	$.ajax({
	   type: "POST",
	   url: "otziv.php",
	   data: {id_for_col_otziv:mas_id1[1]},
	   success: function(msg){
		obj.text("Отзывы ("+msg+")");
		//$("body").append(msg);
		}
		});
	
if (typeof mas_id[1] == 'undefined')
	{	
	$.ajax({
	   type: "POST",
	   url: "otziv.php",
	   data: {foto_href:href_f},
	   success: function(msg){
		//$("body").append(msg);
		obj_f.text("Фотографии ("+msg+")");
		}
		});
	}else
	{
	
	$.ajax({
	   type: "POST",
	   url: "otziv.php",
	   data: {foto_href2:mas_id[1]},
	   success: function(msg){
		//$("body").append(msg);
		obj_f.text("Фотографии ("+msg+")");
		}
		});
	
	}
	
	}
	/*End Бл отз*/

	/*rating_res_for_move*/
	var r_r_f_m = $("#rating_res_for_move").html();
	//$("body").append(r_r_f_m.length);
	if ($("#rating_res_for_move").length)
	{
	$(".toppad2 .shapka").after("<div id='created_rating'>"+r_r_f_m+"</div>");
	$("#rating_res_for_move").remove();
	}else
	{
	$(".toppad2 .shapka").after("<div id='created_rating'></div>");
	}
	
	if ($("#molniay_text").length)
	{
	var r_r_f_molniay = $("#molniay_text").html();
	$("#created_rating").after("<div id='created_molniay'>"+r_r_f_molniay+"</div>");
	$("#molniay_text").remove();
	}
	if ($("#y_san_for_blt").length)
	{
	var r_r_f_blt = $("#y_san_for_blt").html();
	$(".toppad2 .shapka").after("<div id='created_r_r_f_blt'>"+r_r_f_blt+"</div>");
	$("#y_san_for_blt").remove(); 
	}
	if ($("#info_block_rec_garant").length)
	{
	var r_r_f_rec_garant = $("#info_block_rec_garant").html();
	$(".toppad2 .shapka").after("<div id='created_recomendation_box'>"+r_r_f_rec_garant+"</div>");
	$("#info_block_rec_garant").remove(); 
	}
	/*Выбор оценка*/
	$(".r1").click(function(){$(this).parent().removeClass().addClass('give_rating select1');
			var obj = $(this).parent().find("input");
			obj.val("1");
			result_rating();
		}); 
	$(".r2").click(function(){$(this).parent().removeClass().addClass('give_rating select2')
	var obj = $(this).parent().find("input");
			obj.val("2");
			result_rating();
	});
	$(".r3").click(function(){$(this).parent().removeClass().addClass('give_rating select3')
	var obj = $(this).parent().find("input");
			obj.val("3");
			result_rating();
	});
	$(".r4").click(function(){$(this).parent().removeClass().addClass('give_rating select4')
	var obj = $(this).parent().find("input");
			obj.val("4");
			result_rating();
	});
	$(".r5").click(function(){$(this).parent().removeClass().addClass('give_rating select5')
	var obj = $(this).parent().find("input");
			obj.val("5");
			result_rating();
	});
	
	$(".give_rating").hover(function(){$(this).removeClass().addClass('give_rating')},function(){
	var obj = $(this).find("input");
	if(obj.val()!="")
		{
			$(this).removeClass().addClass("give_rating select"+obj.val());
		}
	})
	

	/*end*/
	
	/*Сортировка*/
	$("#sort_select_city").change(function(){
	   sel_city_for_sort = $(this).val();
			if(sel_city_for_sort!=0)
			{
			$("#block_with_otz table[city!='"+sel_city_for_sort+"']").parent().removeClass('el_otziv').addClass('el_otziv_hide');
			$("#block_with_otz table[city='"+sel_city_for_sort+"']").parent().removeClass('el_otziv_hide').addClass('el_otziv');
			$("#block_with_otz table td").removeClass('el_otziv_hide');
			$("#button_get_back_inmp").show(333);
			}
			else
			{
			$("#block_with_otz table").parent().removeClass('el_otziv_hide').addClass('el_otziv');
			$("#block_with_otz table td").removeClass('el_otziv');
			$("#button_get_back_inmp").hide(333);
			}
	   $.ajax({
	   type: "POST",
	   url: "otziv.php",
	   data: {id_selected:sel_city_for_sort},
	   success: function(msg){
	   
		$("#snt_sort").html("<option value='0'>Выберите санаторий</option>"+msg);
		}
		});
		configure_page_menu();
	})
	
	$("#sort_select_city_call_back").change(function(){
	   sel_city_for_sort = $(this).val();
													
		if(sel_city_for_sort=="Геленджик"){sel_city_for_sort = 8;}
		if(sel_city_for_sort=="Анапа"){sel_city_for_sort = 6;}
		if(sel_city_for_sort=="Ессентуки"){sel_city_for_sort = 2;}
		if(sel_city_for_sort=="Железноводск"){sel_city_for_sort = 4;}
		if(sel_city_for_sort=="Кисловодск"){sel_city_for_sort = 1;}
		if(sel_city_for_sort=="Пятигорск"){sel_city_for_sort = 3;}
		if(sel_city_for_sort=="Сочи"){sel_city_for_sort = 5;}
		if(sel_city_for_sort=="Туапсе"){sel_city_for_sort = 7;}
	   $.ajax({
	   type: "POST",
	   url: "otziv.php",
	   data: {id_selected:sel_city_for_sort},
	   success: function(msg){
	   
		$("#snt_sort_call_back").html("<option value='0'>Выберите санаторий</option>"+msg);
		}
		});
		
	})
	
	$("#snt").change(function(){
	var city_select_now = $("#snt option:selected").attr('city'); 
		$("#select_city option[value="+city_select_now+"]").attr("selected", true);
		$("#box_result_san").append($("#snt option:selected").text()+" г."+$("#select_city option[value="+city_select_now+"]").text()+"\n");
		$("#result_sel_san").show(1234);
		
	})
	$("#snt_sort").change(function(){
	    
		sel_san_for_sort = $(this).val();
		
			if(sel_san_for_sort!=0)
			{
			$("#block_with_otz table[sanator!='"+sel_san_for_sort+"']").parent().removeClass('el_otziv').addClass('el_otziv_hide');
			$("#block_with_otz table[sanator='"+sel_san_for_sort+"']").parent().removeClass('el_otziv_hide').addClass('el_otziv');
			$("#block_with_otz table td").removeClass('el_otziv_hide');
			$("#button_get_back_inmp").show(333);
			}
			else
			{
			$("#block_with_otz table").parent().removeClass('el_otziv_hide').addClass('el_otziv');
			$("#block_with_otz table td").removeClass('el_otziv');
			}
		configure_page_menu();
	})
	
	configure_page_menu();
	/*Кон управления сортировкой */
	
	$("#show_otz_btn").click(function(){$("#block_otz").toggle(1234);})
	$("#select_city").change(function(){
	
	
	var id = $(this).val();
	if(id==5 || id==6 || id==7 || id==8 )
		{
			$("#for_sea").css("display","block");
		}
		else
		{
			$("#for_sea").css("display","none");
		}
	$.ajax({
   type: "POST",
   url: "otziv.php",
   data: {id_selected:id},
   success: function(msg){
    $("#snt").html(msg);
   }
	});
	
	})
	
		var allreadopened = $.cookie('opened');
		if(allreadopened!="")
		{
		//$("#"+allreadopened).parent().css("display","block");
		//$("#"+allreadopened).next().next().css("display","block");
		//$.cookie('opened',null);
		}
		
		$(".menu_sb_title").click(function(){
		//$(this).parent().find(".podmenu").toggle(333);
		$(this).next().next().toggle(333);
		$.cookie('opened',$(this).attr("id"));
		});
		
		
		var page_to_select_a = location.pathname;
		var dop_search = location.search;
		
		var open_page_id = $("#open_page_id").val();
		$('a[href|='+page_to_select_a+']').css('color','red');
		/*выделение ссылки для всех страниц */
		$('a[href|='+page_to_select_a+dop_search+']').css('color','red');
			if($('a[href|='+page_to_select_a+']').parent().is(".el_header_menu"))
			{
				/*if(page_to_select_a!="/")
				{*/
				//var objbjb = $('a[href|='+page_to_select_a+']').parent();
				//$(objbjb).css("background","#ededed");
				$('a[href|='+page_to_select_a+']').css("color","red !important");
				//}
			}
		
		var obj_shapka_left = $('a[href|='+page_to_select_a+']').parent().parent();
		var obj_shapka_left2 = $('a[href|='+page_to_select_a+dop_search+']').parent().parent().parent();
		var href_find_for_sel = obj_shapka_left.find("a:first").attr("href");
		var href_find_for_sel_right =  obj_shapka_left2.find("a:first").attr("href");
		$('.toppad3 a[href|='+href_find_for_sel+']').css('color','red');
		$('.toppad3 a[href|='+href_find_for_sel_right+']').css('color','red');
		dop_search = "/index.php"+dop_search;
		$('.toppad3 a[href|='+dop_search+']').css('color','red');
		//$("body").append(href_find_for_sel);
		
		if(open_page_id==1)
		{
			$("#kislov").next().next().show();
			$("#kislov").parent().show();
		}
		if(open_page_id==2)
		{
			$("#esent").next().next().show();
			$("#esent").parent().show();
		}
		if(open_page_id==3)
		{
			$("#payteg").next().next().show();
			$("#payteg").parent().show();
		}
		if(open_page_id==4)
		{
			$("#geleznovod").next().next().show();
			$("#geleznovod").parent().show();
		}
		if(open_page_id==5)
		{
			$("#sochi").next().next().show();
			$("#sochi").parent().show();
		}
		if(open_page_id==6)
		{
			$("#anap").next().next().show();
			$("#anap").parent().show();
		}
		if(open_page_id==7)
		{
			$("#tyapce").next().next().show();
			$("#tyapce").parent().show();
		}			
		if(open_page_id==8)
		{
			$("#gelengik").next().next().show();
			$("#gelengik").parent().show();
		}
		if(open_page_id==9)
		{
			$("#pisynda").next().next().show();
			$("#pisynda").parent().show();
		}
		if(open_page_id==10)
		{
			$("#gagra").next().next().show();
			$("#gagra").parent().show();
		}
		if(open_page_id==11)
		{
			$("#sudak").next().next().show();
			$("#sudak").parent().show();
		}
		if(open_page_id==12)
		{
			$("#feodosia").next().next().show();
			$("#feodosia").parent().show();
		}
		if(open_page_id==13)
		{
			$("#yalta").next().next().show();
			$("#yalta").parent().show();
		}
	
		
	})
	
	
function get_back_inmainpage(){
$("#block_with_otz table").parent().removeClass('el_otziv_hide').addClass('el_otziv');
			$("#block_with_otz table td").removeClass('el_otziv');
			configure_page_menu();
			$("#button_get_back_inmp").hide(333);
}
	
	function href_to_otziv()
	{
	window.location='/otziv';
	}
	function href_to_otziv_focus_forma()
	{
	window.location='/otziv#forma_otziv';
	}
	function href_to_otzivkompany_focus_forma()
	{
	window.location='/otziv_company.php';
	}
function result_rating()
{
var summa=0;
var f_el;
var col_sel_rating=0;
$("#vote_hotel-div").find(".el_rating").each(function(){
		
		f_el = $(this).val();
		if(f_el!="" && f_el!=0)
		{
		f_el = parseInt(f_el);
		summa = f_el+summa;
		col_sel_rating++;
		}
	})
	var result = summa/col_sel_rating;	
	$("#result_rating").text(Math.round(result*100)/100);
	$(".result_rating").val(Math.round(result*100)/100);
	
	
	//var okrel = Math.round(Math.round(result*3.4)*20);
	//okrel = 340-okrel;
	if(result==1)
	{
		$(".average_rating_image").attr({style:"background-position: 0 -320px"});
	}


result = $(".result_rating").val();
var mas_res_s = result.split('.');
var dop_el_w = 0;
if (typeof mas_res_s[1] != 'undefined')
{
var dop_el_w = 0;
var ostatok;
ostatok = parseInt(mas_res_s[1]);
if(ostatok>10){
if(ostatok<25)
	{
		dop_el_w = 20;
	}
if(25<=ostatok && ostatok<=51)
{
	dop_el_w = 40;
}
if(51<=ostatok && ostatok<=75)
{
	dop_el_w = 60;
}
if(75<ostatok)
{
	dop_el_w = 60;
}
}
else{
if(2>=ostatok)
{
	dop_el_w = 20;
}
if(2<ostatok && ostatok<=5)
{
	dop_el_w = 40;
}
if(5<ostatok && ostatok<=7)
{
	dop_el_w = 60;
}
if(7<ostatok)
{
	dop_el_w = 60;
}
}
}
result = 340-((((Math.floor(result))-1)*80)+dop_el_w+20);
$(".average_rating_image").attr({style:"background-position: 0 -"+result+"px"});
}

function scrollBottom()
{
     $('html, body').animate({scrollTop:3000 + 'px'}, 'slow',function(){$("#block_otz").show(1234);});
}
function scrollTop_1()
{
     $('html, body').animate({scrollTop:345 + 'px'}, 'slow');
}
function open_new_block_otziv(st,en)
{
		$(".el_otziv").css("display","none");
		$(".el_otziv").slice(st,en).css("display","block");
		$(".el_otziv").css("display","none");
		$(".el_otziv").slice(st,en).css("display","block");
}
function historyback()
{
var el_history = history.length;
if(el_history>2)
{
history.back();
}
else
{
window.location='/';
}

}
var start_position_button_otziv = 15;
var col_butn;
function configure_page_menu()
{
var text_hreff="";
var col_show_otz_on_page = 2;
	var col_el = $("#block_with_otz div.el_otziv").length;
	/*$("body").append(col_el+"/");*/
	$("div .el_otziv").css("display","none");
	$("div .el_otziv").slice(0,col_show_otz_on_page).css("display","block");
	var start=0;
	if(col_el>col_show_otz_on_page)
	{
	text_hreff="Страница:<input type='button' class='prev_button_otziv' onclick='prev_button_otziv()' value='<<'>";
		var end = col_show_otz_on_page;
		var col_el_in_c = Math.ceil(col_el/col_show_otz_on_page);
		for(var i=1;i<=col_el_in_c;i++)
		{
		text_hreff += "<input type='button' class='btn_page_sort' onclick='open_new_block_otziv("+start+","+end+")' value='"+i+"'>";
		start = end;
		end = end+col_show_otz_on_page;
		}
	}	
	$("#box_bt_for_page").html(text_hreff+"<input type='button' class='next_button_otziv' onclick='next_button_otziv()' value='>>'>");
	
	col_butn = $(".btn_page_sort").length;
	if(col_butn<15)
	{
	$(".prev_button_otziv").hide();
	$(".next_button_otziv").hide();
	}
	var last_butn = col_butn-1;
	$(".btn_page_sort").hide();	
	$(".btn_page_sort").slice(0,start_position_button_otziv).show();
	
	//$(".btn_page_sort").slice(last_butn,col_butn).show();
}

function prev_button_otziv()
{
var col_el_search = col_butn;
	var end = start_position_button_otziv-15;
	var start=end-15;

	if(end>0)
	{
	$(".btn_page_sort").hide();
	$(".btn_page_sort").slice(start,end).show();
	start_position_button_otziv = end;
	//$("#block_info_search").text("("+end+" из "+col_el_search+")");
	}
	if(end<0)
	{
	
	end = (Math.floor(col_el_search/10))*10;
	start=end-15;
	$(".el_search").hide();
	$(".el_search").slice(start,end).show();
	start_position_button_otziv = end;
	//$("#block_info_search").text("("+end+" из "+col_el_search+")");
	}
}
function next_button_otziv()
{
var end = start_position_button_otziv+15;
var start = start_position_button_otziv;
if(end<col_butn)
	{
	$(".btn_page_sort").hide();	
	$(".btn_page_sort").slice(start,end).show();
	start_position_button_otziv = end;
	}
	else
	{
	$(".btn_page_sort").hide();	
	$(".btn_page_sort").slice(start,col_butn).show();
	}
}

function open_new_block_rating(st,en)
{
		$("#table_rating tr.el_rating").hide();
		$("#table_rating tr.el_rating").slice(st,en).show();
		$("#table_rating tr.el_rating").hide();
		$("#table_rating tr.el_rating").slice(st,en).show();
}

function configure_page_menu_rating()
{
var text_hreff="";
var col_show_otz_on_page = 25;
	var col_el = $("#table_rating tr.el_rating").length;
	$("#table_rating tr.el_rating").hide();
	$("#table_rating tr.el_rating").slice(0,col_show_otz_on_page).show();
	var start=0;
	if(col_el>col_show_otz_on_page)
	{
	text_hreff="Страница : ";
		var end = col_show_otz_on_page;
		var col_el_in_c = Math.ceil(col_el/col_show_otz_on_page);
		for(var i=1;i<=col_el_in_c;i++)
		{
		text_hreff += "<input type='button' class='btn_page_sort' onclick='open_new_block_rating("+start+","+end+")' value='"+i+"'>";
		start = end;
		end = end+col_show_otz_on_page;
		}
	}	
	$(".box_bt_for_page_rating").html(text_hreff); 
}
