Add onChange to Google Translate with jQuery and jQuery Tools

Add onChange to Google Translate with jQuery and jQuery Tools

I've got a page that uses the Overlay feature of jQuery Tools to open an overlay with Google Translate inside the overlay. Once the overlay opens, I can select a language and the page is translated. I then have to click the X to close the overlay. What I'd like to do is have the overlay close automatically once a language has been selected. I'm not sure exactly how to do this. Here is my code:

  1. <html>
  2. <head>
  3. <!-- Load jQuery -->
  4. <script type="text/javascript" src="./Resources/jquery.min.js"></script>
  5. <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script> 
  6. <link rel="stylesheet" href="screen.css" type="text/css">
  7. <link rel="stylesheet" href="overlay-apple.css" type="text/css">
  8.         <!--[if lt IE 7]>
  9.         <style>
  10.           div.apple_overlay {
  11.             background-image:url(overlay_IE6.gif);
  12.             color:#fff;
  13.           }
  14.  
  15.           /* default close button positioned on upper right corner */
  16.           div.apple_overlay div.close {
  17.             background-image:url(overlay_close_IE6.gif);
  18.           }
  19.         </style>
  20.         <![endif]-->
  21. </head>
  22.  
  23. <body>
  24.         <div id="user">
  25.             <div id="apple">
  26.             <img src="translate.png" border="0" class="iconsleft" rel="#photo1" />
  27.             </div>
  28.         </div> 
  29.         <!-- overlay for the first trigger. id matches the rel- attribute -->
  30.         <div class="apple_overlay" id="photo1">
  31.           <div class="details">
  32.             <h2>Translate</h2>
  33.             <div id="google_translate_element"></div><br />
  34.           </div>
  35.         </div>

  36. <div class="content">
  37. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. 

  38. </div>

  39. <!-- make all links with the 'rel' attribute open overlays -->
  40. <script>
  41.     $(function () {
  42.         $("#apple img[rel]").overlay({ effect: 'apple', mask: { color: '#DCDCDC', loadSpeed: 200, opacity: 0.8 }, closeOnClick: true });
  43.          
  44.     });
  45.    
  46.     $(document).click(function () {
  47.         $('.simple_overlay:visible .close').click();
  48.     });
  49. </script>
  50. <script type="text/javascript">
  51.     function googleTranslateElementInit() {
  52.         new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element');

  53.     }
  54. </script><script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> 

  55. </body>
  56. </html>

Any help would be appreciated.

-Mitch