
// whh 2018.12.27
// whh 2020.01.06 to show phone numbers and manage the number pad
// whh 2020.01.12 clear all content when switched to number pad
// whh 2020.01.28 clear names fields

function newContactNumberMessages(source) {

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

  //clear data
  document.getElementById("phoneNumber").innerHTML = "&nbsp;";
  document.getElementById('newWindows').innerHTML = "&nbsp;";
  document.getElementById('notes').value = " ";
  document.getElementById('email').value = " ";
  $('#firstName').val(''); //clearing of this field
  $('#lastName').val(''); //clearing of this field


  document.getElementById("sms").style.display = "block";
  document.getElementById("firstName").style.display = "block";
  document.getElementById("lastName").style.display = "block";
  document.getElementById("phone").style.display = "none";
  document.getElementById("numpad").style.display = "none";
  document.getElementById("selectNUM").style.display = "block";
  document.getElementById("selectPhoneNumber").style.display = "block";
  document.getElementById("selectedPhone").style.display = "block";
  document.getElementById("newPhoneList").style.display = "none";
  document.getElementById("contactDelete").style.display = "none";
  document.getElementById("deleteText").style.display = "none";
  document.getElementById("typeText").style.display = "none";
  document.getElementById("messageText").style.marginTop = "-60px";
  document.getElementById("messageText").style.display = "block";



loadContactId() ;
loadPhoneNumbers() ;

// direct form to contacts.php from default didww.php
  document.getElementById('ajax-contact').action = "didww.php";


// change from "back to" to  "back" if the buton has no source phone number
//if (source != ""){var backTo = "Back to"; } else { backTo = "Back"; };
  // 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=" + backTo + " '" + backTo  + source + " onClick='phonesNumbersList(" + source + ")'></input></div>";
  var row1 = "<div class='row phonenumbers horzline p-2'>";
  var backNumber = "<div class='col-2 p-2' style='margin-top:-30px;'> <button class='btn btn-link backarrow' type='button' onClick='phonesNumbersList(" + source + ")' ><span class='glyphicon glyphicon-backward'></span></button></div> ";



  var numpadONbutton = "<div class='col-2 p-2' style='margin-top:-30px;'> <button class='btn btn-link plussign' type='button' onClick='numpadONbutton()' ><span class='glyphicon glyphicon-plus'></span></button></div>";
  var numpadOFFbutton = "<div class='col-2 p-2' style='margin-top:-30px;'> <button class='btn btn-link plussign' type='button' onClick='numpadOFFbutton()' ><span class='glyphicon glyphicon-minus'></span></button></div></div> ";

  document.getElementById("phoneNumberSource").innerHTML += row1 + backNumber + numpadONbutton + numpadOFFbutton;
  //document.getElementById("newWindows").innerHTML += backNumber;

  document.getElementById("firstName").style.display = "block";
  document.getElementById("lastName").style.display = "block";

}

  function numpadONbutton() {

  document.getElementById("firstName").style.display = "none";
  document.getElementById("lastName").style.display = "none";
  document.getElementById("numpad").style.display = "block";
  document.getElementById("selectNUM").style.display = "none";
  document.getElementById("selectPhoneNumber").style.display = "none";
  document.getElementById("showMail").style.display = "none";
  document.getElementById("showNotes").style.display = "none";
  document.getElementById("messageText").style.marginTop = "-80px";

  document.getElementById("recipient").value= "";
  document.getElementById("firstName").value= "";
  document.getElementById("lastName").value= "";
  document.getElementById("selected").value = "";
  document.getElementById("selectedPhone").value = "";
  document.getElementById("email").value = "";
  document.getElementById("notes").value = "";

  }

  function numpadOFFbutton() {

  document.getElementById("firstName").style.display = "block";
  document.getElementById("lastName").style.display = "block";
  document.getElementById("numpad").style.display = "none";
  document.getElementById("selectNUM").style.display = "block";
  document.getElementById("selectPhoneNumber").style.display = "block";
  document.getElementById("showMail").style.display = "block";
  document.getElementById("showNotes").style.display = "block";
  document.getElementById("messageText").style.marginTop = "-60px";
  }
