phoneSeparator = "-";
phoneSign = "00";
function updatePhone(elementId) {
  phoneNumber = document.getElementById(elementId);
  country = document.getElementById("phoneNumberCountry").value;
  city = document.getElementById("phoneNumberCity").value;
  number = document.getElementById("phoneNumberNumber").value;
  phoneNumber.value = "";
  if (country != "") {
      phoneNumber.value += phoneSign + country + phoneSeparator;
  }
  if (city != "") {
      phoneNumber.value += city + phoneSeparator;
  }
  if (number != "") {
      phoneNumber.value += number;
  }
}
function setPhone(elementId) {
  phoneNumber = document.getElementById(elementId);
  country = document.getElementById("phoneNumberCountry");
  city = document.getElementById("phoneNumberCity");
  number = document.getElementById("phoneNumberNumber");
  numberSplitted = phoneNumber.value.split(phoneSeparator);
  countrySplitted = numberSplitted[0].split(phoneSign);
  if (numberSplitted.length < 2) {
  }
  else if (numberSplitted.length < 3) {
      if (countrySplitted.length < 2) {
          city.value = numberSplitted[0];
          number.value = numberSplitted[1];
      }
      else {
          country.value = countrySplitted[1];
          number.value = numberSplitted[1];
      }
  }
  else {
      country.value = countrySplitted[1];
      city.value = numberSplitted[1];
      number.value = numberSplitted[2];
  }
}

