<script>
    $(function() {
	$('a#{{css_id}}').live('click', function(ev) {
            var hiddenLink = $(this).hide();
            $(this).next('img.loading').show();
            ev.stopPropagation();
            ev.preventDefault();
            var href = $(this).attr("href");
            var dia = $('<div/>');

	    dia.load( href + " #create-event", null, function() {
		var title = "Add Event";
                dia.dialog({
                    width:550, height:525, dialogClass:'dialog', position:['right','bottom'], 
                    show:'slide', hide: 'slide', title:title, draggable:false, resizeable:false, 

                    open: function() { 
                        hiddenLink.show();
                        $('img.loading').hide();

                        var datepicker = $("input#id_start_0, input#id_end_0").datepicker({});

                        var timepicker = $('input#id_start_1, input#id_end_1').timepickr({
                            handle: '#trigger-test',
                            convention: 24
                        });

                    },
                    
                    beforeclose: function() { 
                        dia.empty();
                        dia.remove();
                    }
                });
	    });
	});
    });


</script>
