// This array just makes it easier to indicate on the html page which
// language should be selected in the pulldown
var tmCode = {};
tmCode['uk'] = 'English (GB)';
tmCode['us'] = 'English (US)';
tmCode['ie'] = 'English (GB)';
tmCode['it'] = 'Italiano';
tmCode['de'] = 'Deutsch';
tmCode['nl'] = 'Nederlands';
tmCode['fr'] = 'Fran&ccedil;ais';
tmCode['es'] = 'Espa&ntilde;ol';

var tmLangs = {};
tmLangs['Deutsch'] = 'http://www.google.de/tm_complaint.html';
tmLangs['English (GB)'] = 'http://www.google.co.uk/tm_complaint_adwords.html';
tmLangs['English (US)'] = 'http://www.google.com/tm_complaint_adwords.html';
tmLangs['Espa&ntilde;ol'] = 'http://www.google.es/tm_complaint.html';
tmLangs['Fran&ccedil;ais'] = 'http://www.google.fr/tm_complaint.html';
tmLangs['Italiano'] = 'http://www.google.it/tm_complaint.html';
tmLangs['Nederlands'] = 'http://www.google.nl/tm_complaint.html';

function tmWriteMenu(lang) {
  var tmFrmStr = '<label for="lang">Choose language</label> ' +
      '<select id="lang" name="lang" onchange="javascript:tmGoTo' +
      '(document.forms[\'lang_sel\'].elements[\'lang\'])">';

  var selectedLangUrl = tmLangs[tmCode[lang]];

  for (var l in tmLangs) {
    var url = tmLangs[l];
    var curOption = '<option value="' + url + '">' + l + '</option>';

    if (url == selectedLangUrl) {
      tmFrmStr += curOption.replace('option', 'option selected');
    } else {
      tmFrmStr += curOption;
    }
  }
  tmFrmStr += '</select>';
  document.write(tmFrmStr);
}

function tmGoTo(el) {
  window.location = el[el.selectedIndex].value;
}
