title: How to base64 encode inside of javascript
body: <p>I am trying to implement a simple script on a site that will return base64 encoded information from google's ajax API.  This is what I am playing with so far:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://www.google.com/jsapi?key=ABQIAAAA0duujonFsEX871htGWZBHRS76H0qhS7Lb-D1Gd0Mnaiuid8Z7BQIyz2kMpojKizoyiCQA4yRkKAKug" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    jQuery(document).ready(function() {
      var location = 'Unable to determine your location.';
      if (google.loader.ClientLocation) {
        var loc = google.loader.ClientLocation;
        location = 'Country: &lt;strong&gt;' + loc.address.country + '&lt;/strong&gt;, Region: &lt;strong&gt;' + loc.address.region + '&lt;/strong&gt;, City: &lt;strong&gt;' +
                   loc.address.city + '&lt;/strong&gt;, Lat/Long: &lt;strong&gt;' + loc.latitude + ', ' + loc.longitude + '&lt;/strong&gt;';
      }
      jQuery('.geolocation').html(location);
    });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;span class="geolocation"&gt;&lt;/span&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It returns the info I am trying to get properly, but I need to base64 encode the separate parts such as country, region, city, lat and longitude.  In php it would be simple, but I cannot figure out how to do it in javascript.  Any help would be appreciated.</p>