$(document).ready(function() {


		var dates = $( "#search_date_from_ru, #search_date_to_ru" ).datepicker({
			regional: 'ru',
			dateFormat: 'yy-mm-dd',
			numberOfMonths: 2,
			minDate: '0',
			maxDate: '+1y',
			onSelect: function( selectedDate ) {
				var option = this.id == "search_date_from_ru" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" );
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});

		var dates = $( "#search_date_from_en, #search_date_to_en" ).datepicker({
			regional: 'en',
			dateFormat: 'yy-mm-dd',
			numberOfMonths: 2,
			minDate: '0',
			maxDate: '+1y',
			onSelect: function( selectedDate ) {
				var option = this.id == "search_date_from_en" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" );
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});






	
	var winheight = $(document).height() - $("#footer").height() - 168;
	//$(".jslong").height(winheight);
	$(".jslong").css('min-height', winheight + 'px');

	hiddenImg = new Image();
	hiddenImg.src = "../img/roundbox.png";

	$("#podpis").click(function () {
		$(".podpis_form").toggle();
	});


	$(".button_all").click(function () {
		$("#all").toggle();
		$(".button_all").hide();
	});

	$(".outline2 li").click(function() {
		$(".outline2 li").removeClass("select");
		$(this).addClass("select");
		$(".outline2 .outline2-block").removeClass("show-table");
		$(".outline2 #block-" + this.id).addClass("show-table");
		return false;
	});
/*
	$('#map').imGoogleMaps({
		data_url: "/mapjsondir1.php",
		data_type: 'json',
		showtype: true,
		zoom: 'auto', // 1 - 18 or 'auto'
		map: {"width": "1000px", "height": "400px"}
	});

*/
	$(".outline li").click(function() {
		$(".outline li").removeClass("select");
		var lang = $(this).attr('rel');
		var url;

		if (lang == 'en')
		    url =  "/en/mapjson" + this.id + ".php";
		else
		    url =  "/mapjson" + this.id + ".php";

		$(this).addClass("select");
		$('#map').imGoogleMaps({
			data_url: url,
			data_type: 'json',
			showtype: true,
			zoom: 'auto', // 1 - 18 or 'auto'
			map: {"width": "1000px", "height": "400px"}
		});


		return false;
	});


	$('.cloud').mouseover(function() {
		$(this).animate({ "font-size": "+=3" }, "fast");
	});

	$('.cloud').mouseout(function() {
		$(this).animate({ "font-size": "-=3" }, "slow");
	});

	$('table.shedule-avia tr.item').hover(function() {
		$(this).addClass("hover");
	}, function() {
		$(this).removeClass("hover");
	});

	$(".shad_link").click(function() {
		$(".d-shadow", $(this).parent()).css("position", "absolute");
		$(".d-shadow", $(this).parent()).removeClass("hidden");
		return false;
	});

	$(".slide_title").click(function() {
		$(".slide_box", $(this).parent()).slideToggle(0);
		$(this).toggleClass("slide_open");
		return false;
	});


	$(".slide_title2").click(function() {
		$(".slide_box2", $(this).parent()).slideToggle(0);
		$(this).toggleClass("slide_open2");
		return false;
	});


	$(".shad_exit").click(function() {
		$(this).closest(".d-shadow").addClass("hidden");
		return false;
	});

	$('.ad-gallery').adGallery();
	$('.carousel ul').jcarousel({ scroll: 1 });
	$('.carousel2 ul').jcarousel({ scroll: 1 });
	$('.carousel3 ul').jcarousel({ scroll: 1 });
	$("a[rel='image']").colorbox();

	$("#online_tablo").click(function() {
		$("#mainmenu").find(".select").removeClass("select");
		$(this).addClass("select");
		$("#airplane_pic").removeClass("mainbox");
		if ($("#online-body").hasClass("hidden")) {
			$("#flashbody").addClass("hidden");
			$("#online-body").removeClass("hidden");
		}
		return false;
	});

	$("#online-body .direction a").live('click', function() {
		$("#online-body .shedule-avia").removeClass("show-table");
		$("#online-body #" + this.id + "-table").addClass("show-table");
		$("#online-body .direction a").removeClass("select");
		$(this).addClass("select");
	});

	$("#online-body #direction a, #online-body #flight a").live('click', function() {
		var rowId = $(this).parent().parent().attr('id');

		if (rowId == 'flight') {
			tableId = "#" + this.id + "-" + $("#online-body #direction a.select").attr('id') + "-table";
		} else {
			tableId = "#" + $("#online-body #flight a.select").attr('id') + "-" + this.id + "-table";
		}


		$("#online-body #" + rowId + " a").removeClass("select");
		$(this).addClass("select");
		$(".shedule-avia").removeClass("show-table");
		$(tableId).addClass("show-table");
	});
});



function hideLoading() {  
	if (document.getElementById('pageIsLoading')!==null) {
		document.getElementById('pageIsLoading').style. display = 'none';  
		document.getElementById('hidepic').style. display = 'block';
	}
}  


function showPic() {  
document.getElementById('hidepic').style. display = 'block';  
}  

