const firebaseConfig = {
    apiKey: "AIzaSyBqoSChuM4ax_yCDYc5R6Qh4aKkd6hwkWs",
    authDomain: "hirring-2a008.firebaseapp.com",
    databaseURL: "https://hirring-2a008-default-rtdb.firebaseio.com",
    projectId: "hirring-2a008",
    storageBucket: "hirring-2a008.appspot.com",
    messagingSenderId: "580232022328",
    appId: "1:580232022328:web:9179c8d2bab8b48069d9cd",
    measurementId: "G-LMNG6BS37N"
  };

  firebase.initializeApp(firebaseConfig);

  var contactFormDb = firebase.database().ref('Hirrings');

  document.getElementById('frmCareer').addEventListener('submit',submitForm);

  function submitForm(e){
      e.preventDefault();
      var Name = getElementVal('Name');
      var Email = getElementVal('Email');
      var ContactNo = getElementVal('ContactNo');
      var NoticePeriod = getElementVal('NoticePeriod');
      var CurrentOrganization = getElementVal('CurrentOrganization');
      var AnnualSalary = getElementVal('AnnualSalary');
      var WorkExp = getElementVal('WorkExp');
      var AreaExpertise = getElementVal('AreaExpertise');

      savedmessWorkExps(Name,Email,ContactNo,NoticePeriod,CurrentOrganization,AnnualSalary,WorkExp,AreaExpertise);

      document.querySelector('.alert').style.display = 'block';

      setTimeout(() => {
      document.querySelector('.alert').style.display = 'none';
      },2000);
      document.getElementById('frmCareer').reset();
  }

  const savedmessWorkExps = (Name,Email,ContactNo,NoticePeriod,CurrentOrganization,AnnualSalary,WorkExp,AreaExpertise) => {
      var newcontactform = contactFormDb.push();
      newcontactform.set({
          Name : Name,
          Email : Email,
          ContactNo : ContactNo,
        
          NoticePeriod:NoticePeriod,
          CurrentOrganization:CurrentOrganization,
          AnnualSalary:AnnualSalary,
          WorkExp:WorkExp,
          AreaExpertise : AreaExpertise,
      });
  };

  const getElementVal = (id) => {
  return document.getElementById(id).value;
  };
