$('#calendar').hide();
    $editor.show();
  }

  // detect escape key
  $('body').keydown(function(e){
    var code = e.keyCode || e.which;
    if (code == 27 && g_editorState) {
      if (g_editorState.cropping) {
        hideCropper();
      } else {
        hideEditor();
      }
    }
  });

  // setup cropper
  var $cropper = $('#cropper');
  var $cropperworkarea = $('#cropper-work-area');
  var $cropperimage = $('#cropper-image');
  var $cropperhandleleft = $('#cropper-handle-left');
  var $cropperhan