///////////////////////////////---podbor_tura.html start---////////////////////////////////////
var animation_speed = 200;

/* Для датапикера

var my_month;
dates = new Array;

function select_dates(){
				dates.length = 0;
				var city = 'city='+$('#city span').attr('name');
				var country = '&country='+$('#country span').attr('name');
				var month = '&month='+(my_month + 1);
				var url= city+''+country+''+month;
				alert (url);
				$.ajax({
					beforeSend: function(){},
					data: (url),
					type: "get",
					url: "php/select_dates.php",
					dataType : "html",
					async: false,
					success: function(data){
							if (/<!--error-->/.test(data) || /<!--warning-->/.test(data))
							{
								
							}
							else{
								//alert (data);
								var dates_num = data.split(',');
								for (i=0; i<dates_num.length; i++) {
									
									dates_num[i] = dates_num[i].trim();
									dates[''+dates_num[i]+''] = dates_num[i];
									
								}
							}
						}
						
				});
}
Для датапикера */

function selected_page(){
//var active_menu = '<div class="menu_item_bg"><div class="menu_item_bg_center"></div><div class="menu_item_bg_left"></div><div class="menu_item_bg_right"></div></div>';
var active_menu = '<div class="menu_item_bg"></div>'+$('.menu_item a[href='+page+']').parent().html()+'<div class="menu_item_bg_center_new"></div>';
//$(active_menu).appendTo($('.menu_item a[href='+page+']'));
$('.menu_item a[href='+page+']').parent().html(active_menu);;
document.title = 'Банана тур - '+$('.menu_item a[href='+page+']').text();
	$('.menu_item').mouseenter(function(){
		if ($(this).find('.menu_item_bg').html() != null){}
		else{ 
			//alert ($(this).html());
			$(this).html('<div class="menu_item_bg"></div>'+$(this).html());
		}
	}).mouseleave(function(){
		if ($(this).find('.menu_item_bg_center_new').html() != null){}
		else{
			$(this).find('.menu_item_bg').remove();
		}
	});
}
function show_and_hide_select_detect(what_class){
	$.each($('.'+what_class+' span'), function(){
		if (/width/.test($(this).parent().attr('style'))){
			$(this).css({
				maxWidth: $(this).parent().css('width')
			});
		}
		else{}
	});
	$('.'+what_class+' span').bind('click', function(){
		var id = $(this).parent().attr('id');
		var width = $('#'+id).width();
		var display = $('#'+id+' ul').css('display');
		
		if (what_class == 'select_list_box'){
			show_and_hide_select_box(what_class, id, width, display);
		}
		else{
			show_and_hide_select(what_class, id, width, display);
		}
	});
	
	$('.'+what_class+' img').bind('click', function(){
		var id = $(this).parent().attr('id');
		var width = $('#'+id).width();
		var display = $('#'+id+' ul').css('display');
		
		if (what_class == 'select_list_box'){
			show_and_hide_select_box(what_class, id, width, display);
		}
		else{
			show_and_hide_select(what_class, id, width, display);
		}
	});
	
}
function show_and_hide_select(what_class, id, width, display){
//alert ('#'+id+' ul');
	if (display == 'none'){
		$('.'+what_class+' ul').css('display', 'none');
		$('#'+id+' ul').css({
			minWidth: width+'px',
			display: 'block'
		});
		$('#'+id+' ul li').bind('click', function(){
			$('#'+id+' span').text($(this).text());
			$('#'+id+' span').attr('name', $(this).attr('name'));
			$('#'+id+' ul').css('display', 'none');
			//$('#'+id+' ul li').unbind('click');
		});
		
		$('#'+id+' ul li').mouseenter(function(){
			$(this).css('backgroundColor', '#b4c5d5');
		}).mouseleave(function(){
			$(this).css('backgroundColor', 'transparent');
		});
		
		$('#'+id).mouseenter(function(){
			$('body').unbind('click');
		}).mouseleave(function(){
			$('body').bind('click', function(){
				$('#'+id+' ul').css('display', 'none');
				$('body').unbind('click');
			});
		});
	}
	else{
		$('#'+id+' ul').css('display', 'none');
	}
}
function show_and_hide_select_box(what_class, id, width, display){
//alert ('#'+id+' ul');
	if (display == 'none'){
		$('.'+what_class+' ul').css('display', 'none');
		$('#'+id+' ul').css({
			minWidth: width+'px',
			display: 'block'
		});
		/*
		$('#'+id+' ul li').bind('click', function(){
			$('#'+id+' span').text($(this).text());
			$('#'+id+' span').attr('name', $(this).attr('name'));
			$('#'+id+' ul').css('display', 'none');
			//$('#'+id+' ul li').unbind('click');
		});
		*/
		$('#'+id+' ul li').mouseenter(function(){
			$(this).css('backgroundColor', '#b4c5d5');
		}).mouseleave(function(){
			$(this).css('backgroundColor', 'transparent');
		});
		
		$('#'+id).mouseenter(function(){
			$('body').unbind('click');
		}).mouseleave(function(){
			$('body').bind('click', function(){
				$('#'+id+' ul').css('display', 'none');
				$('body').unbind('click');
			});
		});
	}
	else{
		$('#'+id+' ul').css('display', 'none');
	}
}
function drag_select_h_detect(what_class){
		$('.'+what_class+' div').draggable({
						start: function(event, ui){
							$(this).text('');
						},
						containment: 'parent',
						stop: function(event, ui){
							var id = $(this).parent().parent().attr('id');
							
							var left = $(this).css('left').replace(/px/, '');
							left = Math.round(left / 27) * 27;
							$(this).animate({
							left: left+'px'
							}, animation_speed, function(){
								//alert (left/27);
								//$(this).text(left/27 + ($(this).parent().find('li').eq(0).text()*1));
								$(this).text($(this).parent().find('li').eq(left/27).text());
								//alert ($(this).parent().find('li').eq(left/27).text());
							});
						}
					});
		$('.'+what_class+' li').click(function(){
			//alert ($(this).index());
			var left = $(this).index() * 27;
			//alert (left);
			$(this).parent().parent().find('div').text('');
			$(this).parent().parent().find('div').animate({
			left: left+'px'
			}, animation_speed, function(){
				$(this).text($(this).parent().find('li').eq(left/27).text());
			});
		});
		$.each($('.'+what_class), function(){
			//alert ($(this).attr('id'));
			$(this).find('img').eq(0).click(function(){
				var left = $(this).parent().find('div').css('left').replace(/px/, '');
				left = (Math.round(left / 27)-1) * 27;
				if (left >= 0){
					$(this).parent().find('div').text('');
					$(this).parent().find('div').animate({
					left: left+'px'
					}, animation_speed, function(){
						$(this).text($(this).parent().find('li').eq(left/27).text());
					});
				}
				else{}
			});
			$(this).find('img').eq(1).click(function(){
				var left = $(this).parent().find('div').css('left').replace(/px/, '');
				left = (Math.round(left / 27)+1) * 27;
				//alert (left);
				if (left <= 81){
					$(this).parent().find('div').text('');
					$(this).parent().find('div').animate({
					left: left+'px'
					}, animation_speed, function(){
						$(this).text($(this).parent().find('li').eq(left/27).text());
					});
				}
				else{}
			});
		});
}
function stars_detect(){
	$('#stars li.star_enabled').click(function(){
		$('#stars li').removeClass('active_star');
		var index = $(this).index();
		for (i=0; i<index+1; i++){
			$('#stars li').eq(i).addClass('active_star');
		}
		//var length = $('#stars li').length;
		get_hotels();
	});
}

