	
	
	 function footer_bottom(content_block, hightstat){//footer bottom
		 var content_height = $(content_block).height();
		 var widows_height = $(window).height();
		 var razn = widows_height - content_height - hightstat;		 
		 if (razn > 0) {
			 	razn = razn+'px';
			 	$(content_block).css('margin-bottom',razn)
		}		 
	}
	
	
	function imgHeightCenter(container, wrapper, fromHeight){			
			wrapper_height = container.parents(wrapper).height();
			img_height = container.height(); 			
			razn = Math.ceil((wrapper_height -img_height )/2) - fromHeight;	
			if (razn >= 0) {container.css('margin-top',razn+'px')};			
		}
		
	function imgWidhtCenter(container, wrapper, fromWidth){			
			wrapper_width = container.parents(wrapper).width();			
			img_width = container.width(); 				
			razn = Math.ceil((wrapper_width - img_width )/2) - fromWidth;			
			if (razn >= 0) {container.css('margin-right',razn+'px')};			
		}
		 
		 

$(document).ready(function(){
	footer_bottom('.content', 510);
	
	//menu hover
	$('.menu li').hover(function(){				
				$(this).attr('simplimg', $(this).find('img').attr('src'));
				$(this).find('img').attr('src', $(this).attr('imghover'));
			}, function(){				
				$(this).find('img').attr('src', $(this).attr('simplimg'));
			}
	)
	
	
	//блоки на первой странице одинаковой высоты
	if ($('.blocks_wrapper').length > 0) {
		max_height = 0;
		$('.blocks_wrapper .block').each(function(){
				tek_height = $(this).height();
				if (tek_height > max_height) {max_height = tek_height; }
		})
		$('.blocks_wrapper .block').each(function(){ 
			tek_height = $(this).height();
			margin =  (max_height - tek_height);
			$(this).find('.block_end').css('margin-top', margin + 'px' );
		})		
	}
	
	
	$('.img_wrapper img').each(function(){imgHeightCenter($(this), '.img_wrapper', 1)});
	$('.img_wrapper img').each(function(){imgWidhtCenter($(this), '.img_wrapper', 1)});
	
	
	if ($('.pages').length > 0 ) {
		width_parents = $('.pages').parent().width();
		el_width = $('.pages').width();
		raz = Math.ceil((width_parents - el_width )/2);
		if (raz > 0) {$('.pages').css('margin-left', raz + 'px');}
	};
	
	
	//форма contacts, исчезновение легенды при клике
	$('.contact input').click(function(){
		tek_value = $(this).attr('value');
		tek_rel = $(this).attr('text');		
		if (tek_value == tek_rel) {
			$(this).attr('value','');
			$(this).css({'font-style':'normal', 'color': '#000'})
			}			
	})
	$('.contact input').blur(function(){
		tek_value = $(this).attr('value');
		tek_rel = $(this).attr('text');		
		if (tek_value == '') {
			$(this).attr('value',tek_rel);
			$(this).css({'font-style':'italic', 'color': '#7f7f7f'})			
			}						   
	})
	$('.contact textarea').click(function(){
		tek_value = $(this).html();
		tek_rel = $(this).attr('text');		
		if (tek_value == tek_rel) {
			$(this).html('&nbsp;');
			$(this).css({'font-style':'normal', 'color': '#000'})
			}			
	})
	$('.contact textarea').blur(function(){
		tek_value = $(this).html();
		tek_rel = $(this).attr('text');	
		console.log('tek_rel = ', tek_rel);
		console.log('tek_value = ', tek_value);
		if ((tek_value == '&nbsp;') | (tek_value == '')) {
			$(this).html(tek_rel);
			$(this).css({'font-style':'italic', 'color': '#7f7f7f'})			
			}						   
	})
});


