$(function () {

	// исчезание текста в полях ввода
	$(':text, :password, textarea').one('focus', function () {
		$(this).val('');
	});
/*
	// всплывающее окно
	var myImg = $('#folioImg');
	var myImg_src;
	var myA= $('#folioA');
	var myA_href;
	var currentIndex;
	
	$('.portfolioGallery a').click(function () {
		return false;
	});		
	$('.portfolioGallery img').click(function () {
		$('#all').css( 'position', 'fixed').css('width', '100%');
		myImg_src = $(this).attr('alt');
		myA_href = $(this).parent('a').attr('href');
		currentIndex = $(this).parents('li').index();
		$('.folioPopUp').folioGallery();
		$('.folioPopUp').show();//.css({ opacity: 0 }).animate({ opacity: 1 }, 500);
	});	
	
	// ГАЛЕРЕЯ РАБОТ В ПОРТФОЛИО 
	$.fn.folioGallery = function ()
	{
			// устанавливаем максимальную ширину изображения
			var maxImgWidth = 900;
			// сохраняем ссылку на галерею в переменную
			var galleryBody = $('.folioPopUp').find('.window');

			// замена изображений и создание окна просмотра
			function getNewFolioPhoto()
			{
				// начальная ширина изображения
				var imgWidth;
				// дожидаемся загрузки изображения
				myImg.attr('src', myImg_src);
				myA.attr('href', myA_href);
				myImg.load(function () {
					imgWidth = $(this).width();
					// если изображение слишком велико...
					if ( imgWidth > maxImgWidth ){
						imgWidth=maxImgWidth;
						myImg.width(imgWidth);
					}
					//устанавливаем ширину окна
					galleryBody.width(imgWidth);
					// устанавливаем высоту для ссылок "влево/вправо"
					var arrowsHeight = galleryBody.innerHeight()-60;
					galleryBody.find('.arrowLeft, .arrowRight').height(arrowsHeight);
					//устанавливаем ширину на полкартинки
					galleryBody.find('.arrowLeft, .arrowRight').width(imgWidth/2);
					galleryBody.animate({ opacity: 1 }, 200);
				});
			}; getNewFolioPhoto();


			// степень прозрачности стрелок "влево/вправо", анимация при наведении
			galleryBody.find('.arrowLeft, .arrowRight').css({ opacity: 0.1 });
			galleryBody.find('.arrowLeft, .arrowRight').hover(
				function () {
					if ( !$(this).is(':animated') )
						$(this).animate({ opacity: 1 }, 200);
				},
				function () {
					$(this).stop().animate({ opacity: 0.1 }, 200);
				}
			);


			// листаем картинки
			galleryBody.find('a.arrowLeft, a.arrowRight').click(function () {
				var nextIndex;
				if ( $(this).hasClass('arrowLeft') ) { // влево
					if (currentIndex > 0) nextIndex = currentIndex - 1;
					else nextIndex = $('.portfolioGallery').find('li').length - 1;
				}
				else { // вправо
					if (currentIndex < $('.portfolioGallery').find('li').length - 1) nextIndex = currentIndex + 1;
					else nextIndex = 0;
				}

					// определяем src следующего рисунка и меняем URL
					myImg_src = $('.portfolioGallery').find('li').eq(nextIndex).find('img').attr('alt');
					myImg.attr('src', myImg_src);
					myA_href = $('.portfolioGallery').find('li').eq(nextIndex).find('a').attr('href');
					myA.attr('href', myA_href);
					currentIndex=nextIndex;
					return false;				


			});


			// закрываем окно
			galleryBody.find('a.close').click(function () {
				$('#all').css( 'position', 'static');
				$('.folioPopUp').hide();
				return false;
			});
			$(document).keyup(function(e) {
				if (e.keyCode == 27) {
					galleryBody.find('a.close').trigger('click');
				}
			});


	} // folioGallery end
	
	// закрываем по клику на любом месте страницы
	$('body').click(function (event) {
		if ( $(event.target).parents().is('.folioPopUp') ){
			$('.folioPopUp').hide();
		}
	});
*/
	
	

	
	// пункты главного меню
	var positionBgrDefault;
	arr=$('.sideCol .menu').find('a');
    jQuery.each(arr, function() {
		url2=$(this).find('span').attr('id');
		url2=url2.substring(5);
		positionBgrDefault='0 0';
		charone=url2.substring(url2.length-2);
		
		if(charone=='_S'){
			positionBgrDefault='0 -48px';
			url2=url2.substring(0, url2.length-2);
		}

		$(this).find('span').css('background-position', positionBgrDefault);
		$(this).find('span').css('background-image', 'url(/UserFiles/menu/menuMain_'+url2+'.png)');
    });	
	
	$('.sideCol .menu a').mouseover(function(){ 
		positionBgrDefault=$(this).find('span').css('background-position');
		$(this).find('span').css('background-position', '0 -24px');
    });
	$('.sideCol .menu a').mouseout(function(){ 
		$(this).find('span').css('background-position', positionBgrDefault);
    });
	
	//пункты меню на плашках
	arr=$('.sideCol .nav').find('a');
    jQuery.each(arr, function() {
		url2=$(this).find('span span').attr('id');
		url2=url2.substring(5);
		$(this).find('span span').css('background-image', 'url(/UserFiles/menu/menu_'+url2+'.png)');
    });	

	// так можно настроить галерею для всех браузеров, исключая IE6
	$.Lightbox.construct({
		show_linkback: false,
		show_helper_text: false,
		show_info: true,
		show_extended_info: true,
		download_link: false,
		auto_resize: false,
		opacity: 0.7,
		text: {
			image: 'Фото',
			of: 'из',
			close: 'Закрыть',
			download: 'Загрузить'
		}
	});	
	
});


