$(document).ready(function(){	
	$(".pretty:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'normal',theme:'light_square',slideshow:4000});
	$(".pretty:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'normal',slideshow:17000});

	$('div.top_menu table td:first').addClass('first');
	
	$('div.wrapper').each(function(){
		$(this).html('<div><div><div>' + $(this).html() + '</div></div></div>');							   
	});
	
	
	function StandartHeight(Class) {
		var maxWrapperHeight = Math.max.apply(null, $(Class).map(function () { return $(this).height(); }).get()); 
	 $(Class).height(maxWrapperHeight);	
	}
	
	StandartHeight('table.tb_category_list ul.category_list li');
	StandartHeight('table.tb_items_list ul.category_list li');	 
	
	
	if ($('div.numpage').html() != null) {
		$('div.numpage').html($('div.numpage').html().replace('%pages%', '<a href="#">1</a>'));
	}
	
	/*if ($('form.search_block table td.cl_hat').html() != null) {
		$('form.search_block table td.cl_hat').html($(this).replace(' ', '&nbsp;'));
	}*/
	
	
	$('ul.items_list li').each(function() {
		if(($(this).index('ul.items_list li') + 1) % 4 == 0) { 
			$(this).addClass('item_4');
		}
	});
	
	$('ul.category_list li.item_4').after('<li class="separator"></li>');
	
	$('input[name="amount"]').bind('keyup', function() { 
		$('div#QjQ_addbasket a').attr('href', $('div#QjQ_addbasket a').attr('href') + '?amount=' + $('input[name="amount"]').val());
	});
	
	/*alert($('div.numpage div:first').width());*/
	if ($('div.numpage div:first').width() > 200) { 
		$('div.numpage div.small').html($('div.numpage div.small').html().replace('Сортировать по:', 'Сорт:'));
	}
	
}); 
