function olexec() {
	// Submenu collapsing
	var lis = $('#ct_menu > ul > li:has(ul)').add('#ct_menu > ul > li > ul > li:has(ul)');
	lis.find('> ul').each(function() {
		var li = $(this).parent();
		li.addClass('children');
		if(!(li.is('.path') || li.is('.active'))) {
			$(this).hide();
			li.addClass('collapsed');
		}
		if(li.is('.active')) {
			li.addClass('actchild');
		}
	});


	// Gallery image centering
	$('.gallery-images a img, .category-gallery-galleries a img').each(function() {
		$(this).css('margin-top', parseInt((190 - $(this).height())/2) + 'px');
		$(this).css('margin-left', parseInt((176 - $(this).width())/2) + 'px');
	});

	if ($.fn.lightBox)
		$('a.lightbox').lightBox();

	// Article datepicker
	if ($.ngsDatepickerCs) {
		$.ngsDatepickerCs('article_published_at');
	}

	$('a.confirm').click(function() {
		return confirm('Opravdu provést operaci?');
	});

	if ($.fn.calFill)
		calFill();

	//setColumnHeights();
	
}

function setColumnHeights()
{
	// stejna vyska sloupcu
	left = document.getElementById('content_left');
	center = document.getElementById('content_center');
	right = document.getElementById('content_right');

	if (left.offsetHeight > right.offsetHeight)
		height = left.offsetHeight;
	else
		height = right.offsetHeight;

	if (center.offsetHeight > height)
		height = center.offsetHeight;

	left.style.height = height + 'px';
	right.style.height = height + 'px';
}

function no_height(){
	$('#content_left, #content_right').css('height', 'auto');
}

function editImageDescription(o)
{
	var image_id = jQuery(o).attr("class").substr(6);
	var gallery_id = jQuery("#gallery_id").val();
	if(gallery_id) {
		var description = jQuery(o).parent().find(".description").text();
		if(jQuery("#inputOverlay").attr("id") == undefined) {
			var code = '<div id="inputOverlay"><div class="background"></div><div class="form"><div class="inner"><input type="hidden" name="id_gal" id="new_description_id_gallery" value="" /><input type="hidden" name="id_img" id="new_description_id_image" value="" /><input id="new_description" type="text" value="" /> <button onclick="editImageDescriptionConfirm(this); return false;" type="submit">Uložit</button><button onclick="editImageDescriptionClose(); return false;">Zrušit</button></div></div></div>';
			jQuery("body").append(code);
		} else {
			jQuery("#inputOverlay").show();
		}
		jQuery("#new_description").val(description);
		jQuery("#new_description_id_gallery").val(gallery_id);
		jQuery("#new_description_id_image").val(image_id);
	} else {
		alert("Prosím uložte nejprve galerii - teprve poté je možné měnit popisky.");
	}
}
function editImageDescriptionClose()
{
	jQuery("#inputOverlay").hide();
}
function editImageDescriptionConfirm(o)
{
	var image_id = jQuery("#new_description_id_image").val();
	var gallery_id = jQuery("#new_description_id_gallery").val();
	var label = jQuery("#new_description").val();
	jQuery.post(ROOT+"/gallery/ajaxSetDescription",{id_image: image_id, id_gallery: gallery_id, description: label},function(data){
		if(data=="success"){
			editImageDescriptionClose();
			jQuery(".ngs_image_gallery_wrapper .image .image_"+image_id).parent().find(".description").text(label);
		}else{
			alert("Při ukládání nastala chyba, obnovte prosím okno.");
		}
	});
}
