var translators = {
    'google-ru' : 'http://translate.google.com/translate?hl=ru&sl=ja&tl=ru&u=',
    'google-en' : 'http://translate.google.com/translate?hl=ru&sl=ja&tl=en&u=',
    'excite-en' : 'http://www.excite-webtl.jp/world/english/web/body?wb_lp=JAEN&wb_dis=2&wb_url='
};

var current_translator;
var description_height;

function load_translation(translator) {
  item_src = "http://"+(document.location.host)+"/items/"+ item_id +"/description";
  src = translators[translator] + item_src;

  iframe = '<iframe border="0" name="excite_header" frameborder="0" noresize="noresize" cellspacing="0" ' 
    + 'style="border: none; padding: 0; margin: 0; width: 100%; height: ' 
    + description_height +'px" src="' + src + '"></iframe>';

  $j('#description-' + translator).html(iframe);
}


function switch_translator(translator) {
  if (!has_translation(translator)) {
    load_translation(translator);
  }

// <title>
        $j('#title-0').html('<iframe border="0" style="width:100%;border:none;height:30px;" src="'+translators['excite-en']+"http://"+(document.location.host)+"/items/"+ item_id +"/titleexcite"+'"></iframe>');
// </title>
  if (current_translator != translator) {
    $j('#description-' + current_translator).toggle(false);
  }

  $j('#description-' + translator).toggle();  
  current_translator = translator;
}

function has_translation(translator) {
  return ($j('#description-' + translator).html() != "");
}

$j(document).ready(function () {
  description_height = $j('#description-ja').height() + 200;
  $j('#description-ja').css('display', 'none');

  $j('#google-ru,#google-en,#babelfish-en,#excite-en').click(function() {
     switch_translator($j(this).attr('id'));
  });

  current_translator = 'google-ru';
  switch_translator(current_translator);
});

