function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.fadeIn('fast', function () {
			dialog.data.hide().slideDown('fast');	 
		});
	});
	
	$('#simplemodal-overlay').click(function(){
		$.modal.close();
											  });
}
$(document).ready(function () {
	$('a.modal').click(function (e) {
		e.preventDefault();
		$(this).next('.modal_big').modal({onOpen: modalOpen});
	});
	
	$('ul.triplex').each(function(){
		var liN = $(this).children('li').length;
		var x1 = Math.ceil(liN/3);
		var x2 = Math.ceil((liN-x1)/2);
		$(this).children('li').addClass('tripl_col2');
		$(this).children('li:gt('+(x1+x2-1)+')').attr('class', 'tripl_col3');
		$(this).children('li:lt('+(x1)+')').attr('class', 'tripl_col1');
		///console.log($(this).children('.tripl_col1').length, $(this).children('.tripl_col2').length, $(this).children('.tripl_col3').length)
		var col1H = 0, col2H = 0;
		$(this).children('li.tripl_col1').each(function(){
			col1H += $(this).height();
		});
		$(this).children('li.tripl_col2').each(function(){
			col2H += $(this).height();
		});
		$(this).children('li.tripl_col2:first').css('margin-top', -col1H+'px');
		$(this).children('li.tripl_col3:first').css('margin-top', -col2H+'px');
		$(this).height(col1H);
		//console.log(col1H, col2H);
		
	});
});