
// whh 2019.12.22    add/edit the contacts
// whh 2020.01.07    manages fields displayed for edit contacts and sets the forms to contacts.php

function editContacts(){

console.log("Running - editContacts.js");

  //clear data
  document.getElementById("phoneNumber").innerHTML = "&nbsp;";
  document.getElementById('newWindows').innerHTML = "&nbsp;";
  // document.getElementById("phoneNumberSource").innerHTML = "<br>";

  // set element to display
  document.getElementById("sms").style.display = "block";
  document.getElementById("phone").style.display = "none";
  document.getElementById("numpad").style.display = "block";
  document.getElementById("selectNUM").style.display = "block";
  document.getElementById("newPhoneList").style.display = "none";
  document.getElementById("selectContact").style.display = "block";
  document.getElementById("contactSubmit").style.display = "block";
  document.getElementById("firstName").style.display = "block";
  document.getElementById("lastName").style.display = "block";
  document.getElementById("type").style.display = "block";
  document.getElementById("typeText").style.display = "block";
  document.getElementById('typeDelete').style.display = "block";
  document.getElementById('showNotes').style.display = "block";
  document.getElementById('showMail').style.display = "block";
  document.getElementById('notes').style.display = "block";
  document.getElementById('mail').style.display = "block";
  document.getElementById('contactAction').style.display = "block";
  document.getElementById('contactDelete').style.display = "block";



  // make this input required for this useage set to true
  document.getElementById("recipient").required  = false;

  document.getElementById("messageText").style.display = "none";

  document.getElementById('phoneNumber').innerHTML = "Contacts";

// direct form to contacts.php from default didww.php
  document.getElementById('ajax-contact').action = "contacts.php";
  document.getElementById("firstName").value = "";
  document.getElementById('lastName').value = "";
  document.getElementById("mail").value = "";
  document.getElementById('notes').value = "";
   document.getElementById('recipient').value = "";

  loadContactId(); // load select list from contacts.json
  loadPhoneNumbers(); // load select phone numbers from contacts.json

  var backNumber3 = " <div class='row phonenumbers' style='position:fixed; z-index:9999; background-color:rgba(0, 0, 0, 0)!Important; margin-top:-20px; width:100%;'> <div class='col-6' style=' align-text:left !important;  background-color:rgba(0, 0, 0, 0)!Important;'> <button class='btn btn-link backarrow' style='background-color:rgba(0, 0, 0, 0) !Important;' type='button' onClick='newMessages()' ><span class='glyphicon glyphicon-backward'></span></button></div> ";
  document.getElementById("backContact").style.display = "block";
  document.getElementById("backContact").innerHTML = backNumber3;


  // back button to numbers under the current source
  // var backNumber = "<div class='row'><div class='col-4 p-2'><input class='btn btn-outline-secondary' style='color:white'' type='button' value='Back' onClick='newMessages()'></input></div>";
  // document.getElementById("newWindows").innerHTML += backNumber;

};
