$(document).ready( function() {
		$('.catalog_menu_expander').click( function() {
			var m = $('.left_menu');
			var c_mode = m.hasClass('left_menu_item_mode') ? 'item' : 'full';
			m[0].className = 'left_menu';
			m.addClass( c_mode == 'item' ? 'left_menu_full_mode' : 'left_menu_item_mode' );
		})
		
		$('.catalog_menu .item a.item_name').click ( function() {
				var i = $(this).parents('.item').first();
				
				if ( i.find('.subitem').length == 0) {
					return true;
				}
				
				$('.left_menu .item').each( function() {
					$(this).removeClass('in_path');	
				})
				i.addClass('in_path');
				$('.left_menu').removeClass('left_menu_full_mode').addClass('left_menu_item_mode');
				return false;
		})
		
		$('.text table').each( function() {
				var ctbl = this;
				var is_char = false;
				var c = 0;
				if ($(ctbl).hasClass('special_table')) {
					return;
				}
				this.removeAttribute('width');
				$(this).css({width:'100%'});
				var rows = $(this).children('tbody').children('tr');
				if (rows.length > 4) {
					if (!is_char) {
						var has_lcol = $(ctbl).find('td.lcol').length > 0;
						if (has_lcol) {
							$(ctbl).addClass('char_table');
							is_char = true;
						}
					}
					rows.each( function() {
						c++;
						if (c > 2) {
							$(this).addClass( c % 2 == 0 ? 'row_even' : 'row_odd');
						}
						$(this).find('td').each( function() {
							this.removeAttribute('width');
							this.removeAttribute('height');
							if ( (this.hasAttribute('rowspan') && this.getAttribute('rowspan') > 1) || this.hasAttribute('bgcolor')) {
								$(this).parents('tr').first().remove();
							}
							if ($(this).hasClass('head1') || $(this).hasClass('head2')) {
								this.removeAttribute('colspan');
							}
						})
					});
				}
		})
		
		$('.text a').each( function() {
				if ($(this).find('img').length > 0) {
					var ch = $(this).html();
					var span = this.parentNode.insertBefore(
						document.createElement('span'),
						this
					);
					$(span).html(ch);
					this.parentNode.removeChild(this);
				}
		});
		
		var fsearch = $('.footer .search_w input.text')
		
		fsearch.focus( function() {
				if (this.value == 'Поиск') {
					this.value = '';
				}
		})
		
		fsearch.blur( function() {
				if (this.value == '') {
					this.value = 'Поиск';
				}
		})
})
