function festReserveDialog(festivalId, button) {
	var ajax = false;
	$dialog = $('div#fsd').dialog({
		title: 'Ověření',
		modal: true,
		width: 350,
		buttons: {
			'Ověřit': function() {
				if (ajax == true) {
					return null;
				}
				$('div#fsd').find('div.alert').remove();
				if (!$(this).find('#name').val() || !$(this).find('#email').val()) {
					$('div#fsd').prepend('<div id="alert" class="alert error" style="text-align:left"><p>Položky označené hvezdičkou jsou povinné.</p></div>');
				} else {
					$('div.ui-dialog-titlebar span.ui-dialog-title').after('<span class="ui-dialog-title-progress" style="background: url(\'/images/small_loader.gif\') repeat scroll 0% 0% transparent; width: 16px; height: 11px; float: left; margin: 2px 10px;"></span>');	
					ajax = true;
					$.post('/ajax/reservecustomer/', {
						festival_id: festivalId,
						user_name: $(this).find('#name').val(),
						user_email: $(this).find('#email').val()
					}, function(data) {
						$('div.ui-dialog-titlebar span.ui-dialog-title-progress').remove();
						$('div#fsd').prepend(data);
						if ($('div#fsd div.success').length) {
							var timeout = setTimeout( 
									function() {
										clearTimeout(timeout);
										$dialog.dialog('close');
										date = new Date();
										$(button).after(date.getDate() + '.' + eval(date.getMonth()+1) + '.' + date.getFullYear());
										$(button).remove();
									}, 5000
								);
						}
						ajax = false;
					});
				}
			},
			'Zrušit': function() {
				$(this).find('form').get(0).reset();
				$(this).find('div.alert').remove();
				$(this).dialog('close');
			}
		},
		close: function() {
			$(this).find('form').get(0).reset();
			$(this).find('div.alert').remove();
		}
	});
}

$(function() {
	$('body').append('<div id="fsd" style="display:none;"><form action="" method="post"><table class="form-list"><tr><td class="label"><label for="name" class="required">* Jméno a Příjmení:</label><td class="element"><input type="text" name="name" id="name" value=""></td></td></tr><tr><td class="label"><label for="email" class="required">* E-mail</label><td class="element"><input id="email" name="email" type="text" value="" /></td></tr></table></form><div><a href="http://blog.metalshop.cz/rozcestnik-festivaly-metalshop-2010/#prubeh">Jak probíhá přihlášení?</a></div></div>');
});
