$(function(){
	$('div.level_2').find('div.item_lev_2:last').addClass('nobord');
	//news
	$('div.news:last').addClass('nobord');
	//catalog 
	/*
	var maxHeigth = 0;
	var arr = new Array();
	var n = 0;
	$('div.product_inner').each(function(i,element){
		arr.push($(this));
		if ((((i+1)%3) == 0) && (i!=0)){
			$.each(arr, function(){
				if (maxHeigth < $(this).height())
				{
					maxHeigth = $(this).height();
				}
			}); 
			$.each(arr, function(k,el){
				$(el).height(maxHeigth);
			});
			arr = new Array();
			maxHeigth = 0;
		}
	});
	$('div.prod_prices_wrap').addClass('ppw_position');
	//остатки в незаполненнйо нижней линии 
	maxHeigth = 430;
	if(arr.length == 1){$(arr[0]).find('div.prod_prices_wrap').removeClass('ppw_position');}
		else {
			$.each(arr, function(){
				if (maxHeigth < $(this).height())
				{
					alert($(this).height());
					maxHeigth = $(this).height();
				}
			}); 
			$.each(arr, function(k,el){
				$(el).height(maxHeigth);
			});
		}*/
	//
		$(".fancybox-effects-a").fancybox({
				padding: 0,

				openEffect : 'elastic',
				openSpeed  : 150,

				closeEffect : 'elastic',
				closeSpeed  : 150,

				closeClick : true,

				helpers : {
					overlay : null
				}
			});
			
	$(document).on('click','a.add_to_cart',function (){
		alert('Товар "'+$(this).attr('ttl')+'" добавлен в корзину');
	});
	if ($('#item_description').height()>250){
		$('#item_description').height('250px');
		$(document).on('click', '#show_description', function(){
			var item = $(this);
			var vis = $(this).attr('vis');
			if (vis == 0){
				$('#item_description').height('auto');
				$('#item_description img').show();
				item.html('Скрыть описание');
				item.attr('vis','1');
				}else{
					$('#item_description').height('250px');
					$('#item_description img').hide();
					item.html('Показать описание полностью');
					item.attr('vis','0');
				}
		});
	}else{$('#show_description').remove();}
			
	$('[href^="http://www.amiro.ru"]').remove();
	
});

function setLinkToCart(link,id,priceNum,flag)
	{	
		$('#add_to_cart'+id).attr('href','javascript:amiCart.add("'+link+'itemId='+id+'&offset=0&catoffset=0&action=add&num='+priceNum+'"'+','+id+','+priceNum+')');
		//если флаг 1 - необходимо сменить еще и name формы с количеством
		if (flag == 1)
			{
				$('#item_form').attr('name','qty_'+id+'_'+priceNum);
				//document.getElementById("item_form").setAttribute("name",'qty_'+id+'_'+priceNum);
			}
	}
