﻿/* Russian initialisation for the jQuery UI date picker plugin. */
/* Written by Andrew Stromnov (stromnov@gmail.com). */
jQuery(function($){
    $.datepicker.regional['ru'] = {
      closeText: 'Закрыть',
      prevText: '&#x3c;Пред',
      nextText: 'След&#x3e;',
      currentText: 'Сегодня',
      monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
      'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
      monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
      'Июл','Авг','Сен','Окт','Ноя','Дек'],
      dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
      dayNamesShort: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
      dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
      dateFormat: 'dd.mm.yy', firstDay: 1,
      isRTL: false};
    $.datepicker.setDefaults($.datepicker.regional['ru']);
});

function declOfNum(number, titles) {
  cases = [2, 0, 1, 1, 1, 2];  
  return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}

$(document).ready(function(){

	/*$("#page_form .button input").click(function(e){
		e.preventDefault();
		
		$.post("/modal/search.php",$("#page_form").serialize(),function(date){ $("#page_form").submit(); });
	});*/

	$(".empty a").click(function(e){
		e.preventDefault();		
		
		$("#search-hotel-title-spb").attr("value",$(this).html());
		$("#search-hotel-title-msk").attr("value",$(this).html());
		
		$(".hotel-search-form form").submit();
	})

	$("#search-hotel-title-spb").autocomplete("modal/json_list.php?city=spb");
	$("#search-hotel-title-msk").autocomplete("modal/json_list.php?city=msk");
	
	$(".address .street a[rel^='prettyPhoto[iframemap']").prettyPhoto({theme: 'light_rounded', allowresize: false});
	$(".box-video a[rel^='prettyPhoto[iframe-']").prettyPhoto({theme: 'light_rounded', allowresize: false});

    /* GOOGLE MAP */	//[rel^='prettyPhoto[iframemap']
    $(".address .street a").click(function (e) {
      e.preventDefault();
      href = $(this).attr('href');
	  
      street = "<dt>Адрес: </dt><dd>" + $(this).html() + "</dd>";
      if($('#hotel-title').length) {hotel = "<dt>Гостиница: </dt><dd>" + $("#hotel-title").html() + "</dd>";}
      
	  $.prettyPhoto.open(href, "", "<dl>" + hotel + street + "</dl>");
    });
											
    /* VIDEO */
    $(".box-video a[rel^='prettyPhoto[iframe-']").click(function (e) {
      e.preventDefault();
      href = $(this).attr('href');
	  
	  hotel=$('#hotel-title').html();
	 	
	  if (hotel)	
	  {
		  hotel = "<dt>Гостиница: </td><dd>" + $("#hotel-title").html() + "</dd>";
		  street = "<dt>Адрес: </dt><dd>" + $(".street a").html() + "</dd>";
		  
		  $.prettyPhoto.open(href, "", "<dl>" + hotel + street + "</dl>");
	  }
	  else	
	  {
	  	  hotel="<dd>"+$(".box-video p a").html()+"</dd>";
		  street="";
		  
		  $.prettyPhoto.open(href, "", "<dl></dl>");
	  }
    });   
					  
	$('#fade').cycle({ 
		fx:      'fade', 
		speed:    1000, 
		timeout:  4000
	});
	
	$(".sendtime").attr("value",Date.parse(new Date()));

	/*$(".captcha a").click(function (e) {
	   e.preventDefault();

		$(".captcha img").attr("src","");
		$(".captcha img").attr("src","cap.php");
		//$.ajax({ type: "GET", url: "cap.php", success: function(msg){$(".captcha img").attr('src',img_src);}  });	
	});*/
	
	//$(document).ready(function(){
	$(".captcha a").click(function (e) {
		e.preventDefault();
		var img_id = ".captcha img";
		var timestamp = new Date().getTime();
		var img_src = $(img_id).attr("src").split("?")[0] + "?" + timestamp;
		$.ajax({
			type: "GET",
			url: img_src,
			success: function(msg){$(img_id).attr('src',img_src);}
		});
	});
	//});
		
	/* Custom select */
    $(".room-booking select").msDropDown();
    $(".room-price select").msDropDown();
    $("#hotel-search-form .msdropdown").msDropDown();
	$(".recreation-search-form .msdropdown").msDropDown();
    
    /* form validation recreation search */
    if($('#hotel-search-form .recreation-search-form form').length) {
      $("#hotel-search-form .recreation-search-form form").validate();
    }
    /* form validation contact */
    if($('form.contact-form').length) {
      //$("form.contact-form").validate();
    }
    /* form validation booking */
    if($('form.booking-form').length) {
      //$("form.booking-form").validate();
    }
    
    /* prettyphoto gallery */
    if($('.hotel-photos').length) {
      $(".hotel-photos a[rel^='prettyPhoto[gallery']").prettyPhoto({theme: 'light_rounded', allowresize: false});
    }
    	
    /* Photo gallery ajax load */
    $('.hotel-photos ul li').click(function (e) {
      e.preventDefault();
      //var block_height = $(".hotel-photos").height();
      var href = $(this).children("a").attr('href');
      $(".hotel-photos li").removeClass("active");
      $(this).addClass("active");
      $('.hotel-photos .ajax-content').fadeOut('slow', function() {
        $('.hotel-photos .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
        $('.hotel-photos .ajax-content .preloader-box').height("260px");
        $('.hotel-photos .ajax-content').fadeIn('slow', function() {
          $.get(href,
            function(data){
              $('.hotel-photos .ajax-content').fadeOut('slow', function() {
                text = $('.hotel-photos .ajax-content').html(data);
                $('.hotel-photos .ajax-content').fadeIn('slow', function() {
                  //$(document).ready(function(){
                    $(".hotel-photos .photos a[rel^='prettyPhoto[gallery]']").prettyPhoto({theme: 'light_rounded', allowresize: false});
                  //});
                });
              });
            });
        });
      });
    });
    
    /* datepicker */
	
      $('#form-booking-date-in').datepicker({showOn: 'both', buttonImage: 'img/common/calendar.png', buttonImageOnly: true, beforeShow: customRange});
      $('#form-booking-date-out').datepicker({showOn: 'both', buttonImage: 'img/common/calendar.png', buttonImageOnly: true, beforeShow: customRange});
	  
      function customRange(input) {
		  
		  if ($("#form-booking-date-in").datepicker("getDate")) date=$("#form-booking-date-in").datepicker("getDate");
		  else    date=new Date();

          var input_id = input.id;
          if (input_id == "form-booking-date-in"){return {maxDate: $("#form-booking-date-out").datepicker("getDate"), minDate:new Date() };}
          if (input_id == "form-booking-date-out"){return {minDate: date, maxDate:null};}
      }
      
    /* booking form datepicker */
    if ($('form.booking-form').length) {
      $('#h-datein').datepicker({showOn: 'both', buttonImage: 'img/common/calendar-large.png', buttonImageOnly: true, beforeShow: customRangeBooking, altField: '#h-datein-alt', altFormat: '@'});
      $('#h-dateout').datepicker({showOn: 'both', buttonImage: 'img/common/calendar-large.png', buttonImageOnly: true, beforeShow: customRangeBooking, altField: '#h-dateout-alt', altFormat: '@'});
    }
    function customRangeBooking(input) {
		 
	  if ($("#h-datein").datepicker("getDate")) date=$("#h-datein").datepicker("getDate");
	  else    date=new Date();
	
      var input_id = input.id;
      if (input_id == "h-datein") {return {maxDate: $("#h-dateout").datepicker("getDate"), minDate:new Date()};}
      if (input_id == "h-dateout") {return {minDate: date, maxDate:null};}
    }
    
    /* booking form date period */
    $('.hotel-booking-box .booking-period .date').change(function() {
      date_in = parseInt($("#h-datein-alt").val());
      date_out = parseInt($("#h-dateout-alt").val());
	  
      if (date_in > 0 && date_out > 0) {
        days_count = ((date_out - date_in)/(86400000));
        $(".booking-period .days-count").html('= ' + days_count +declOfNum(days_count, [' ночь', ' ночи', ' ночей']));
      }
    });
    
    if ($('form.booking-form .booking-rooms').length) {$("form.booking-form .booking-rooms .msdropdown").msDropDown();}
    	
    function booking_form_delete() {
      $('.hotel-booking-box .booking-rooms .booking-room-type .delete').click(function (e) {
        e.preventDefault();
		var	count=1;
        
		base = $(this).parents('.booking-room-type');
		 
		$(base).slideUp('slow', function() {
          $(base).remove();
		  change_summ();
		  $(".booking-rooms .booking-room-type .part-left span").each(function(intIndex){
			//alert($(this).html());
			$(this).html(count++);
		  });
		  
        });
      });
    }
    booking_form_delete();
    
    function booking_form_add() {
      $('.hotel-booking-box .room-total .add-room').click(function (e) {
        e.preventDefault();
        var block_num = 1;
		var number = 1;
		
		parent_form=$(this).parents("form");
		
		//if ($(parent_form).hasClass("base"))	alert("base");
		
        $(".hotel-booking-box .booking-rooms .booking-room-type").each(function(intIndex){
          block_num = parseInt($(this).attr("id").replace('booking-room-type-', '')) + 1;
        });
		
		$(".booking-rooms .booking-room-type .part-left span").each(function(intIndex){
		  number++;
		});
		
        text = $('.hotel-booking-box .booking-hidden .booking-room-type').html();
		
        $('.hotel-booking-box .rooms-box').append('<div class="booking-room-type" id="booking-room-type-' + block_num + '">' + text + '</div>');
        $("#booking-room-type-" + block_num).hide();
        $("#booking-room-type-" + block_num + " .hotel-type label").attr("for", "hotel-type-" + block_num);
        $("#booking-room-type-" + block_num + " .hotel-type select").attr("id", "hotel-type-" + block_num);
        $("#booking-room-type-" + block_num + " .hotel-type select").attr("name", "room-types[" + block_num + "]");
        $("#booking-room-type-" + block_num + " .hotel-people-count label").attr("for", "hotel-people-count-" + block_num);
        $("#booking-room-type-" + block_num + " .hotel-people-count select").attr("id", "hotel-people-count-" + block_num);
        $("#booking-room-type-" + block_num + " .hotel-people-count select").attr("name", "room-people-count[" + block_num + "]");
        $("#booking-room-type-" + block_num + " .part-left p span").html(number);
        $("#booking-room-type-" + block_num).slideDown();
        $("#booking-room-type-" + block_num + " .msdropdown").msDropDown();
		
		if ($(parent_form).hasClass("base"))
		{
			booking_form_delete();
			change_beds_list_base();
			change_one_price_base();
			change_summ();
			pipol_count_change_base();
		}
		else
		{
			booking_form_delete();
			change_beds_list();
			change_one_price();
			change_summ();
			pipol_count_change();
		}
      });
    }
    booking_form_add();
    
    /* Different color of rows */
    $("#header .contacts dl:even").addClass("odd");
    $(".popular-hotels-list ul li:odd").addClass("even");
    $(".in-content-right .services li:even").addClass("odd");
    //$(".hotel-search .search-result table tr:odd").addClass("odd");
    $(".hotel-rooms table.room-price-date tr.top:even").addClass("even");
    $(".hotel-rooms table.room-price-month tr.top:even").addClass("even");
    
    /* Room price details */
    function roomprice_details(base_id) 
	{
		if (base_id)
		{
			$('#'+base_id+' .room-booking table td a.more').click(function (e) {
				e.preventDefault();
				var base = "";
			
				base = $(this).parents('#' + base_id + ' tr');
			
				$(base).addClass('current');
			
				if ($(base).hasClass('active')) 
				{
					$(".room-price .room-booking tr.current .singletwin").attr("style","");
					$(".room-price .room-booking tr.current .how").attr("style","");  
				
					$('.room-price .room-booking tr.current .price-month-box').slideUp('slow', function() {
						$(base).removeClass('active');
					});
				}
				else 
				{
					$(base).addClass('active');
				
					thisbase=$(".room-price .room-booking tr.current .singletwin");
					thishow=$(".room-price .room-booking tr.current .how");
				
					$('.room-price .room-booking tr.current .price-month-box').slideDown('slow',function() {
						thisbase.attr("style","display:block;");
						thishow.attr("style","display:block;");
					});  
				}
			
				$(base).removeClass('current');
			});
		}
		else
		{
			$('.room-price .room-booking table td a.more').click(function (e) {
				e.preventDefault();
				var base = "";
			
				base = $(this).parents('tr');
			
				$(base).addClass('current');
			
				if ($(base).hasClass('active')) 
				{
					$(".room-price .room-booking tr.current .singletwin").attr("style","");
					$(".room-price .room-booking tr.current .how").attr("style","");  
				
					$('.room-price .room-booking tr.current .price-month-box').slideUp('slow', function() {
						$(base).removeClass('active');
					});
				}
				else 
				{
					$(base).addClass('active');
				
					thisbase=$(".room-price .room-booking tr.current .singletwin");
					thishow=$(".room-price .room-booking tr.current .how");
				
					$('.room-price .room-booking tr.current .price-month-box').slideDown('slow',function() {
						thisbase.attr("style","display:block;");
						thishow.attr("style","display:block;");
					});  
				}
			
				$(base).removeClass('current');
			});
		}
    }
    roomprice_details();
	
	function hover_singletwin()
	{
		$(".singletwin a").hover(
			function(){
				if ($(this).attr("class")!="active")	$(this).addClass("hover");
			},
			function(){
				if ($(this).attr("class")!="active")	$(this).removeClass("hover");
			}
		);
	}
	hover_singletwin();
	
	function hover_singletwindate()
	{
		$(".singletwin-date a").hover(
			function(){
				if ($(this).attr("class")!="active")	$(this).addClass("hover");
			},
			function(){
				if ($(this).attr("class")!="active")	$(this).removeClass("hover");
			}
		);
	}
	hover_singletwindate();

	// single-twin show
	function load_singletwin()
	{
		var base="";

			$('.singletwin a').click(function (e) {
			e.preventDefault();
			
			if ($(".week").attr("value")=="1")
			{
				parent_class="tr";
				even_check="";
			}
			else
			{
				parent_class=".room-price";
				even_check="tr";
			}
			
			aclass = $(this).parents("span").attr("class");
			base = $(this).parents(parent_class);
			parent_class=$(this).parents(".prices-box");
			parent_base=$(this).parents(".room-price");
			
			if ($(parent_class).hasClass("housing"))	{	 filename="housing_newtable";	}
			else	{	filename="newtable";	}
			
			if ($(parent_base).hasClass("base"))	filename="allobjects_newtable";
			
			$(base).addClass('current');

			$(".current .singletwin a").removeClass('active');
			$(".current .singletwin a").removeClass('hover');
			$(".current .singletwin ."+aclass+" a").addClass('active');
			
			loader_height=$(".current .price-month-box").height();
			
			$('.current .price-month-box').fadeOut('fast',function() { 				
				if ($(".current "+even_check).hasClass("even"))	// tr 
				{
					$('.current .price-month-box').html('<div class="preloader-gray">&nbsp;</div>');
					$('.current .preloader-gray').height(loader_height);
					$('.current .singletwin').height(loader_height-136);
				}
				else
				{
					$('.current .price-month-box').html('<div class="preloader-box">&nbsp;</div>');
					$('.current .preloader-box').height(loader_height);
					$('.current .singletwin').height(loader_height-136);
				}
				
				week=$(".current .week").attr("value");
				
				if (week)
				{
					m1=$(".room-month").attr("value");
					y1=$(".room-year").attr("value");
				}
				else
				{
					m1=$(".current .room-month").attr("value");
					y1=$(".current .room-year").attr("value");
				}
				
				hotelid=$(".hotel-id").attr("value");
				objectid=$(".object-id").attr("value");
				roomid=$(".current .room-id").attr("value");
				//if ($(".current .roomid").attr("value"))	roomid=$("tr.current .roomid").attr("value");
				//else	roomid=$(".current .room-id").attr("value");
				
				$(".room-booking .st").attr("value",aclass);				
				
				$('.current .price-month-box').fadeIn('fast',function() {
					$('.current .price-month-box').fadeOut('fast',function() { 
							$.post("modal/"+filename+".php",
								   		{"hotel-id":hotelid,
										"room-month":m1,
										"room-year":y1,
										"room-id":roomid,
										"week":week,
										"st":aclass,
										"object-id":objectid},
									function(data){
										//$(".room-booking").serialize()
										$('.current .price-month-box').html(data); 
										//$('tr.current .price-month-box').height(loader_height);
										$('.current .price-month-box').fadeIn('fast',function() { $(base).removeClass('current');  });
							});
					});
				});
			});
		 });
	}
	load_singletwin();
	
	// single-twin date show
	function load_singletwindate()
	{
		var base="";
		$('.singletwin-date a').click(function (e) {
			e.preventDefault();
			
			/*if ($(".week").attr("value")=="1")
			{
				parent_class="tr";
				even_check="";
			}
			else
			{
				parent_class=".room-price";
				even_check="tr";
			}*/
			
			aclass = $(this).parents("p").attr("class");
			base=$(this).parents(".room-price");
			parent_base=$(this).parents(".prices-box");

			if ($(base).hasClass("base"))	filename="newtable_date_base";
			else	filename="newtable_date";
			
			if ($(parent_base).hasClass("housing"))	filename="housing_date";

			$(base).addClass('current');

			$(".current .singletwin-date a").removeClass('active');
			$(".current .singletwin-date a").removeClass('hover');
			$(".current .singletwin-date ."+aclass+" a").addClass('active');
			
			loader_height=$(".current .room-price-date").height();
			
			$('.current .room-price-date').fadeOut('fast',function() { 				
				
				$('.current .room-price-date').width('75%');
				$('.current .room-price-date').html('<div class="preloader-box">&nbsp;</div>');
				$('.current .preloader-box').height(loader_height);
				
				hotelid=$(".current .hotel-id").attr("value");
				roomid=$(".current .room-id").attr("value");
				datein=$(".current .date-in").attr("value");
				dateout=$(".current .date-out").attr("value");		
				objectid=$(".current .object-id").attr("value");		
				
				$('.current .room-price-date').fadeIn('fast',function() {
					$('.current .room-price-date').fadeOut('fast',function() { 
							$('.current .room-price-date').width('');
							
							$.post("modal/"+filename+".php",{
								   			"hotel-id":hotelid,
											"room-id":roomid,
										 	"date-in":datein,
											"date-out":dateout,
											"st":aclass,
											"object-id":objectid
											},
									function(data){
										$('.current .room-price-date').html(data); 
										base_select=".current .room-price-date select";

										$('.current .room-price-date').fadeIn('fast',function() { 
											$(base_select).msDropDown();
											$(base).removeClass('current');  
										});
							});
					});
				});
			});
		 });
	}
	load_singletwindate();
    
	//	rooms list changes
	function change_beds_list(){
		$('form.hotel .hotel-type .ddChild a').click(function (e) {
			e.preventDefault();
			
			room = $(this).html();
			parent = $(this).parents('.booking-room-type');

			$(parent).addClass('current');
			
			block_num = parseInt($(parent).attr("id").replace('booking-room-type-', ''));
			
			$('.current .hotel-people-count').fadeOut('slow',function() {
				$.post("modal/pipol_list.php",{roomname:room,count:block_num,hotelid:$(".hotel-id").attr("value")},function(data){
					$('.current .hotel-people-count').html(data); 
					$(".current .hotel-people-count select").msDropDown();
					$(".current #hotel-people-count-"+block_num+"_msdd").width(49);
					$(".current #hotel-people-count-"+block_num+"_child").width(47);
					$('.current .hotel-people-count').fadeIn('slow',function() { $(parent).removeClass('current');  });
				});
			});
		});
	}
	change_beds_list();
	
	//	rooms list changes
	function change_beds_list_base(){
		$('form.base .hotel-type .ddChild a').click(function (e) {
			e.preventDefault();
			
			room = $(this).html();
			parent = $(this).parents('.booking-room-type');

			$(parent).addClass('current');
			
			block_num = parseInt($(parent).attr("id").replace('booking-room-type-', ''));
			
			$('.current .hotel-people-count').fadeOut('slow',function() {
				$.post("modal/pipol_list_base.php",{roomname:room,count:block_num,hotelid:$(".hotel-id").attr("value")},function(data){
					$('.current .hotel-people-count').html(data); 
					$(".current .hotel-people-count select").msDropDown();
					
					//if ($(".current #hotel-people-count-"+block_num+"_child").height()>155)	height=155;
					//else	height=$(".current #hotel-people-count-"+block_num+"_child").height();
					
					//alert(height);
					$(".current #hotel-people-count-"+block_num+"_msdd").width(49);
					$(".current #hotel-people-count-"+block_num+"_child").width(47);
					
					$('.current .hotel-people-count').fadeIn('slow',function() { $(parent).removeClass('current');  });
				});
			});
		});
	}
	change_beds_list_base();

	
	function change_one_price()
	{
		$('.hotel-type .ddChild a').click(function (e) {
			e.preventDefault();
		
			room = $(this).html();
		
			parent = $(this).parents('.booking-room-type');
		
			$(parent).addClass('current');
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
		  
			days_count = ((dateout - datein)/(86400));
			
			$('.current .room-price').fadeOut('slow',function() {
				$('.current .room-price').html("&nbsp;"); 
				$.post("modal/price.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count},function(data){
					$('.current .room-price').html(data); 
					change_summ();
					$('.current .room-price').fadeIn('slow',function() { $(parent).removeClass('current'); pipol_count_change();  });
				});
			});
		});
	}
	change_one_price();
	
	function change_one_price_base()
	{
		$('.hotel-type .ddChild a').click(function (e) {
			e.preventDefault();
		
			room = $(this).html();
		
			parent = $(this).parents('.booking-room-type');
		
			$(parent).addClass('current');
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
		  
			days_count = ((dateout - datein)/(86400));
			
			$('.current .room-price').fadeOut('slow',function() {
				$('.current .room-price').html("&nbsp;"); 
				$.post("modal/price_base.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count},function(data){
					$('.current .room-price').html(data); 
					change_summ();
					$('.current .room-price').fadeIn('slow',function() { $(parent).removeClass('current'); pipol_count_change_base();  });
				});
			});
		});
	}
	change_one_price_base();
	
	function	change_all_prices()
	{	
		$('.hotel-booking-box form.hotel .booking-period .date').change(function (e) {															   
			e.preventDefault();
			
			var count = 0;
			var	array = new Array;
			
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
			//alert(dateout);
			if(datein!=-1 && dateout!=-1)
			{
				days_count = ((dateout - datein)/(86400));
			  
				$('.rooms-box .booking-room-type').each(function(){						
					id=$(this).attr("id");
					
					array[count++]=$("#"+id+" .textTitle").html();
				});
				
				$(".rooms-box").fadeOut('slow',function() {
					//height=$(".rooms-box").height();
					
					//$('.rooms-box').html('<div class="upload">&nbsp;</div>');
					//$('.rooms-box .upload').height(height);
														
					$.post("modal/price_block.php",$("form.booking-form").serialize(),function(data){ 
						$(".rooms-box").html(data);
						$(".rooms-box").fadeIn('slow',function(){ 
							change_summ(); 
							$(".rooms-box .hotel-people-count select").msDropDown();
							$(".rooms-box .hotel-type select").msDropDown();
							
							change_one_price();
							pipol_count_change();
							change_beds_list();
							booking_form_delete();
							
							room=$(".booking-hidden #hotel-type-bookingnum #1").html();
							$.post("modal/price.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count},function(data){
								$(".booking-hidden .room-price").html(data); 
							});
						});
					});
				});
			}
		});
	}
	change_all_prices();
	
	function	change_all_prices_base()
	{	
		$('.hotel-booking-box form.base .booking-period .date').change(function (e) {															   
			e.preventDefault();
			
			var count = 0;
			var	array = new Array;
			
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
			//alert(dateout);
			if(datein!=-1 && dateout!=-1)
			{
				days_count = ((dateout - datein)/(86400));
			  
				$('.rooms-box .booking-room-type').each(function(){						
					id=$(this).attr("id");
					
					array[count++]=$("#"+id+" .textTitle").html();
				});
				
				$(".rooms-box").fadeOut('slow',function() {
					//height=$(".rooms-box").height();
					
					//$('.rooms-box').html('<div class="upload">&nbsp;</div>');
					//$('.rooms-box .upload').height(height);
														
					$.post("modal/price_block_base.php",$("form.booking-form").serialize(),function(data){ 
						$(".rooms-box").html(data);
						$(".rooms-box").fadeIn('slow',function(){ 
							change_summ(); 
							$(".rooms-box .hotel-people-count select").msDropDown();
							$(".rooms-box .hotel-type select").msDropDown();
							
							change_one_price_base();
							pipol_count_change_base();
							change_beds_list_base();
							booking_form_delete();
							
							room=$(".booking-hidden #hotel-type-bookingnum #1").html();
							$.post("modal/price_base.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count},function(data){
								$(".booking-hidden .room-price").html(data); 
							});
						});
					});
				});
			}
		});
	}
	change_all_prices_base();
	
	function	change_summ()
	{
		var summa=0;
		//var old_summa=0;
		
		//old_summa=parseInt($(".compact-sum strong").html());
		
		$('.rooms-box .booking-room-type .room-price strong').each(function(){
			price=$(this).html();
			
			summa+=parseInt(price);
			//alert(summa);
		});
		//Итого 17310 руб. без учета скидок. 
		 if (summa>0)	$(".compact-sum").html("Итого <strong>"+summa+"</strong> руб. без учета скидок");
		 else	$(".compact-sum").html("Цена за весь период по запросу");
	}
	
	function	pipol_count_change()
	{
		$(".hotel-people-count .ddChild a").click(function(e){
			e.preventDefault();
			
			pipol=$(this).html();
			parent = $(this).parents('.booking-room-type');
		
			room = $("#"+$(parent).attr("id")+" .textTitle").html();
		
			$(parent).addClass('current');
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
		  
			days_count = ((dateout - datein)/(86400));
			
			$('.current .room-price').fadeOut('slow',function() {
				$('.current .room-price').html("&nbsp;"); 
				$.post("modal/price.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count,pipol:pipol},function(data){
					$('.current .room-price').html(data); 
					change_summ();
					$('.current .room-price').fadeIn('slow',function() { $(parent).removeClass('current');  });
				});
			});
		});
	}
	pipol_count_change();
	
	function	pipol_count_change_base()
	{
		$(".hotel-people-count .ddChild a").click(function(e){
			e.preventDefault();
			
			pipol=$(this).html();
			parent = $(this).parents('.booking-room-type');
		
			room = $("#"+$(parent).attr("id")+" .textTitle").html();
		
			$(parent).addClass('current');
			datein=parseInt($("#h-datein-alt").attr("value"))/1000;
			dateout=parseInt($("#h-dateout-alt").attr("value"))/1000;
		  
			days_count = ((dateout - datein)/(86400));
			
			$('.current .room-price').fadeOut('slow',function() {
				$('.current .room-price').html("&nbsp;"); 
				$.post("modal/price_base.php",{datein:datein,dateout:dateout,roomname:room,hotelid:$(".hotel-id").attr("value"),nights:days_count,pipol:pipol},function(data){
					$('.current .room-price').html(data); 
					change_summ();
					$('.current .room-price').fadeIn('slow',function() { $(parent).removeClass('current');  });
				});
			});
		});
	}
	pipol_count_change_base();
	
    /* SEARCH more */
    $('#hotel-search-form .search-more a').click(function (e) {
      e.preventDefault();
      $('#hotel-search-form .search-more-box').slideToggle();
      $('#hotel-search-form .search-more a span').toggleClass("hidden");
      $("#hotel-search-form .search-more-box select.msdropdown").msDropDown();
    });
    
    /* input tips */
    function phone_tip() {
      if($('.phone-code-tip').length) {
        if ($('.phone-code-tip').val() == '') {$('.phone-code-tip').addClass('phone-code-tip-active');}
        else {$('.phone-code-tip').removeClass('phone-code-tip-active');}
      }
      if($('.phone-tip').length) {
        if ($('.phone-tip').val() == '') {$('.phone-tip').addClass('phone-tip-active');}
        else {$('.phone-tip').removeClass('phone-tip-active');}
      }
    }
    phone_tip();
    $(".phone-code-tip").focus(function() {$('.phone-code-tip').removeClass('phone-code-tip-active');}).blur(function() {phone_tip();});
    $(".phone-tip").focus(function() {$('.phone-tip').removeClass('phone-tip-active');}).blur(function() {phone_tip();});
    
    /* SEARCH change city */
    function highlight_city(){
      checked_input = $(".hotel-city input:checked").val();
      base = $(".hotel-city input:checked").parents("span.radio");
      if ($(base).hasClass("radio-active").toString() == 'false') {
        $(".hotel-city span.radio").removeClass("radio-active");
        $(base).addClass("radio-active");
      }
      $("#hotel-search-form p.hotel-metro").hide();
      $("#hotel-search-form p.hotel-district").hide();
	  $("#hotel-search-form p.hotel-surround").hide();
	  
      $("#hotel-search-form p.metro-" + checked_input ).show();
      $("#hotel-search-form p.district-" + checked_input ).show();
	  $("#hotel-search-form p.surround-" + checked_input ).show();
	  
      $("#hotel-search-form select.msdropdown").msDropDown();
	  
	  if ($(".radio-active input").attr("value")=="msk")
	  {
			$("#search-hotel-title-msk").attr("value",$("#search-hotel-title-spb").attr("value"));
			$("#search-hotel-title-spb").hide();
			$("#search-hotel-title-msk").show();
	  }
	  else
	  {
		  	$("#search-hotel-title-spb").attr("value",$("#search-hotel-title-msk").attr("value"));
			$("#search-hotel-title-msk").hide();
			$("#search-hotel-title-spb").show();
	  }
    }
    highlight_city();
	
    function highlight_region2(){
      checked_input = $(".region-city input:checked").val();
	  
      base = $(".region-city input:checked").parents("span.radio");
      if ($(base).hasClass("radio-active").toString() == 'false') {
        $(".region-city span.radio").removeClass("radio-active");
        $(base).addClass("radio-active");
      }
	  
	 /* $("#recreation-search-form p.recr-district").hide();
      $("#recreation-search-form p.recr-dest").hide();
	  
      $("#recreation-search-form p.recr-district-" + checked_input ).show();
      $("#recreation-search-form p.recr-dest-" + checked_input ).show();
	  
	  $("#recreation-search-form select.msdropdown").msDropDown();*/
    }
    highlight_region2();
	
    $(".hotel-city span.radio label").click(function(){
      $(".hotel-city span.radio").removeAttr("checked");
      $('#' + $(this).attr("for")).attr("checked", "checked");
      highlight_city();
    });
	
    $(".region-city span.radio label").click(function(){
      $(".region-city span.radio").removeAttr("checked");
      $('#' + $(this).attr("for")).attr("checked", "checked");
      highlight_region2();
    });
	
	/* SEARCH change region */
    function highlight_region(){
	  checked_input = $(".recr-region input:checked").val();
	  //alert(checked_input);
      base = $(".recr-region input:checked").parents("span.radio");
      if ($(base).hasClass("radio-active").toString() == 'false') {
        $(".recr-region span.radio").removeClass("radio-active");
        $(base).addClass("radio-active");
      }
      
	  $("#hotel-search-form p.recr-district").hide();
      $("#hotel-search-form p.recr-dest").hide();
	  //$("#hotel-search-form p.hotel-surround").hide();
	  
      $("#hotel-search-form p.distr-" + checked_input ).show();
      $("#hotel-search-form p.dest-" + checked_input ).show();
	  //$("#hotel-search-form p.surround-" + checked_input ).show();
	  
      $("#hotel-search-form select.msdropdown").msDropDown();
    }
    highlight_region();
	
    $(".recr-region span.radio label").click(function(){
      $(".recr-region span.radio").removeAttr("checked");
      $('#' + $(this).attr("for")).attr("checked", "checked");
      highlight_region();
    });
    
    /* SEARCH change center */
    function highlight_center(){
      checked_input = $(".hotel-center input:checked").val();
      base = $(".hotel-center input:checked").parents("span.radio");
      if ($(base).hasClass("radio-active").toString() == 'false') {
        $(".hotel-center span.radio").removeClass("radio-active");
        $(base).addClass("radio-active");
      }
    }
	
    highlight_center();
    $(".hotel-center span.radio label").click(function(){
      //$(".hotel-center span.radio").removeAttr("checked");
      $('#' + $(this).attr("for")).attr("checked", "checked");
      highlight_center();}
    );
    
    /* SEARCH Switch tabs to hotel */
    $('#hotel-search-form .hotel-title').click(function (e) {
      e.preventDefault();
      if ($('#hotel-search-form .hotel-title').hasClass("active")){ }
      else {
        $('#hotel-search-form h2').removeClass("active");
        $(this).addClass("active");
        $('#hotel-search-form .form-box').removeClass("active");
        $('#hotel-search-form .hotel-search-form').addClass("active");
        $("#hotel-search-form select.msdropdown").msDropDown();
      }
    });
    
    /* SEARCH Switch tabs to recreation */
    $('#hotel-search-form .recreation-title').click(function (e) {
      e.preventDefault();
      if ($('#hotel-search-form .recreation-title').hasClass("active")){ }
      else {
        $('#hotel-search-form h2').removeClass("active");
        $(this).addClass("active");
        $('#hotel-search-form .form-box').removeClass("active");
        $('#hotel-search-form .recreation-search-form').addClass("active");
		$(".recreation-search-form select.msdropdown").msDropDown();
      }
    });
    
    /* BEST OFFERS menu */
    $('#best-offers .tabs-titles li').click(function (e) {
      e.preventDefault();
      if ($(this).hasClass("active")){ }
      else {
        $('#best-offers .tabs-titles li').removeClass("active");
        $(this).addClass("active");
      }
    });
    
    /* BEST OFFERS Switch tabs */
    $('#best-offers .tabs-titles li').click(function (e) {
      e.preventDefault();
      var block_height = $("#best-offers .ajax-content").height();
      var href = $(this).children("a").attr('href');
      $("#best-offers .tabs-titles li").removeClass("active");
      $(this).addClass("active");
      $('#best-offers .ajax-content').fadeOut('slow', function() {
        $('#best-offers .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
        $('#best-offers .ajax-content .preloader-box').height(block_height);
        $('#best-offers .ajax-content').fadeIn('slow', function() {
          $.get(href,
            function(data){
              $('#best-offers .ajax-content').fadeOut('slow', function() {
                text = $('#best-offers .ajax-content').html(data);
                $('#best-offers .ajax-content').fadeIn('slow');
                offers_types();
              });
            });
        });
      });
    });
    
    /* BEST OFFERS Switch types */
    function offers_types() {
      $('#best-offers .tabs-content li').not(".all").click(function (e) {
        e.preventDefault();
        var block_height = $("#best-offers .ajax-content").height();
        var href = $(this).children("a").attr('href');
        $("#best-offers .tabs-content li").removeClass("active");
        $(this).addClass("active");
        $('#best-offers .ajax-content').fadeOut('slow', function() {
          $('#best-offers .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
          $('#best-offers .ajax-content .preloader-box').height(block_height);
          $('#best-offers .ajax-content').fadeIn('slow', function() {
            $.get(href,
              function(data){
                $('#best-offers .ajax-content').fadeOut('slow', function() {
                  text = $('#best-offers .ajax-content').html(data);
                  $('#best-offers .ajax-content').fadeIn('slow');
                  offers_types();
                });
              });
          });
        });
      });
    }
    offers_types();
    
    /* BEST RECREATION menu */
    $('#best-offers-recreations .tabs-titles li').click(function (e) {
      e.preventDefault();
      if ($(this).hasClass("active")){ }
      else {
        $('#best-offers-recreations .tabs-titles li').removeClass("active");
        $(this).addClass("active");
      }
    });
    
    /* BEST RECREATION Switch tabs */
    $('#best-offers-recreations .tabs-titles li').click(function (e) {
      e.preventDefault();
      var block_height = $("#best-offers-recreations .ajax-content").height();
      var href = $(this).children("a").attr('href');
      $("#best-offers-recreations .tabs-titles li").removeClass("active");
      $(this).addClass("active");
      $('#best-offers-recreations .ajax-content').fadeOut('slow', function() {
        $('#best-offers-recreations .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
        $('#best-offers-recreations .ajax-content .preloader-box').height(block_height);
        $('#best-offers-recreations .ajax-content').fadeIn('slow', function() {
          $.get(href,
            function(data){
              $('#best-offers-recreations .ajax-content').fadeOut('slow', function() {
                text = $('#best-offers-recreations .ajax-content').html(data);
                $('#best-offers-recreations .ajax-content').fadeIn('slow');
                recreations_types();
              });
            });
        });
      });
    });
    
    /* BEST RECREATION Switch types */
    function recreations_types() {
      $('#best-offers-recreations .tabs-content li').not(".all").click(function (e) {
        e.preventDefault();
        var block_height = $("#best-offers-recreations .ajax-content").height();
        var href = $(this).children("a").attr('href');
        $("#best-offers-recreations .tabs-content li").removeClass("active");
        $(this).addClass("active");
        $('#best-offers-recreations .ajax-content').fadeOut('slow', function() {
          $('#best-offers-recreations .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
          $('#best-offers-recreations .ajax-content .preloader-box').height(block_height);
          $('#best-offers-recreations .ajax-content').fadeIn('slow', function() {
            $.get(href,
              function(data){
                $('#best-offers-recreations .ajax-content').fadeOut('slow', function() {
                  text = $('#best-offers-recreations .ajax-content').html(data);
                  $('#best-offers-recreations .ajax-content').fadeIn('slow');
                  recreations_types();
                });
              });
          });
        });
      });
    }
    recreations_types();
    
    /* DATES CHANGE CUSTOM RANGE */
      function customRange2(input) {
		var date="";  
		var base = $(this).parents('.room-price').attr('id');
		
		if ($('#' + base + " .date-in").datepicker("getDate"))	date=$('#' + base + " .date-in").datepicker("getDate");
		else date=new Date;  
        
        if ($(input).hasClass('date-in')){return {maxDate: $('#' + base + " .date-out").datepicker("getDate"), minDate:new Date};}
        if ($(input).hasClass('date-out')){return {minDate: date, maxDate: null};}
      }
    
    /* DATES CHANGE SHOW */
    function dates_change_show(base_id) {
      $('.dates-change span').click(function (e) {
        e.preventDefault();
		var base = "";

        if (base_id)	base = $(this).parents('#' + base_id + '').attr('id');
	    else	base = $(this).parents('.room-price').attr('id');
		
		
        $("#" + base + ' .dates-change-form').slideToggle('slow', function() {
          $('#' + base + ' .dates-change-form input').datepicker({showOn: 'both', buttonImage: 'img/common/calendar.png', buttonImageOnly: true, beforeShow: customRange2});
        });
      });
    }
    dates_change_show();
    
    /* DATES CHANGE RESET */
	function dates_change_reset() {
		$('.dates-change .reset a').click(function (e) {
			e.preventDefault();
			
			parent_class=$(this).parents(".prices-box");
			parent_base=$(this).parents(".room-price");
			
			if ($(parent_class).hasClass("housing"))	{	 filename="housing";	}
			else if ($(parent_class).hasClass("objects"))	{	 filename="objects";	}
			else	{	filename="dates";	}
			
			if ($(parent_base).hasClass("base"))	filename="allobjects";
			
			var base = $(this).parents('.room-price');
			$('#'+$(base).attr("id")+' .dates-change-form input').val('');
			
			$(base).addClass("current");
			
			loader_height=$(".current .price-month-box").height();
			
			object=$('.current  .object-id').attr("value");
			array = $('.current .ajax-content-box form').serialize()+"&object-id="+object;
			
			//dropdown=$(".current .ajax-content-box select").attr("id");
			
			$('.current .ajax-content-box ').fadeOut('slow',function() {	
				
				$('.current .ajax-content-box').html('<div class="preloader-box">&nbsp;</div>');
				$('.current .preloader-box').height(loader_height);
				//$('.current .singletwin').height(loader_height-136);
				
				$('.current .ajax-content-box ').fadeIn('slow',function() {
					$('.current .ajax-content-box ').fadeOut('slow',function() {
																			 
						$.post("modal/"+filename+"_delete.php",array, function(data){
							$(".current .ajax-content-box").html(data);
							
							$(".current .ajax-content-box").fadeIn('slow',function() {
								//alert($(".current .ajax-content-box select").attr("id"));
							
								$(".current .ajax-content-box select").msDropDown();
								
								dates_change_month_next();
								dates_change_month_prev();
								dates_change_select();
								dates_change_show($(base).attr("id"));
								dates_change_reset();
								roomprice_details($(base).attr("id"));
								load_singletwin();
								hover_singletwin();
								dates_change_submit();
								
								$(base).removeClass("current");
							});
							
						});
						
					});
				});
			});
		});
	}
    dates_change_reset();
    
    /* DATES CHANGE Submit */
    function dates_change_submit() {
      $('.dates-change .accept a').click(function (e) {
        e.preventDefault();
        var base = $(this).parents('.room-price').attr('id');
		//alert($('#' + base + ' .date-in').attr("value"));
        
		if ($('#' + base + ' .date-in').attr("value")!="" && $('#' + base + ' .date-out').attr("value")!="")
		{
			load_price_by_date(base);
		}
      });
    }
    dates_change_submit();
    
    /* DATES CHANGE MONTH PREV*/
    function dates_change_month_prev() {
		//alert("prev");
      $('.current-date a.prev').click(function (e) {
        e.preventDefault();
        var prev_month = -1;
        var prev_year = -1;
        var base = $(this).parents('.room-price').attr('id');
        var current_month = parseInt($('#' + base + ' .room-month').val());
        var first_month = parseInt($('#' + base + ' .room-month option:first').val());
        var current_year = parseInt($('#' + base + ' .room-year').val());
        var first_year = parseInt($('#' + base + ' .room-year option:first').val());
        if (current_month > first_month) {
          $('#' + base + ' .room-month option').each(function(){
            if (this.value < current_month) {prev_month = this.value;}
          });
          prev_year = current_year;
        }
        else {
          if (current_year > first_year) {
            $('#' + base + ' .room-year option').each(function(){
              if (this.value < current_year) {prev_year = this.value;}
              prev_month = parseInt($('#' + base + ' .room-month option:last').val());
            });
          }
        }
        if (prev_month > 0 && prev_year > 0){
          $('#' + base + ' .room-month').val(prev_month);
          $('#' + base + ' .room-year').val(prev_year);
          load_price_by_month(base);
		 // dates_change_select();
		  hover_singletwin();
          $('#' + base + ' .current-date select').msDropDown();
        }
      });
    }
    dates_change_month_prev();
    
    /* DATES CHANGE MONTH NEXT */
    function dates_change_month_next() {
      $('.current-date a.next').click(function (e) {
        e.preventDefault();
        var next_month = -1;
        var next_year = -1;
        var base = $(this).parents('.room-price').attr('id');
        var current_month = parseInt($('#' + base + ' .room-month').val());
        var last_month = parseInt($('#' + base + ' .room-month option:last').val());
        var current_year = parseInt($('#' + base + ' .room-year').val());
        var last_year = parseInt($('#' + base + ' .room-year option:last').val());
        if (current_month < last_month) {
          next_month =  parseInt($('#' + base + ' .room-month option:selected').next().val());
          next_year = current_year;
        }
        else {
          if (current_year < last_year) {
            next_year =  parseInt($('#' + base + ' .room-year option:selected').next().val());
            next_month = parseInt($('#' + base + ' .room-month option:first').val());
          }
        }
        if (next_month > 0 && next_year > 0){
          $('#' + base + ' .room-month').val(next_month);
          $('#' + base + ' .room-year').val(next_year);
          load_price_by_month(base);
		  //dates_change_select();
		  hover_singletwin();
          $('#' + base + ' .current-date select').msDropDown();
        }
      });
    }
    dates_change_month_next();
    
    /* DATES CHANGE SELECT */
    function dates_change_select() {
      $('.current-date .ddChild a').click(function () {
        var base = $(this).parents('.room-price').attr('id');
        load_price_by_month(base);
      });
    }
    dates_change_select();
    
    /* AJAX ROOM PRICE BY MONTH */
    function load_price_by_month(base_id) {
	  
	  parent_class=$('#' + base_id + '').parents(".prices-box");
	  parent_main=$('#'+base_id+'');
	  	  
	  if ($(parent_class).hasClass("services"))	
	  {
		  filename="services";
	  }
	  else if ($(parent_class).hasClass("housing"))	
	  {
		  filename="housing";
	  }
	  else if ($(parent_class).hasClass("objects"))	
	  {
		  filename="objects";
	  }
	  else	filename="roomprice";
	  
	  if ($(parent_main).hasClass("base"))	
	  {
		  filename="allobjects";
	  }
	  
	  //alert(base_id);
      loader_height = $('#' + base_id + ' .room-price-table-box').height();
      if (loader_height < 80) {loader_height = 80;}
      $('#' + base_id + ' .room-price-table-box .ajax-content').fadeOut('slow', function() {
        $('#' + base_id + ' .room-price-table-box .ajax-content').html('<div class="preloader-box">&nbsp;</div>');
        $('#' + base_id + ' .room-price-table-box .preloader-box').height(loader_height);
        $('#' + base_id + ' .room-price-table-box .ajax-content').fadeIn('slow', function() {
            $.post("modal/"+filename+"_by_month.php", $('#' + base_id + ' form').serialize(), function(data){
                $('#' + base_id + ' .room-price-table-box .ajax-content').fadeOut('slow', function() {
                  text = $('#' + base_id + ' .room-price-table-box .ajax-content').html(data);
                  $('#' + base_id + ' .room-price-table-box .ajax-content').fadeIn('slow');
                  $('#' + base_id + ' table select').msDropDown();
				  //alert(base_id);
                  roomprice_details(base_id);
				  dates_change_select();
				  hover_singletwin();
				  load_singletwin();
                });
              });
          });
      });
    }
	
    /* AJAX ROOM PRICE BY DATE */
    function load_price_by_date(base_id) {
	  var	array=$('#' + base_id + ' form').serialize()+"&object-id="+$('#' + base_id + ' form .object-id').attr("value");
	  
	  parent_base=$('#' + base_id + '').parents(".prices-box");
	  
	  if ($('#' + base_id + '').hasClass("base"))
	  {
		 filename="baseprice";
	  }
	  else
	  {
		 filename="roomprice";
	  }
	  
	  if ($(parent_base).hasClass("housing"))	 filename="housing";
	  if ($(parent_base).hasClass("objects"))	 filename="objects";
	 
      loader_height = $('#' + base_id ).height();
      $('#' + base_id + ' .ajax-content-box').fadeOut('slow', function() {
        $('#' + base_id + ' .ajax-content-box').html('<div class="preloader-box">&nbsp;</div>');
        $('#' + base_id + ' .preloader-box').height(loader_height);
        $('#' + base_id + ' .ajax-content-box').fadeIn('slow', function() {
            $.post("modal/"+filename+"_by_date.php", array, function(data){
                $('#' + base_id + ' .ajax-content-box').fadeOut('slow', function() {
                  text = $('#' + base_id + ' .ajax-content-box').html(data);
                  
				  $('#' + base_id + ' .ajax-content-box').fadeIn('slow');
                  $('#' + base_id + ' table select').msDropDown();	//
				  
				  $('#' + base_id + ' table select').each(function(){$("#"+$(this).attr("id")+"").msDropDown();});
				  
                  dates_change_submit();
                  dates_change_reset();
				 // hover_singletwin();
				  hover_singletwindate();
                  dates_change_show(base_id);
				  load_singletwindate();
				  
                });
              });
          });
      });
    }

});

