  var no_person = new Array ('client_clienttype', 'client_dic', 'client_employees');
  function initAfterLoad() {
    var cval = document.getElementById('client_country');
    var bval = document.getElementById('bef_client_country');
    if (cval && bval) {
      selected   = 0;
      for (i=0; i<cval.options.length; i++) {
	if (cval.options[i].value == bval.value) {
	  selected = i;
	}
      }
      cval.selectedIndex = selected;
    }
    chooseCountry('client_register_form');
    cval = document.getElementById('client_clienttype');
    bval = document.getElementById('bef_client_clienttype');
    if (cval && bval) {
      selected   = 0;
      for (i=0; i<cval.options.length; i++) {
	if (cval.options[i].value == bval.value) {
	  selected = i;
	}
      }
      cval.selectedIndex = selected;
    }
    elem = document.getElementById('client_personal');
    if (elem) {
      swap_person(elem.checked);
    }
  }
  function swap_person(aState) {
    for (i=0; i < no_person.length; i++) {
      elem = document.getElementById(no_person[i]);
      if (elem) {
	elem.disabled = aState ? true : false;
      }
    }
    fixResize();
  }
  function fixResize() {
    var obj_clienttype = document.getElementById('client_clienttype');
    var index          = obj_clienttype.selectedIndex;
    chooseCountry('client_register_form');
    obj_clienttype.selectedIndex = index;
  }
  function chooseCountry(strFormName) {
    var arrCompanyList;
    var obj_clienttype = document.getElementById('client_clienttype');
    var obj_country    = document.getElementById('client_country');
    var i;
    var selected;
    var disabled_status;
    if (!(obj_clienttype && obj_country)) {
      return;
    }
    obj_clienttype.selectedIndex  = 0;
    obj_clienttype.options.length = 0;
    selected = obj_country.options[obj_country.selectedIndex].value;
    if (companies[selected] != null) {
      disabled_status               = obj_clienttype.disabled;
      obj_clienttype.disabled       = false;
      obj_clienttype.options.length = 0;
      arrCompanyList = (companies[selected]).split(';');
      for (i = 0; i < arrCompanyList.length; i++) {
        tmp_data                  = (arrCompanyList[i]).split(',');
        obj_clienttype.options[i] = new Option(tmp_data[1], tmp_data[0], false, false);
      }
      obj_clienttype.disabled = disabled_status;
    }
  }
  function unmark(aWhat) {
    var obj = document.getElementById(aWhat);
    obj.value = '';
    obj.selectedIndex = -1;
  }
  function clearLang(aLang) {
    var obj_Lang = document.getElementById(aLang);
    obj_Lang.value = "";
  }
  function appendLang(aLang, aSelect) {
    var i;
    var obj_Lang   = document.getElementById(aLang);
    var obj_Select = document.getElementById(aSelect);
    var tmp;
    var uniq       = {};
    if (obj_Lang &&
        obj_Select &&
        obj_Select.tagName == 'SELECT') {
      tmp = obj_Lang.value.split(',');
      if (tmp.length > 0) {
        for (i=0; i<tmp.length; i++) {
          tmp[i] = tmp[i].replace(/[^a-z]+/g, '');
          if (tmp[i]) {
            uniq[tmp[i]] = 1;
          }
        }
      }
      if (obj_Select.multiple) {
	for (i = 0; i < obj_Select.options.length; i++) {
	  if (obj_Select.options.item(i).selected) {
	    uniq[obj_Select.options[i].value] = 1;
	  }
	}
      } else {
	uniq[obj_Select.options[obj_Select.selectedIndex].value] = 1;
      }
      obj_Lang.value = '';
      for (i in uniq) {
        if (i.length > 0) {
          obj_Lang.value += ',' + i;
        }
      }
      obj_Lang.value = obj_Lang.value.substr(1);
    }
  }