$(document).ready(function(){
	
	
	// Menus
	$("ul.menu li:first-child").addClass("first");
	$("ul.menu li:last-child").addClass("last");

	// input focus function
	$('.fitem, #as-destination-city-button').focus(function() {
		$(this).addClass("fitem-focus");
	});
	$('input[type="text"], input[type="password"], select, textarea').blur(function() {
		$(this).removeClass("fitem-focus");
	});

	//search box
	$('.search-source select').selectmenu();
	
	// free for today
	$("#free-for-today").scrollable({circular: true, mousewheel: true, speed: 700}).navigator().autoscroll({
		interval: 10000
	});
	
	// form
	$('#as-destination-city').selectmenu({
			select: function(event, ui) {
				$( "#as-destination-city, .rs-destination-city input" ).val(ui.value);
			}
	});
	$('.rs-destination-city input').val($('#as-destination-city').selectmenu("value"));
	
	$("#as-arrival").datepicker({
			dateFormat: "d-m-yy",
			altField: ".rs-arrival input",
			altFormat: "d-m-yy"
	});
	
	$("#as-departure").datepicker({
			dateFormat: "d-m-yy",
			altField: ".rs-departure input",
			altFormat: "d-m-yy"
	});
	
	
	$( "#as-sleeps-slider" ).slider({
			range: "min",
			min: 1,
			max: 16,
			value: 1,
			slide: function( event, ui ) {
				$( "#as-sleeps, .rs-sleeps input" ).val( ui.value );
			}
		});
		$( "#as-sleeps, .rs-sleeps input" ).val( $( "#as-sleeps-slider" ).slider( "value" ));
		
	$( "#as-rooms-slider" ).slider({
			range: "min",
			min: 1,
			max: 8,
			value: 1,
			slide: function( event, ui ) {
				$( "#as-rooms, .rs-rooms input" ).val( ui.value );
			}
		});
		$( "#as-rooms, .rs-rooms input" ).val( $( "#as-rooms-slider" ).slider( "value" ));

	$( "#as-price-slider" ).slider({
			range: true,
			min: 5,
			max: 750,
			values: [5, 300],
			slide: function( event, ui ) {
				$( "#as-price, .rs-price input" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
			}
		});
		$( "#as-price, .rs-price input" ).val( "$" + $( "#as-price-slider" ).slider( "values", 0 ) +
			" - $" + $( "#as-price-slider" ).slider( "values", 1 ) );
	
	
	// thumbs
	$("#thumbs").scrollable({
			items: "#thumbs ul",
			circular: false, 
			mousewheel: true
		}).navigator();
	
	$("a[rel=thumbs-gallery]").fancybox({
				'transitionIn' : 'none',
				'transitionOut' : 'none',
				'titlePosition' : 'over',
				'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Фото ' + (currentIndex + 1) + ' из ' + currentArray.length + (title.length ? ' &nbsp; <strong>' + title : '') + '</strong></span>';
				}
			});
	
	// reservation form
	$('#reservation-btn').click(function() {
	  //$('.reservation-form ').slideToggle(300);
	  $('.reservation-form ').slideDown(300);
	});
	
	$("#rf-arrival, #rf-departure").datepicker({dateFormat: "d-m-yy"});

	
	//icons
	$('.item-serv-ico img').css({opacity: 0.5});
	$('.item-serv-ico img').hover(function () {
		$(this).animate({opacity: 1}, 100);
	}, function() {
		$(this).animate({opacity: 0.5}, 100);
	});

	
	
});
