﻿$(document).bind("ready", function() {
			fixMinMaxwidth();			
		
			$("a.scroll").bind("click",function(){
				var id=$(this).attr("href");//.replace(/#/g, "");
				$("body").scrollTo(id,600,{axis:"y"});
				location.href="#"+$(this).attr("href").replace(/#/g, "").substr(0,$(this).attr("href").length-6);
			return false;			
			});
			
		$('#yamap').jqm();
		$('#phonebox').jqm({trigger: '.phoneModal'});
		 $.preloadCssImages();

		/*var postHeight = $("#content").height();
		var postOffset = $("#content").offset();
		var offset = $("#fsb_slider").offset();
		$(window).scroll(function() {
			if (postHeight < $(window).scrollTop()) {
			return;
		}
		if ($(window).scrollTop()+20 > offset.top) {
			$("#fsb_slider").animate({marginTop: $(window).scrollTop()-340});
		} else {
			$("#fsb_slider").animate({marginTop: 0});
		}
		});
		*/
		
		$('#menu li').mouseover(function() {
			var $this =  $(this);
			$($this).addClass('hover');	       
		
		$($this).parent().hover(function() {
        }, function(){    
			$($this).removeClass('hover');
        });	
		});			
		
		if ($.fn.lightBox) {
			var max = 1000;
			if (screen && screen.width && screen.width < 1000) max = 800;
			$('a.lightbox').lightBox({allwaysShowControls: true, maxImageWidth: max});
			}
			
		$('.accordion').prevAll('.accordion_header').click(function() {
			$($(this).nextAll('.accordion').get(0)).toggle('slow');
			return false;
		});
		$('.accordion').hide();	
		
	});
//анонимная функция для проверки всех элементов с классом .fixMinMaxwidth
var fixMinMaxwidth=function(){
   //только для браузеров без поддержки этого свойства
   if (typeof document.body.style.maxHeight !== "undefined" &&
      typeof document.body.style.minHeight !== "undefined") return false;

   	var maxWidth = parseInt($('#corper').css("max-width"));
	var minWidth = parseInt($('#wrap').css("min-width"));
   //получаем значение максимальной и минимальной ширины
	if (minWidth>0 && $('#corper').width()<minWidth) {
		$('#corper').width(minWidth);
		}
	if (minWidth>0 && $(document.body).width()>maxWidth) {
		$('#wrap').width(maxWidth);
		$('#footer').width(maxWidth);
	}
      //Выполняем,если min-/maxwidth установлены
}
 
//запускаем проверку после изменения размера окна
$(window).bind("resize", function(){
   fixMinMaxwidth();
});