//-----------------------------GET START---------------------------//

function get_curorts(new_w){
	var country = '&countryId='+$('#country span').attr('name');
	var url = 'debug=0'+country;
	//alert (url);
	$.ajax({
		beforeSend: function(){},
		data: (url),
		type: "get",
		//url: "http://module.sletat.ru/Main.svc/GetCities",
		url: "php/select_curorts.php",
		//dataType : "jsonp",
		dataType : "json",
		//dataType : "html",
		success: function(data){
			var html = '';
			$('#curorts span').text('Все курорты');
			var html_href = '<a href="javascript: void(0)" onclick="$(\'#curorts li input\').attr(\'checked\', false); add_curort()">Очистить</a>';
			//html = html+''+data;
			
			for (i=0; i<data.GetCitiesResult.Data.length; i++){
				var jr = data.GetCitiesResult.Data[i];
				html = html+'<li><div><input type="checkbox" name='+jr.Id+' onclick="add_curort()" /><a>'+jr.Name+'</a></div></li>';
			}
			
			
			//alert (html);
			$('#curorts ul').find('.select_green_li_wrapper').html(html);
			$('#curorts ul').find('.empty_10px').eq(1).html(html_href);
			$('#curorts li a').click(
				function(){
					if ($(this).parent().find('input[type=checkbox]').attr('checked')){
						$(this).parent().find('input[type=checkbox]').attr('checked', false);
						add_curort();
					}
					else{
						$(this).parent().find('input[type=checkbox]').attr('checked', true);
						add_curort();
					}
				});
			if (new_w == 1){
			set_curorts();
			add_curort(1);
			}
			else{
			add_curort();
			}
		}
	});
}
function get_hotels(new_w){
	var country = '&countryId='+$('#country span').attr('name');
	if ($('#curorts li input:checked').length == 0){
		var towns = '&towns=';
	}
	else{
		towns_mass = new Array;
		for(i=0; i<$('#curorts li input:checked').length; i++){
			towns_mass[i] = $('#curorts li input:checked').eq(i).attr('name');
		}
		var towns = '&towns='+towns_mass.join(',');
	}
	//alert ($('#stars_better:checked').length);
	if ($('#stars_better:checked').length == 0){
		var stars = '&stars='+$('#stars .active_star').last().attr('name');
	}
	else{
		stars_mass = new Array;
		stars_mass[0] = $('#stars .active_star').last().attr('name');
		for (i=0; i<$('#stars .active_star').last().nextAll().length; i++){
			stars_mass[i+1] = $('#stars .active_star').last().nextAll().eq(i).attr('name');
		}
		var stars ='&stars='+stars_mass.join(',');
	}
	var url = 'debug=0'+country+''+towns+''+stars+'&filter=&all=9999';
	//alert (url);
	$.ajax({
		beforeSend: function(){},
		data: (url),
		type: "get",
		url: "http://module.sletat.ru/Main.svc/GetHotels",
		//url: "php/hlam_hotels.php",
		dataType : "jsonp",
		//dataType : "html",
		success: function(data){
			var html = '';
			//html = html+''+data;
			
			for (i=0; i<data.GetHotelsResult.Data.length; i++){
				var jr = data.GetHotelsResult.Data[i];
				html = html+'<li name="'+jr.Id+'"><img src="images/hotels_plus.png" />'+jr.Name+'</li>';
			}
			
			$('#hotels').html(html);
			add_hotel();
			//alert ($('#hotels li').length);
			if (new_w == 1){
			set_hotels();
			get_search_result();
			}
			else{}
		}
	});
	
}
function get_search_result(){
	//var url = 'debug=0&filter=0&f_to_id=0&fake=0&vk_group_id=0&extend=0&requestId=0&userId=&pageSize=100&pageNumber=1&countryId=40&countryName=%D0%95%D0%B3%D0%B8%D0%BF%D0%B5%D1%82&cityFromId=832&cityFromName=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0&cities=&cityNames=&meals=&mealNames=&stars=&starNames=&hotels=&hotelNames=&s_adults=2&s_kids=0&s_nightsMin=3&s_nightsMax=15&s_priceMin=&s_priceMax=&currencyAlias=RUB&s_departFrom=07%2F06%2F2011&s_departTo=13%2F06%2F2011&visibleOperators=&hiddenOperators=&requestTimeout=1&s_hotelIsNotInStop=true&s_hasTickets=false&s_ticketsIncluded=false&s_clearCache=false&updateResult=0';
	var url = 'debug=0&filter=0&f_to_id=0&fake=0&vk_group_id=0&extend=0&requestId=0&userId=';
	url = url+'&pageSize=100&pageNumber=1';
	
	var countryId = '&countryId='+$('#country span').attr('name');
	var countryId_number = $('#country span').attr('name');
	var cityFromId = '&cityFromId='+$('#cityFrom span').attr('name');
	
	var cities = '&cities=';
	cities_mass = new Array;
	for (i=0; i<$('#curorts input:checked').length; i++){
		cities_mass[i] = $('#curorts input:checked').eq(i).attr('name');
	}
	cities = cities+''+cities_mass.join(',');
	
	if ($('#meals_better:checked').length == 0){
		var meals = '&meals='+$('#meals span').attr('name');
	}
	else{
		meals_mass = new Array;
		meals_mass[0] = $('#meals span').attr('name');
		for (i=0; i<$('#meals li[name='+meals_mass[0]+']').nextAll().length; i++){
			meals_mass[i+1] = $('#meals li[name='+meals_mass[0]+']').nextAll().eq(i).attr('name');
		}
		var meals ='&meals='+meals_mass.join(',');
	}
	
	if ($('#stars_better:checked').length == 0){
		var stars = '&stars='+$('#stars .active_star').last().attr('name');
	}
	else{
		stars_mass = new Array;
		stars_mass[0] = $('#stars .active_star').last().attr('name');
		for (i=0; i<$('#stars .active_star').last().nextAll().length; i++){
			stars_mass[i+1] = $('#stars .active_star').last().nextAll().eq(i).attr('name');
		}
		var stars ='&stars='+stars_mass.join(',');
	}
	
	var hotels = '&hotels=';
	hotels_mass = new Array;
	for (i=0; i<$('#hotels_add li:visible').length; i++){
		hotels_mass[i] = $('#hotels_add li:visible').eq(i).attr('name');
	}
	hotels = hotels+''+hotels_mass.join(',');
	
	var s_adults = '&s_adults='+$('#adults span div').text();
	var s_kids = '&s_kids='+$('#kids span div').text();
	var s_nightsMin = '&s_nightsMin='+$('#nightsMin span').attr('name');
	var s_nightsMax = '&s_nightsMax='+$('#nightsMax span').attr('name');
	
	var url_values = countryId+''+cityFromId+''+cities+''+meals+''+stars+''+hotels+''+s_adults+''+s_kids+''+s_nightsMin+''+s_nightsMax;
	url = url+''+url_values;
	var url_hash = url_values;
	
	url = url+'&s_priceMin=&s_priceMax=&currencyAlias=RUB';
	
	//%2F
	var date_str = $.datepicker.formatDate('mm/dd/yy', $.datepicker.parseDate('dd MM yy', $('#date').attr('value')));
	var day_plus = $('#date_plus span').attr('name')*1;
	
	var date = new Date(date_str);
	date.setDate(date.getDate() - day_plus);
	var s_departFrom = addZero(date.getDate())+'/'+addZero(date.getMonth()+1)+'/'+date.getFullYear();
	s_departFrom = '&s_departFrom='+s_departFrom;
	
	var date = new Date(date_str);
	date.setDate(date.getDate() + day_plus);
	var s_departTo = addZero(date.getDate())+'/'+addZero(date.getMonth()+1)+'/'+date.getFullYear();
	s_departTo = '&s_departTo='+s_departTo;
	
	url_values = s_departFrom+''+s_departTo;
	url = url+''+url_values;
	url_hash = url_hash+''+url_values;
	
	url = url+'&visibleOperators=&hiddenOperators=&requestTimeout=5&s_hotelIsNotInStop=true&s_hasTickets=false&s_ticketsIncluded=false&s_clearCache=false&updateResult=0';
	//window.location.hash = url_hash;
	//alert (url);
	
	$.ajax({
		beforeSend: function(){
			$('#search_result').css('display', 'none');
			$('#search_result_text').html('');
			$('#podbor_tura_button').css('display', 'none');
			$('#podbor_tura_button_preloader').css('display', 'block');
		},
		data: (url),
		type: "get",
		url: "http://module.sletat.ru/Main.svc/GetTours",
		dataType : "jsonp",
		success: function(data){
			//alert (data);
			
			var html = '';
			//html = html+'<table border="1" width="100%">';
			sr_hotels_mass = new Array();
			for (i=0; i<data.GetToursResult.Data.aaData.length; i++){
				var jr = data.GetToursResult.Data.aaData[i];
				//alert (jr[15]);
				//html = html+'<tr>';
					if (window.sr_hotels_mass[jr[3]]){
						var number = sr_hotels_mass[jr[3]].length;
						sr_hotels_mass[jr[3]][number] = new Array();
						sr_hotels_mass[jr[3]][number][4] =  thousands_sep(''+jr[15].replace(/\D/g,'')+'', ' ');
						sr_hotels_mass[jr[3]][number][5] =  jr[9].toLowerCase();
						sr_hotels_mass[jr[3]][number][6] =  jr[10];
						sr_hotels_mass[jr[3]][number][7] =  jr[12];
						sr_hotels_mass[jr[3]][number][8] =  jr[14];
					}
					else{
						sr_hotels_mass[jr[3]] = new Array();
						var number = sr_hotels_mass[jr[3]].length;
						sr_hotels_mass[jr[3]][number] = new Array();
						sr_hotels_mass[jr[3]][number][0] = jr[29];
						sr_hotels_mass[jr[3]][number][1] = jr[7].toLowerCase();
						sr_hotels_mass[jr[3]][number][2] =  $('#country li[name='+countryId_number+']').text();
						sr_hotels_mass[jr[3]][number][3] =  $('#curorts input[name='+jr[5]+']').parent().find('a').text();
						sr_hotels_mass[jr[3]][number][4] =  thousands_sep(''+jr[15].replace(/\D/g,'')+'', ' ');
						sr_hotels_mass[jr[3]][number][5] =  jr[9].toLowerCase();
						sr_hotels_mass[jr[3]][number][6] =  jr[10];
						sr_hotels_mass[jr[3]][number][7] =  jr[12];
						sr_hotels_mass[jr[3]][number][8] =  jr[14];
						sr_hotels_mass[jr[3]][number][9] =  jr[8].replace(/\*/g,'');
					}
				
				/*
				for (j=0; j<jr.length; j++){
				html = html+'<td>'+jr[j]+'</td>';
				}
				*/
				
				//html = html+'</tr>';
			}
			var n = 0;
			for (var key in sr_hotels_mass) {
				if (n == 0){}
				else{
					html = html+'<div class="spec_predl_separator_h"></div>';
				}
				var val = sr_hotels_mass[key];
				html = html+'<div class="sr_element" id="hotel_'+key+'">';
				if (val[0][0] == ''){
					val[0][0] = 'images/sr_no_foto.png';
				}
				else{}
				html = html+'<div class="sr_element_foto"><div class="sr_element_foto_img" style="background: url('+val[0][0]+') no-repeat 0 0;"><div class="sr_element_foto_img_border"></div></div></div>';
				html = html+'<div class="sr_element_info">';
				html = html+'<div class="sr_element_info_header">'+val[0][1]+'<span class="sr_element_info_header_country">'+val[0][2]+', '+val[0][3]+'</span><div class="stars"><ul>';
				for (j=0; j<5; j++){
					if (j<val[0][9]){
						html = html+'<li class="active_star"></li>';
					}
					else{
						html = html+'<li></li>';
					}
				}
				html = html+'</ul><div class="clear"></div></div></div>';
				html = html+'<div class="sr_element_info_price"><span class="price_big">'+val[0][4]+' р.</span><br /><input class="zakazat_button" type="button" value="заказать" /></div><div class="clear"></div>';
				html = html+'<div class="sr_element_info_variants"><table class="sr_variants_table" border="0" cellpadding="0" cellspacing="0">';
				html = html+'<tr class="sr_variants_table_header"><td class="sr_width_30px"></td><td class="sr_align_left">Тип комнаты</td><td>Питание</td><td>Вылет</td><td>Ночей</td><td>Цена</td></tr>';
				for (i=0; i<val.length; i++){
					html = html+'<tr><td class="sr_width_30px">';
					if (i == 0){
						html = html+'<input id="radio_'+key+'_'+i+'" name="hotels_radio_'+key+'" type="radio" checked="checked">';
					}
					else{
						html = html+'<input id="radio_'+key+'_'+i+'" name="hotels_radio_'+key+'" type="radio">';
					}
					html = html+'</td><td class="hotel_name sr_align_left">'+val[i][5]+'</td><td class="hotel_meal">'+val[i][6]+'</td><td class="hotel_dateFrom">'+val[i][7]+'</td><td class="hotel_nights">'+val[i][8]+'</td><td class="price_small">'+val[i][4]+' р.</td></tr>';
				}
				html = html+'</table></div>';
				html = html+'</div><div class="clear"></div></div>';
				n++;
			}
			//alert (sr_hotels_mass.length);
			//html = html+'</table>';
			$('#aboute').css('display', 'none');
			$('#search_result').css('display', 'block');
			$('#search_result_text').html(html);
			//print_r(sr_hotels_mass);
			window.location.hash = url_hash;
			$('#podbor_tura_button_preloader').css('display', 'none');
			$('#podbor_tura_button').css('display', 'block');
			
			$('input[type=radio]').click(function(){
				$(this).parents('.sr_element_info').find('.price_big').text($(this).parents('tr').find('.price_small').text());
			});
			//alert (html);
			//add_hotel();
			//alert ($('#hotels li').length);
			
		}
	});
	
}
/*
function get_meals(){
	$.ajax({
		beforeSend: function(){},
		//data: (url),
		//type: "get",
		url: "http://module.sletat.ru/Main.svc/GetMeals",
		dataType : "jsonp",
		success: function(data){
			var html = '';
			//$('#curorts span').text('Все курорты');
			//html = html+'<a href="javascript: void(0)" onclick="$(\'#curorts li input\').attr(\'checked\', false); add_curort()">Очистить</a>';
			for (i=0; i<data.GetMealsResult.Data.length; i++){
				var jr = data.GetMealsResult.Data[i];
				if (i == 0){
					$('#meals span').attr('name', jr.Id).text(jr.Name);
				}
				else{}
				html = html+'<li name='+jr.Id+'>'+jr.Name+'</li>';
			}
			$('#meals ul').html(html);
		}
	});
}
*/
//-----------------------------GET END---------------------------//
//-------------------Индивидуальные функции старт----------------//
function add_curort(new_w){
var col = $('#curorts input:checked').length;
if (col == 0){
	$('#curorts span').text('Все курорты');
}
else{
	$('#curorts span').text('Выбрано: '+col);
}
if (new_w == 1){
get_hotels(1);
}
else{
get_hotels();
}
//alert (col);
}
function add_hotel(){
$('#hotels_add').html($('#hotels').html());
$('#hotels_add li').css('display', 'none');
$('#hotels_add li img').attr('src', 'images/hotels_minus.png');
//var li_all_hotel = '<li name="all_hotels" value="all_hotels" class="hotels" style="background-color: transparent; color: #AAA;"><input type="checkbox" value="all_hotels" checked="checked" disabled="disabled">Выбраны все отели</li>';
/*
$('.hotels').mouseenter(function(){
	$(this).css('backgroundColor', '#ddf2fe');
}).mouseleave(function() {
	$(this).css('backgroundColor', 'transparent');
})
*/;
$('#hotels li').click(function(){
	$(this).css('display', 'none');
	$(this).addClass('not_search');
	$('#hotels_add li[name='+$(this).attr('name')+']').css('display', 'block');
	//$('#hotels_add li[name='+$(this).attr('name')+'] img').attr('src', 'images/hotels_minus.png');
	//$('#hotels_add li[value='+$(this).attr('value')+'] input').attr('checked', 'checked');
	
	if ($('#hotels_add li:visible').length == 0){
		$('#check_all_hotels input').attr('checked', true).attr('disabled', true);
	}
	else{
		$('#check_all_hotels input').attr('checked', false).attr('disabled', false);
	}
	
});
$('#hotels_add li').click(function(){
	$(this).css('display', 'none');
	//$('#hotels li[value='+$(this).attr('value')+'] input').removeAttr('checked');
	//str = new RegExp('^.*'+$('#search_hotels').attr('value')+'.*$', 'i');
	if (str.test($('#hotels li[name='+$(this).attr('name')+']').text())){
		$('#hotels li[name='+$(this).attr('name')+']').css('display', 'block');
	}
	else{}
	$('#hotels li[name='+$(this).attr('name')+']').removeClass('not_search');
	
	//$('#hotels_add li[value='+$(this).attr('value')+'] input').removeAttr('checked');
	
	if ($('#hotels_add li:visible').length == 0){
		$('#check_all_hotels input').attr('checked', true).attr('disabled', true);
	}
	else{
		$('#check_all_hotels input').attr('checked', false).attr('disabled', false);
	}
	
	//search_hotels();
});
/*
if ($('#hotels_add li:visible').length == 0){
	$(li_all_hotel).appendTo('#hotels_add');
}
else{
	$('#hotels_add li[value=all_hotels]').remove();
}
*/
$('#check_all_hotels input').click(function(){
	if ($('#check_all_hotels input:checked').length == 1){
		//alert ('1');
		$.each($('#hotels_add li:visible'), function(){
			$(this).css('display', 'none');
			if (str.test($('#hotels li[name='+$(this).attr('name')+']').text())){
				$('#hotels li[name='+$(this).attr('name')+']').css('display', 'block');
			}
			else{}
			$('#hotels li[value='+$(this).attr('value')+']').removeClass('not_search');
		});
		$('#check_all_hotels input').attr('checked', true).attr('disabled', true);
	}
	else{
		//alert ('0');
		//$('#check_all_hotels input').attr('checked', true).attr('disabled', true);
	}
});
}
var str = new RegExp();
function search_hotels(){
		str = new RegExp('^.*'+$('#search_hotels').attr('value')+'.*$', 'i');
		var search_hotels = $('#hotels li:not(.not_search)');
		search_hotels.css('display', 'none');
		var hotel_name = '';
		for (i=0; i<search_hotels.length; i++){
			hotel_name = search_hotels.eq(i).text();
			if (str.test(hotel_name)){
				//alert (hotel_name);
				search_hotels.eq(i).css('display', 'block');
			}
			else{}
		}
}
//-------------------Индивидуальные функции стоп----------------//
//-----------------------------SET START---------------------------//
function set_podbor_form(){
		if (window.get['countryId']){
			$('#country span').attr('name', get['countryId']).text($('#country li[name='+get['countryId']+']').text());
		}
		else{}
		
		if (window.get['cityFromId']){
			$('#cityFrom span').attr('name', get['cityFromId']).text($('#cityFrom li[name='+get['cityFromId']+']').text());
		}
		else{}
		
		if (window.get['meals']){
			if (/,/.test(window.get['meals'])){
				var meals_mass = get['meals'].split(',');
				$('#meals span').attr('name', meals_mass[0]).text($('#meals li[name='+meals_mass[0]+']').text());
				$('#meals_better').attr('checked', true);
			}
			else{
				$('#meals span').attr('name', get['meals']).text($('#meals li[name='+get['meals']+']').text());
			}
		}
		else{}
		
		
		if (window.get['stars']){
			if (/,/.test(window.get['stars'])){
				var stars_mass = get['stars'].split(',');
				$('#stars li').removeClass('active_star');
				$('#stars li[name='+stars_mass[0]+']').addClass('active_star');
				$('#stars li[name='+stars_mass[0]+']').prevAll().addClass('active_star');
				$('#stars_better').attr('checked', true);
			}
			else{
				$('#stars li[name='+get['stars']+']').addClass('active_star');
				$('#stars li[name='+get['stars']+']').prevAll().addClass('active_star');
			}
		}
		else{}
		
		if (window.get['s_adults']){
			var left = $('#adults li[name='+get['s_adults']+']').index() * 27;
			$('#adults div').text('');
			$('#adults div').css({
				left: left+'px'
			});
			$('#adults div').text(get['s_adults']);
			
		}
		if (window.get['s_kids']){
			var left = $('#kids li[name='+get['s_kids']+']').index() * 27;
			$('#kids div').text('');
			$('#kids div').css({
				left: left+'px'
			});
			$('#kids div').text(get['s_kids']);
			
		}
		if (window.get['s_nightsMin']){
			$('#nightsMin span').attr('name', get['s_nightsMin']).text($('#nightsMin li[name='+get['s_nightsMin']+']').text());
		}
		else{}
		if (window.get['s_nightsMax']){
			$('#nightsMax span').attr('name', get['s_nightsMax']).text($('#nightsMax li[name='+get['s_nightsMax']+']').text());
		}
		else{}
		
		//%2F
		if (window.get['s_departFrom'] && window.get['s_departTo']){
			departFrom_date = new Date($.datepicker.formatDate('mm/dd/yy', $.datepicker.parseDate('dd/mm/yy', get['s_departFrom'])));
			departTo_date = new Date($.datepicker.formatDate('mm/dd/yy', $.datepicker.parseDate('dd/mm/yy', get['s_departTo'])));
			var days = ((departTo_date - departFrom_date) / 1000 / 60 / 60 / 24) / 2;
			
			$('#date_plus span').attr('name', days).text($('#date_plus li[name='+days+']').text());
			departFrom_date.setDate(departFrom_date.getDate() + days);
			var date = addZero(departFrom_date.getDate())+'/'+addZero(departFrom_date.getMonth()+1)+'/'+departFrom_date.getFullYear();
			date = $.datepicker.formatDate('dd MM yy', $.datepicker.parseDate('dd/mm/yy', date));
			$('#date').attr('value', date);
			
		}
}
function set_curorts(){
	if (window.get['cities']){
		var cities_mass = get['cities'].split(',');
		for (i=0; i<cities_mass.length; i++){
			$('#curorts input[name='+cities_mass[i]+']').attr('checked', true);
		}
	}	
}
function set_hotels(){
	if (window.get['hotels']){
		var hotels_mass = get['hotels'].split(',');
		for (i=0; i<hotels_mass.length; i++){
			$('#hotels li[name='+hotels_mass[i]+']').css('display', 'none');
			$('#hotels li[name='+hotels_mass[i]+']').addClass('not_search');
			$('#hotels_add li[name='+hotels_mass[i]+']').css('display', 'block');
			
			if ($('#hotels_add li:visible').length == 0){
				$('#check_all_hotels input').attr('checked', true).attr('disabled', true);
			}
			else{
				$('#check_all_hotels input').attr('checked', false).attr('disabled', false);
			}
		}
	}
}
//-----------------------------SET STOP---------------------------//


