(function (){
  if (document.getElementById && document.getElementsByTagName) {
    var country_ul = document.getElementById('country_ul');
    if (!country_ul) {
      return null;
    }

    var buf = '';
    buf += ('      <form name="Fo1">\n');
    buf += ('        <div class="AreaHeader"><label for="COUNTRY">Asia-Pacific Sites</label></div>\n');
    buf += ('            <p style="padding-left: 5px; padding-bottom: 0px;">Select Country or Area</p>\n');
    buf += ('        <div class="contentBox" style="padding: 5px; text-align: right;">\n');
    buf += ('            <select style="float: left" class="txt-form" name="COUNTRY" id="COUNTRY">\n');

    var list = country_ul.getElementsByTagName('A');
    for (var i = 0; i < list.length; i++) {
      var a = list[i];
      buf += '<option value="'+a.href+'">'+a.innerHTML+'</option>\n';
    }

    buf += ('              <option value="default3">--------------</option>\n');
    buf += ('              <option value="/tapl/" selected="selected">Asia-Pacific</option>\n');
    buf += ('            </select>\n');
    buf += ('            <input style="float: right" type="button" value="Go" class="txt-form select-country-button" onClick=\'juRi21("Fo1","COUNTRY")\'>\n');
    buf += ('        </div>\n');
    buf += ('        <div style="clear: both; height: 0; padding: 0; margin: 0; line-height: 0"></div>\n');
    buf += ('      </form>\n');
    document.write(buf);

    if (window.location.href) {
      var country = function(s){
        var val;
        if (s.match("/tapl/([^/]+)")) {
          val = RegExp.$1;
        }
        return val;
      }

      var u = window.location.href;
      var c = country(u);

      if (c) {
        var f = document.forms['Fo1'].elements['COUNTRY'];
        var o = f.options;
        var found = null;
        for (var i = 0; i < o.length; i++) {
          if (country(o[i].value) == c) {
            found = i;
            break;
          }
        }
        if (found != null) {
          o[f.selectedIndex].selected = false;
          o[found].selected = true;
        }
      }
    }
  }
})()

