{
  //
  // get the url and blow /jp off of the pathname, regardless is whether or
  // not it was there
  //
    var href = String(window.location);
    var pathname = String(window.location.pathname);
    var search = String(window.location.search);
    var hash = String(window.location.hash);
    var re = RegExp('^//*jp', 'i');
    var nothing = String('');
  //
  // calculate en and jp urls based off of '/jp'-less url
  //
    var basename = pathname.replace( re, nothing );
    var en = basename + search + hash;
    var jp = '/jp' + en;
  //
  // find the translation widget
  //
    var translate = $('#translate');
  //
  // find the translation links in the widget - add the appropriate links to the 'a' elements
  //
    translate.find('.lang').each(function(){
      var lang = $(this);
      var link = lang.find('a:first');

      if(lang.hasClass('en')){
        link.attr( 'href', en );
      }
      if(lang.hasClass('jp')){
        link.attr( 'href', jp );
      }
    });
});
