// Функция сворачивания / разворачивания списка популярных курортов в меню

function show_cities_block (type)
{
	if (type == 'all')
	{
		$(".not_popular_cities").show ();
		$("#show_popular_cities").show();
		$("#show_all_cities").hide();
	}
	else
	{
		$(".not_popular_cities").hide ();
		$("#show_popular_cities").hide();
		$("#show_all_cities").show();
	}	
}

// показать / скрыть слой
function showWin(win) {
	var win = document.getElementById(win);
	
	if(win.style.display == "none") {
		win.style.display = "block";
	} else {
		win.style.display = "none"
	}
}

var cssFix = function(){
	var u = navigator.userAgent.toLowerCase(),
	is = function(t){return (u.indexOf(t)!=-1)};
	$("html").addClass([
		(!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
		:is('firefox/2')?'gecko ff2'
		:is('firefox/3')?'gecko ff3'
		:is('gecko/')?'gecko'
		:is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
		:is('konqueror')?'konqueror'
		:is('applewebkit/')?'webkit safari'
		:is('mozilla/')?'gecko':'',
		(is('x11')||is('linux'))?' linux'
		:is('mac')?' mac'
		:is('win')?' win':''
		].join(''));
}();

function show_hotel_photo(id, num, title)
{
	$('#photo').remove ();
	if (!isNaN (num))
		$('#hotel_photo').prepend ('<img src="/hotels/hotelimg2.php?id=' + id + '&num=' + num + '" width="320" border="0" id="photo" alt="' + title + '" title="' + title + '" style="display:none;">');
	else
		$('#hotel_photo').prepend ('<img src="' + num + '" border="0" id="photo" alt="' + title + '" title="' + title + '" style="display:none;">');
	$('#photo').fadeIn(500);
}	

function add_comment_rate (id, type)
{
	$.post ('/hotels/setrate.php', {id: id, type: type}, function (data)
	{	
		if (data != '')
		{
			$.cookie ('acr', data, {expires: 365*7, path: '/', domain: 'ayda.ru', secure: false});
			var a = $('#acr_' + type).html();
			$('#acr_' + type).html(parseInt($('#acr_' + type).html()) + 1);
		}
	});
}

function add_story_rate (id, type)
{
	$.post ('/stories/setrate.php', {id: id, type: type}, function (data)
	{	
		if (data != '')
		{
			$.cookie ('asr', data, {expires: 365*7, path: '/', domain: 'ayda.ru', secure: false});
			var a = $('#asr_' + type).html();
			$('#asr_' + type).html(parseInt($('#asr_' + type).html()) + 1);
		}
	});
}


