		$(document).ready(function () {
			$('.mover')
				.mouseover(function() {
					$(this).find("img").attr("src", $(this).find("img").attr("src").match(/[^\.]+/) + "a.gif");
				})
				.mouseout(function() {
					$(this).find("img").attr("src", $(this).find("img").attr("src").replace("a", ""));
				});

			$('.bordered')
				.click(function() {
					var element="#s"+$(this).attr('id').substr(1,1);
					$(this).css("border-color","#222");
					$(element).find("img").attr("src", $(element).find("img").attr("src").replace("a", ""));
				})
				.mouseover(function() {
					var element="#s"+$(this).attr('id').substr(1,1);
					$(this).css("border-color","#fff");
					$(element).find("img").attr("src", $(element).find("img").attr("src").match(/[^\.]+/) + "a.gif");
				})
				.mouseout(function() {
					var element="#s"+$(this).attr('id').substr(1,1);
					$(this).css("border-color","#222");
					$(element).find("img").attr("src", $(element).find("img").attr("src").replace("a", ""));
				});
				
			$('.signature a')
				.click(function() {
					$("#b"+$(this).attr('id').substr(1,1)).css("border-color","#222");
					$(this).find("img").attr("src", $(this).find("img").attr("src").replace("a", ""));
				})
				.mouseover(function() {
					$("#b"+$(this).attr('id').substr(1,1)).css("border-color","#fff");
					$(this).find("img").attr("src", $(this).find("img").attr("src").match(/[^\.]+/) + "a.gif");
				})
				.mouseout(function() {
					$("#b"+$(this).attr('id').substr(1,1)).css("border-color","#222");
					$(this).find("img").attr("src", $(this).find("img").attr("src").replace("a", ""));
				});
				
			$('.change_img a')
				.click(function() {
					var new_src=$("#normal").find("img").attr("src").match(/[^\.]+/).toString();
					new_src=new_src.substr(0,new_src.length-1)+$(this).attr('rel')+".jpg";
					var old_active=$("#normal").find("img").attr("src").toString();
					old_active=old_active.substr(old_active.length-5,1);
					$("#normal").find("img").attr("src", new_src);
					$(this).attr("class", "bordered-active");
					$("#sm"+old_active).attr("class", "bordered_2");
					$("#normal").attr("href", new_src.replace("normal", "large"));
					return false;
				});
				
			$("#show_map_btn")
				.click(function() {
					var old_class=$("#map_display").attr("class");
					if(old_class=="hide") $("#map_display").attr("class","show");
					else $("#map_display").attr("class","hide");
					return false;
				});
				
			$("a#price_c")
				.fancybox({
					'titlePosition'	: 'inside'
				});
			$("a#price_g")
				.fancybox({
					'titlePosition'	: 'inside'
				});
				
			$("#show_map")
				.click(function() {
					var image_map=$(this).find("img").attr("src").replace("gif", "jpg");
					width=420;
					height=700;
					var nw_map=0;
					nw_map = window.open(
						image_map.replace("small_", ""),
						'map_big',
						'width='+width+',height='+height+',toolbar=no,location=0,directories=0,menubar=0,scrollbars=no,resizable=0,fullscreen=0,status=0'
					);
					nw_map.focus()
					return false;
				});
				
			$("#show_res_btn")
				.click(function() {
					var old_class=$("#reserve_display").attr("class");
					if(old_class=="hide") $("#reserve_display").attr("class","show");
					else $("#reserve_display").attr("class","hide");
					return false;
				});
			
			$("#ind_a")
				.click(function() {
					width=420;
					height=700;
					var nw_ind=0;
					nw_ind = window.open(
						$(this).attr("href"),
						'individual',
						'width='+width+',height='+height+',toolbar=no,location=0,directories=0,menubar=0,scrollbars=no,resizable=0,fullscreen=0,status=0'
					);
					nw_ind.focus()
					return false;
				});
				
			$("#group_a")
				.click(function() {
					width=820;
					height=700;
					var nw_group=0;
					nw_group = window.open(
						$(this).attr("href"),
						'individual',
						'width='+width+',height='+height+',toolbar=no,location=0,directories=0,menubar=0,scrollbars=no,resizable=0,fullscreen=0,status=0'
					);
					nw_group.focus()
					return false;
				});
				
			$("#banner_outer")
				.click(function() {
					width=820;
					height=700;
					var news_banner=0;
					news_banner = window.open(
						"/rus/news/3/",
						'news_banner',
						'width='+width+',height='+height+',toolbar=no,location=0,directories=0,menubar=0,scrollbars=yes,resizable=0,fullscreen=0,status=0'
					);
					news_banner.focus()
					return false;
				});
				
			$("#count")
				.change(function () {
					var count=$(".cuselText").html();
					var i=0;
					for(i=1;i<=count;++i){
						$("#num"+i).css("display", "block");
					}
					for(;i<=5;++i){
						$("#num"+i).css("display", "none");
					}
				});
		
			
			
				$('#show_booking')
					.click(function(e) {	
						e.preventDefault();
						var id = $(this).attr('rel');
								
						var maskHeight = $(document).height();
						var maskWidth = $(window).width();
								
						$('#mask').css({'width':maskWidth,'height':maskHeight});
						$('#mask').fadeTo("slow",0.3);	
								
						var winH = $(window).height();
						var winW = $(window).width();

						$("#dialog").css('top',  winH/2-660/2);
						//$("#dialog").css('left', winW/2-643/2);
						$("#dialog").fadeIn(2000); 
						
						return false;
					});
						
				$('#mask')
					.click(function () {
						$("#success").css("display","none");
						$("#booking").css("display","block");
						
						var top_fields=["#org","#email","#code","#phone", "#fio1","#in1","#out1", "#fio2","#in2","#out2", "#fio3","#in3","#out3", "#fio4","#in4","#out4", "#fio5","#in5","#out5"];
						for(var key in top_fields) {
							$(top_fields[key]).val("");
						}
						
						$(this).hide();
						$('.window').hide();
					});	
						
				$('.window .close')
					.click(function (e) {
						$("#success").css("display","none");
						$("#booking").css("display","block");
						
						var top_fields=["#org","#email","#code","#phone", "#fio1","#in1","#out1", "#fio2","#in2","#out2", "#fio3","#in3","#out3", "#fio4","#in4","#out4", "#fio5","#in5","#out5"];
						for(var key in top_fields) {
							$(top_fields[key]).val("");
						}
					
						e.preventDefault();
						$('#mask, .window').hide();
					});
					
					
				$('#show_banner')
					.click(function(e) {	
						e.preventDefault();
								
						var maskHeight = $(document).height();
						var maskWidth = $(window).width();
								
						$('#mask2').css({'width':maskWidth,'height':maskHeight});
						$('#mask2').fadeTo("slow",0.3);	
								
						var winH = $(window).height();
						var winW = $(window).width();

						$("#dialog2").css('top',  winH/2-400/2);
						$("#dialog2").fadeIn(2000); 
						
						return false;
					});
						
				$('#mask2')
					.click(function () {				
						$(this).hide();
						$('.window2').hide();
					});	
						
				$('.window2 .close2')
					.click(function (e) {					
						e.preventDefault();
						$('#mask2, .window2').hide();
					});			
		});
