window.logoMagnifiedExists = false;
$(document).ready(function() {
  $('#logo').hover(
    function() {
      if (!window.logoMagnifiedExists) {
        var $img = $('#logoMagnified');
        if ($img.length == 0) {
          $img = $('<img id="logoMagnified">');
          var img = $img.get(0);
          var scale = 3;
          $img.load(function() {
            var img = $(this).get(0);
            img.width = img.width * scale;
            img.height = img.height * scale;
            $(document.body).append($(this).hide());
            window.logoMagnifiedExists = true;
            $(this).css({
              position: 'absolute',
              border: '10px solid #ffffff',
              right: '50%',
              bottom: '50%',
              marginBottom: Math.round(img.height / -2) + 'px',
              marginRight: Math.round(img.width / -2) + 'px',
              zIndex: 30000
            }).fadeIn('fast');
          });
          img.src = this.src;
        }
      }
    }, function() {
      if (window.logoMagnifiedExists) {
        $('#logoMagnified').fadeOut('fast', function() {
          $(this).remove();
          window.logoMagnifiedExists = false;
        });
      }
    }
  );
});