function addZero(i) {
return (i < 10)? "0" + i: i;
}
get = new Array;;
function get_get(){
	if (window.location.hash != '' &&  window.location.hash != '#' && /=/.test(window.location.hash)){
		var get_mass = window.location.hash.replace('#', '');
		get_mass = get_mass.split('&');
		for (i=0; i<get_mass.length; i++){
			name = get_mass[i].replace(/\=.+/, '');
			value = get_mass[i].replace(/.+\=/, '');
			get[name] = value;
			//alert (name+':'+get[name]);
		}
	}
	else{}
}

function thousands_sep(_num, _sep){
    if (_num.length <= 3) return _num;
    var _count = _num.length;
    var _num_parser = '';
    var _count_digits = 0;
    for (var _p = (_count - 1); _p >= 0; _p--){
      var _num_digit = _num.substr(_p, 1);
      if (_count_digits % 3 == 0 && _count_digits != 0 && !isNaN(parseFloat(_num_digit))) _num_parser = _sep + _num_parser;
      _num_parser = _num_digit + _num_parser;
      _count_digits++;
      }
    return _num_parser;
  }
///////////////////////////////---podbor_tura.html end---////////////////////////////////////

///////////////////////////////---spec_predl.html start---////////////////////////////////////
function select_spec_predl(){
	$.ajax({
		beforeSend: function(){
			$('#spec_predl_content').html('');
		},
		//data: (url),
		type: "get",
		url: "php/select_spec_predl.php",
		dataType : "html",
		success: function(data){
			//alert (data);
			$('#spec_predl_content').html(data);
		}
	});
}


/*
$(document).ready(function(){
$('<style>#print_r_div ul{ list-style: disc inside none; margin: 0; padding: 10px; }</style>').appendTo('body');
$('<div id="print_r_div"></div>').appendTo('body');
});
function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}
*/
///////////////////////////////---spec_predl.html end---////////////////////////////////////
