$(function() {
	fixHeights();
});

function fixHeights() {
	
	stevec = 0;
	maxHeight=0;
	
	var izdelki = [];
	
	$(".izdelek-displayed:visible").find("h3").each(function() {
		$(this).css("height","auto");
		izdelki[stevec]=$(this);
		
		if ($(this).height()>maxHeight) {
			maxHeight=$(this).height();
		}
		
		stevec++;
		
		if (stevec==3) {
			stevec=0;
			izdelki[0].height(maxHeight+"px");
			izdelki[1].height(maxHeight+"px");
			izdelki[2].height(maxHeight+"px");
			maxHeight=0;
		}
	
	});
	
	if (stevec==2) {
	
		izdelki[0].height(maxHeight+"px");
		izdelki[1].height(maxHeight+"px");
	
	}
	
	stevec = 0;
	maxHeight=0;
	
	var izdelki = [];
	
	$(".izdelek-displayed:visible").find("p").each(function() {
		$(this).css("height","auto");	
		izdelki[stevec]=$(this);
		
		if ($(this).height()>maxHeight) {
			maxHeight=$(this).height();
		}
		
		stevec++;
		
		if (stevec==3) {
			stevec=0;
			izdelki[0].height(maxHeight+"px");
			izdelki[1].height(maxHeight+"px");
			izdelki[2].height(maxHeight+"px");
			maxHeight=0;
		}
	
	});	
	
	if (stevec==2) {
	
		izdelki[0].height(maxHeight+"px");
		izdelki[1].height(maxHeight+"px");
	
	}	
	
	
	stevec = 0;
	maxHeight=0;
	stevec2 = 1;
	
	
	$(".izdelek-displayed:visible").each(function() {
		if ($(this).height()>maxHeight) {
			maxHeight=$(this).height();
		}
		
		stevec++;
		
		if (stevec%3==0) {
			
			$(".l"+stevec2+"-"+(stevec2+1)).height(maxHeight);
			
			$(".l"+(stevec2+1)+"-"+(stevec2+2)).height(maxHeight);
		
			stevec2=stevec2+3;
			
			maxHeight=0;
		
		}
		
	});
	
	if (stevec%3==2) {
			
			$(".l"+stevec2+"-"+(stevec2+1)).height(maxHeight);
			
			$(".l"+(stevec2+1)+"-"+(stevec2+2)).height(maxHeight);
		
			stevec2=stevec2+3;
		
	}

}
