
	pngFix_msie = false;

	function resize_gal(){
		
		var img = $("#image img").css({width: "auto", height: "auto"});
		
		
		var dst = {
			w: $(document).width(), 
			h: $(document).height()
		}
/*		if (img.width() >= img.height()) {
			var s = img.width() / img.height();
			
			var width = (dst.w / s > dst.h) ? dst.w : dst.h * s; // при пересчете с аспектом полученная высота будет больше имеющейся
			var height = width / s;
			
			
		} else {
	*/		
			var s = img.width() / img.height();
			
			var width = dst.h * s;
			var height = width / s;
			
//		}

			var margin = {
				w: ((dst.w - width) / 2),
				h: ((dst.h - height) / 2)
			}


		if(width && height)
			img.css({
				'width': width,
				'height': height
			});

		if(margin.w || margin.h)
			img.css({
				'margin-top': margin.h + "px",
				'margin-bottom': margin.h + "px",
				'margin-left': margin.w + "px",
				'margin-right': margin.w + "px"
			});


			
			$('#spinner').hide();
  }

$(document).ready(function(){
	
	/* init */
	
	$.scrollTo.defaults.axis = 'xy';
	$('#thumbs').scrollTo(0);
	$.scrollTo(0);
	
	
	if($('html').hasClass('opera')){
		
		$('#scroll').mouseover(function(){
			$(this).trigger('focus');
		});
		
	}
	
	/* end of init */

	/* gallery */

	$('#thumbs a').hover(
		function(e){
			
			$(this).children('img').css({'display': 'none'});
			
			if (e.clientX < $(window).width() * (1/3)) {
				
				$('#thumbs').stop().scrollTo('-=75px', 1000, {axis:'x'});
				
			} else if (e.clientX > $(window).width() * (2/3)) { // right
				
				$('#thumbs').stop().scrollTo('+=75px', 1000, {axis:'x'});
				
			}
			
		},
		function(){
			
			if(!$(this).hasClass('act')) $(this).children('img').css({'display': 'block'});
			
			$('#thumbs').stop();
			
		}
	);
	
	
	
	$('#thumbs a')
		.nyroModal({
			endRemove: function(){$('#thumbs a').removeClass('act').children('img').css({'display':'block'});}
		})
		.click(function(){
		
			$('#thumbs a').removeClass('act').children('img').css({'display':'block'});
			$(this).addClass('act').children('img').css({'display':'none'});
			
			return false;
		
		});
	
	
	/* end of gallery */
	

	/* menu */

	$('#menu ul li a').hover(function(){
		if(!$(this).hasClass('act')){
		
			var color = $(this).attr('class').split(' ')[0];
			if(color)
				color = color.split('_')[1];
	
			if(color)
				$(this).css({'background-color':'#'+color, 'color':'#ffffff'});
	
		}
	},function(){
			
		if(!$(this).hasClass('act'))
			$(this).css({'background':'none', 'color':'#807C8F'});
			
	});

	/* end of menu */


  $('a.feedback_spb, a.feedback_msk').click(function(e){
		e.preventDefault();
		var city = $(this).attr('class').split('_')[1];
		if(city){
			
			$.get("/pages/form_"+city+".php", function(data){
					
		    $(data).modal({
					closeHTML: "<a href='#'>Закрыть</a>",
					overlayClose: true,
					overlayId: 'simplemodal-overlay',
					escClose: true,
					containerId: 'simplemodal-container'
				});
	
	
			});
			
		}
		return false;
	});


});
