
function disablePage ()
{
	var disabler = $('<div></div>').attr('id', 'forms-disabler');

	disabler.show().css({
		position: 'fixed',
		left: '0',
		top: '0',
		right: '0',
		bottom: '0'
	});

	disabler.appendTo('body');
}

function popup_create (e)
{
	$.get (this.href, function (data) {
		var id = new Date().getTime ();
		var title = data.match ('<h1[^>]*>([^<]+)</h1>')[1];
		data = data.replace (/(<h1[^>]*>[^<]+<\/h1>)/, '');
		var html = '<div id="popup-' + id + '" style="display: none; text-align: left;">' + data + '</div>';
		$('body').append (html);
		$('#popup-' + id).dialog({
			'autoOpen': true,
			'width': '600px',
			'title': title,
			'buttons': {
				'Zavřít': function () { $(this).dialog ('close'); },
			},
			'close': function () { $(this).remove (); }
		});
	});

	return false;
}

$('.popup').live ('click', popup_create);


$(document).ready ( function () {
	if ( $('textarea.rich').tinymce ) $('textarea.rich').tinymce({
		script_url : '/tiny_mce/tiny_mce.js',
		theme : "advanced",
		entities: ''
	});
});

$('form').live ('submit', disablePage);

