title: Google Book Viewer API - can't hide then show
body: <p>I'm using the Google Book Viewer API to show book previews based on metadata found on the page. This is in a system I don't control, although I can append scripts and markup. </p>
  
  <p>Only some pages contain information about books that have previews available. The book viewer is inside a div which, if the preview isn't found, is empty and looks ridiculous; so my strategy is to hide the div via CSS, then, if a preview is found, change the ID of the div so that it is no longer hidden. If I do that, though, when the div appears, the preview does not show correctly; if you zoom in and out with your browser, it does, but otherwise no.</p>
  
  <p>Here's an example of it working. (I've simplified the script--normally I traverse the page to get the metadata, whereas here I'm just supplying it in a string.) Everything is there except the CSS:
  <a href="https://googledrive.com/host/0BxoVkXnTNNDoV3NpQUtsNDEyaTQ/gbpreview.htm" rel="nofollow">https://googledrive.com/host/0BxoVkXnTNNDoV3NpQUtsNDEyaTQ/gbpreview.htm</a></p>
  
  <p>And here it is with the CSS, not working:
  <a href="https://googledrive.com/host/0BxoVkXnTNNDoV3NpQUtsNDEyaTQ/gbpreview2.htm" rel="nofollow">https://googledrive.com/host/0BxoVkXnTNNDoV3NpQUtsNDEyaTQ/gbpreview2.htm</a></p>
  
  <p>Anyone know how I might fix this, or can you think of an alternative strategy to achieve what I'm looking for?</p>
  
  <p>And here is the code:</p>
  
  <pre><code>&lt;style type="text/css"&gt;#GoogleBooksPreview {display: none;} &lt;/style&gt;
  &lt;div id="GoogleBooksPreview"&gt;
      &lt;div id="viewerCanvas" style="height: 600px;"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;var gbsWidget = document.getElementById('GoogleBooksPreview');
  function gbsFound() {
      gbsWidget.id = 'gbsFound';
  }
  function initialize() {
      var viewer = new google.books.DefaultViewer(document.getElementById('viewerCanvas'), {
          showLinkChrome: false
          });
     viewer.load(['ISBN:9780596805524', 'OCLC:502415271'], null, gbsFound);
      }
      google.load("books", "0");
      google.setOnLoadCallback(initialize);
  &lt;/script&gt;
  </code></pre>