jQuery(document).keydown(function(e) {
  if (e.which == 27) {
    hideModal();

    return false;
  }
});

function showModal(url) {
  if (!(jQuery('#modal').length)) {
    jQuery('body').prepend('<div id="modal" style="display: none">  <div class="blocker">&nbsp;</div>  <div class="wrapper">    <div class="top">&nbsp;</div>    <a class="close" href="#" onclick="hideModal(); return false;">&nbsp;</a>    <div id="ajax" class="content"></div>    <div class="bottom">&nbsp;</div>  </div></div>');
  }

  jQuery.get(url, function(data){
    jQuery('#modal').show();
    jQuery('#modal #ajax').html(data).parent().show();
    jQuery('#modal #ajax :input:visible:enabled:first').focus();
  });
  
  return false;
}

function hideModal() {
  jQuery('#modal').fadeOut('slow');
  
  return false;
}

function refreshPage() {
  window.setTimeout('location.reload(true)', 200);
}
