﻿function BuildPage() {
//	Убираем верхний разделитель и нижний падинг в вевом меню, последний бордер в правом блоке
	$('#left-menu > ul > li:first').css('background','none');
	$('#left-menu > ul > li:last > a').css('padding-bottom','0');
	if ($('#BestDeals')) {
		$('#BestDeals > .block:first').css('border-top','none');
		$('#BestDeals > .block:last > .price').css('padding-bottom','0');
	};
	//Ставим отступы вокруг картинок в контенте
	if ($('#content-block').find('img')) {
		$('#content-block').find('img').each(function(i){
			if ($(this).attr('align')=='left') {$(this).css('margin-left','0px')};
			if ($(this).attr('align')=='right') {$(this).css('margin-right','0px')};
		});
	};
//	Запускаем галерею
	if ($('.fhoto-gallery').length>0) {
		MakeGallery();
		$('.fhoto-gallery a').overlay({
			target: '#gallery',
			expose: '#f1f1f1'
		}).gallery({
			speed: 300,
			template: '<strong>${title}</strong> <span>Фотография ${index} из ${total}</span>'
		});
	};

	//Из-за ie6 перерисовываем футер 
	$('#footer').css('display','none');
	$('#footer').css('display','block');
};

function MakeGallery() {
	if ($('.fhoto-gallery').length>0)
		var Wgal=$('.fhoto-gallery').width(),
			Wphoto=171,
			ElCounts=Math.floor(Wgal/Wphoto),
			Mar=Math.floor((Wgal-Wphoto*ElCounts)/ElCounts*0.5)+5;
		if ($.browser.msie && $.browser.version > 6 || !$.browser.msie) {
			$('.fhoto-gallery a').css('margin','0 '+Mar+'px 10px '+Mar+'px');
		};
};
//Запуск функций построения страницы
$(document).ready(function(){BuildPage();});
$(window).resize(function(){MakeGallery();});

