<script src="<?=base_url();?>assets/front/js/jquery-3.3.1.min.js"></script>
<script src="<?=base_url();?>assets/front/js/bootstrap.min.js"></script>
<script src="<?=base_url();?>assets/front/js/jquery-input-mask-phone-number.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    $(".enroll-btnm").click(function() /*Enroll Member*/
    {
      var form=$(this).attr('form-data');
      var mprice=$(this).attr('mem-price');
      var trno = $('#mebhid'+form).val();
      nexttr =  parseInt(trno)+1;
      var html="";
      html+='<div id="mdiv'+nexttr+form+'"><ul class="d-flex">'
      html+='<li><input type="text" name="m_first_name_'+form+'[]" placeholder="First Name*" onblur="membersum('+form+','+nexttr+form+','+mprice+')" onKeyUp="member('+nexttr+form+')" id="m_first_name'+nexttr+form+'"></li>'
      html+='<li><input type="text" name="m_last_name_'+form+'[]" placeholder="Last Name*" onKeyUp="member('+nexttr+form+')" id="m_last_name'+nexttr+form+'"></li>'
      html+='<li><input type="email" name="m_email_id_'+form+'[]" placeholder="Email Address*" onKeyUp="member('+nexttr+form+')" id="m_email_id'+nexttr+form+'"></li>'
      html+='<li><input type="text" class="yourphone" name="m_phone_no_'+form+'[]" placeholder="Phone Number*" onKeyUp="member('+nexttr+form+')" id="m_phone_no'+nexttr+form+'"></li>'
      html+='<li><input type="text" maxlength="4" name="m_ssn_'+form+'[]" placeholder="Last 4 Of SSN*" onKeyUp="member('+nexttr+form+')" class="ssn" id="m_ssn'+nexttr+form+'"></li>'
      html+='<button type="button" class="cls-btn-m" mem-price='+mprice+' form-data='+form+' target='+nexttr+form+'> X </button>'
      html+='</ul></div>'
      $(this).parent().find('.clone-append').append(html).html();
      var html2="";
      html2+='<div id="madiv'+nexttr+form+'" class="d-flex alumi-content mebdiv">'
      html2+='<div class="col-sm-8">'
      html2+='<span style="color: grey;" id="member'+nexttr+form+'"></span>'
      html2+='</div>'
      html2+='<div class="col-sm-1">$ <h id="mprice'+nexttr+form+'">0.00</h></div>'
      html2+='<span class="cls-btn-m" mem-price='+mprice+' form-data='+form+' target='+nexttr+form+'> X </span>'
      html2+='</div>';
      $('.almeb'+form).append(html2).html();
      $('#mebhid'+form).val(nexttr);
      $(document).ready(function () {
        $('.yourphone').usPhoneFormat({
          format: '(xxx) xxx-xxxx',
        });
      });
      $('.ssn').keyup(function(e){
        if (/\D/g.test(this.value)){
         this.value = this.value.replace(/\D/g,'');
       }
     });
    });
    $('body').delegate(".cls-btn-m", "click",function(){
     var btnid =$(this).attr('target');
     var form =$(this).attr('form-data');
     var mprice=$(this).attr('mem-price');
     var cursum = document.getElementById('total1'+form).innerHTML;
     var totalsum = parseInt(cursum);
     var mmprice = parseInt(mprice);
     var total = totalsum - mmprice;
     document.getElementById('mdiv'+btnid).remove();
     document.getElementById('madiv'+btnid).remove();
     document.getElementById('total1'+form).textContent = total;
   });


    $(".enroll-btnm2").click(function() /*Enroll Member*/
    {
      var form=$(this).attr('form-data');
      var mprice=$(this).attr('mem2-price');
      var trno = $('#mebhid2'+form).val();
      nexttr =  parseInt(trno)+1;
      var html="";
      html+='<div id="m2div'+nexttr+form+'"><ul class="d-flex">'
      html+='<li><input type="text" name="mp_first_name_'+form+'[]" placeholder="First Name*" onblur="memplussum('+form+','+nexttr+form+','+mprice+')" onKeyUp="memplus('+nexttr+form+')" id="m2_first_name'+nexttr+form+'"></li>'
      html+='<li><input type="text" name="mp_last_name_'+form+'[]" placeholder="Last Name*" onKeyUp="memplus('+nexttr+form+')" id="m2_last_name'+nexttr+form+'"></li>'
      html+='<li><input type="email" name="mp_email_id_'+form+'[]" placeholder="Email Address*" onKeyUp="memplus('+nexttr+form+')" id="m2_email_id'+nexttr+form+'"></li>'
      html+='<li><input type="text" class="yourphone" name="mp_phone_no_'+form+'[]" placeholder="Phone Number*" onKeyUp="memplus('+nexttr+form+')" id="m2_phone_no'+nexttr+form+'"></li>'
      html+='<li><input type="text" maxlength="4" class="ssn" name="mp_ssn_'+form+'[]" placeholder="Last 4 Of SSN*" onKeyUp="memplus('+nexttr+form+')" id="m2_ssn'+nexttr+form+'"></li>'
      html+='<button type="button" class="cls-btn-m2" mem2-price='+mprice+' form-data='+form+' target='+nexttr+form+'> X </button>'
      html+='</ul></div>'
      $(this).parent().find('.clone-append').append(html).html();
      var html2="";
      html2+='<div id="m2adiv'+nexttr+form+'" class="d-flex alumi-content meb2div">'
      html2+='<div class="col-sm-8">'
      html2+='<span style="color: grey;" id="memplus'+nexttr+form+'"></span>'
      html2+='</div>'
      html2+='<div class="col-sm-1">$ <h id="mplusprice'+nexttr+form+'">0.00</h></div>'
      html2+='<span class="cls-btn-m2" mem2-price='+mprice+' form-data='+form+' target='+nexttr+form+'> X </span>'
      html2+='</div>';
      $('.almeb2'+form).append(html2).html();
      $('#mebhid2'+form).val(nexttr);
      $(document).ready(function () {
        $('.yourphone').usPhoneFormat({
          format: '(xxx) xxx-xxxx',
        });
      });
      $('.ssn').keyup(function(e){
        if (/\D/g.test(this.value)){
         this.value = this.value.replace(/\D/g,'');
       }
     });
    });
    $('body').delegate(".cls-btn-m2", "click",function(){
     var btnid =$(this).attr('target');

     var form =$(this).attr('form-data');
     var mprice=$(this).attr('mem2-price');
     var cursum = document.getElementById('total1'+form).innerHTML;
     var totalsum = parseInt(cursum);
     var mmprice = parseInt(mprice);
     var total = totalsum - mmprice;
     document.getElementById('m2div'+btnid).remove();
     document.getElementById('m2adiv'+btnid).remove();
     document.getElementById('total1'+form).textContent = total;
   });



    $(".enroll-btnn").click(function() /*Enroll Non Member*/
    {
      var form=$(this).attr('form-data');
      var nprice=$(this).attr('nmem-price');
      var trno = $('#nmebhid'+form).val();
      nexttr =  parseInt(trno)+1;
      var html="";
      html+='<div id="ndiv'+nexttr+form+'"><ul class="d-flex">'
      html+='<li><input type="text" name="n_first_name_'+form+'[]" placeholder="First Name*" onblur="nmembersum('+form+','+nexttr+form+','+nprice+')" onKeyUp="nonmember('+nexttr+form+')" id="n_first_name'+nexttr+form+'"></li>'
      html+='<li><input type="text" name="n_last_name_'+form+'[]" placeholder="Last Name*" onKeyUp="nonmember('+nexttr+form+')" id="n_last_name'+nexttr+form+'"></li>'
      html+='<li><input type="email" name="n_email_id_'+form+'[]" placeholder="Email Address*" onKeyUp="nonmember('+nexttr+form+')" id="n_email_id'+nexttr+form+'" ></li>'
      html+='<li><input type="text" class="yourphone" name="n_phone_no_'+form+'[]" placeholder="Phone Number*" onKeyUp="nonmember('+nexttr+form+')" id="n_phone_no'+nexttr+form+'"></li>' 
      html+='<li><input type="text" maxlength="4" class="ssn" name="n_ssn_'+form+'[]" placeholder="Last 4 Of SSN*" onKeyUp="nonmember('+nexttr+form+')" id="n_ssn'+nexttr+form+'"></li>'
      html+='<button type="button" class="cls-btn-n" nmem-price='+nprice+' form-data='+form+' target='+nexttr+form+'> X </button>'
      html+='</ul></div>'
      $(this).parent().find('.clone-append').append(html).html();
      var html2="";
      html2+='<div id="nadiv'+nexttr+form+'" class="d-flex alumi-content nmebdiv">'
      html2+='<div class="col-sm-8">'
      html2+='<span style="color: grey;" id="nonmember'+nexttr+form+'"></span>'
      html2+='</div>'
      html2+='<div class="col-sm-1">$ <h id="nprice'+nexttr+form+'">0.00</h></div>'
      html2+='<span class="cls-btn-n" nmem-price='+nprice+' form-data='+form+' target='+nexttr+form+'> X </span>'
      html2+='</div>';
      $('.alnmeb'+form).append(html2).html();
      $('#nmebhid'+form).val(nexttr);
      $(document).ready(function () {
        $('.yourphone').usPhoneFormat({
          format: '(xxx) xxx-xxxx',
        });
      });
      $('.ssn').keyup(function(e){
        if (/\D/g.test(this.value)){
         this.value = this.value.replace(/\D/g,'');
       }
     });
    });
    $('body').delegate(".cls-btn-n", "click",function(){
     var btnid =$(this).attr('target');
     var form =$(this).attr('form-data');
     var nprice=$(this).attr('nmem-price');
     var cursum = document.getElementById('total1'+form).innerHTML;
     var totalsum = parseInt(cursum);
     var nmprice = parseInt(nprice);
     var total = totalsum - nmprice;
     document.getElementById('ndiv'+btnid).remove();
     document.getElementById('nadiv'+btnid).remove();
     document.getElementById('total1'+form).textContent = total;
   });


    $(".enroll-btnn2").click(function() /*Enroll Non Member 2+*/
    {
      var form=$(this).attr('form-data');
      var nprice=$(this).attr('nmem2-price');
      var trno = $('#nmebhid'+form).val();
      nexttr =  parseInt(trno)+1;
      var html="";
      html+='<div id="n2div'+nexttr+form+'"><ul class="d-flex">'
      html+='<li><input type="text" name="np_first_name_'+form+'[]" placeholder="First Name*" onblur="nmemplussum('+form+','+nexttr+form+','+nprice+')" onKeyUp="nonmemplus('+nexttr+form+')" id="n2_first_name'+nexttr+form+'"></li>'
      html+='<li><input type="text" name="np_last_name_'+form+'[]" placeholder="Last Name*" onKeyUp="nonmemplus('+nexttr+form+')" id="n2_last_name'+nexttr+form+'"></li>'
      html+='<li><input type="email" name="np_email_id_'+form+'[]" placeholder="Email Address*" onKeyUp="nonmemplus('+nexttr+form+')" id="n2_email_id'+nexttr+form+'" ></li>'
      html+='<li><input type="text" class="yourphone" name="np_phone_no_'+form+'[]" placeholder="Phone Number*" onKeyUp="nonmemplus('+nexttr+form+')" id="n2_phone_no'+nexttr+form+'"></li>' 
      html+='<li><input type="text" maxlength="4" class="ssn" name="np_ssn_'+form+'[]" placeholder="Last 4 Of SSN*" onKeyUp="nonmemplus('+nexttr+form+')" id="n2_ssn'+nexttr+form+'"></li>'
      html+='<button type="button" class="cls-btn-n2" nmem2-price='+nprice+' form-data='+form+' target='+nexttr+form+'> X </button>'
      html+='</ul></div>'
      $(this).parent().find('.clone-append').append(html).html();
      var html2="";
      html2+='<div id="n2adiv'+nexttr+form+'" class="d-flex alumi-content nmebdiv">'
      html2+='<div class="col-sm-8">'
      html2+='<span style="color: grey;" id="nmemplus'+nexttr+form+'"></span>'
      html2+='</div>'
      html2+='<div class="col-sm-1">$ <h id="nplusprice'+nexttr+form+'">0.00</h></div>'
      html2+='<span class="cls-btn-n2" nmem2-price='+nprice+' form-data='+form+' target='+nexttr+form+'> X </span>'
      html2+='</div>';
      $('.alnmeb2'+form).append(html2).html();
      $('#nmebhid'+form).val(nexttr);
      $(document).ready(function () {
        $('.yourphone').usPhoneFormat({
          format: '(xxx) xxx-xxxx',
        });
      });
      $('.ssn').keyup(function(e){
        if (/\D/g.test(this.value)){
         this.value = this.value.replace(/\D/g,'');
       }
     });
    });
    $('body').delegate(".cls-btn-n2", "click",function(){
     var btnid =$(this).attr('target');
     var form =$(this).attr('form-data');
     var nprice=$(this).attr('nmem2-price');
     var cursum = document.getElementById('total1'+form).innerHTML;
     var totalsum = parseInt(cursum);
     var nmprice = parseInt(nprice);
     var total = totalsum - nmprice;
     document.getElementById('n2div'+btnid).remove();
     document.getElementById('n2adiv'+btnid).remove();
     document.getElementById('total1'+form).textContent = total;
   });


    $(".enroll-btns").click(function() /*Enroll Employer*/
    {
     var form=$(this).attr('form-data');
     var sprice=$(this).attr('smem-price');
     var trno = $('#smebhid'+form).val();
     nexttr =  parseInt(trno)+1;
     var html="";
     html+='<div id="sdiv'+nexttr+form+'"><ul class="d-flex">'
     html+='<li><input type="text" name="s_first_name_'+form+'[]" placeholder="First Name*" onblur="smembersum('+form+','+nexttr+form+','+sprice+')" onKeyUp="employer('+nexttr+form+')" id="s_first_name'+nexttr+form+'"></li>'
     html+='<li><input type="text" name="s_last_name_'+form+'[]" placeholder="Last Name*" onKeyUp="employer('+nexttr+form+')" id="s_last_name'+nexttr+form+'"></li>'
     html+='<li><input type="email" name="s_email_id_'+form+'[]" placeholder="Email Address*" onKeyUp="employer('+nexttr+form+')" id="s_email_id'+nexttr+form+'"></li>'
     html+='<li><input type="text" class="yourphone" name="s_phone_no_'+form+'[]" placeholder="Phone Number*" onKeyUp="employer('+nexttr+form+')" id="s_phone_no'+nexttr+form+'"></li>'
     html+='<li><input type="text" maxlength="4" class="ssn" name="s_ssn_'+form+'[]" placeholder="Last 4 Of SSN*" onKeyUp="employer('+nexttr+form+')" id="s_ssn'+nexttr+form+'"></li>'
     html+='<button type="button" class="cls-btn-s" smem-price='+sprice+' form-data='+form+' target='+nexttr+form+'> X </button>'
     html+='</ul></div>'
     $(this).parent().find('.clone-append').append(html).html();
     var html2="";
     html2+='<div id="sadiv'+nexttr+form+'" class="d-flex alumi-content smebdiv">'
     html2+='<div class="col-sm-8">'
     html2+='<span style="color: grey;" id="employer'+nexttr+form+'"></span>'
     html2+='</div>'
     html2+='<div class="col-sm-1">$ <h id="sprice'+nexttr+form+'">0.00</h></div>'
     html2+='<span class="cls-btn-s" smem-price='+sprice+' form-data='+form+' target='+nexttr+form+'> X </span>'
     html2+='</div>';
     $('.alsmeb'+form).append(html2).html();
     $('#smebhid'+form).val(nexttr);
     $(document).ready(function () {
      $('.yourphone').usPhoneFormat({
        format: '(xxx) xxx-xxxx',
      });
    });
     $('.ssn').keyup(function(e){
      if (/\D/g.test(this.value)){
       this.value = this.value.replace(/\D/g,'');
     }
   });
   });
    $('body').delegate(".cls-btn-s", "click",function(){
     var btnid =$(this).attr('target');
     var form =$(this).attr('form-data');
     var sprice=$(this).attr('smem-price');
     var cursum = document.getElementById('total1'+form).innerHTML;
     var totalsum = parseInt(cursum);
     var smprice = parseInt(sprice);
     var total = totalsum - smprice;
     document.getElementById('sdiv'+btnid).remove();
     document.getElementById('sadiv'+btnid).remove();
     document.getElementById('total1'+form).textContent = total;
   });
  });
</script>

<script type="text/javascript">

  /*Reset First Field*/

  function resetm(fid,mpr) /*Reset Member*/
  {
    var crtot = $('#total1'+fid).html();
    var crpri = $('#mprice'+fid).html();
    if(crtot != 0){
      if(crpri != 0){
        var tot = crtot - mpr;
        $('#total1'+fid).html(tot);}}
        $('.resultsm'+fid).find('input').val('');
        $('#mprice'+fid).html('0.00');
        $('.resultsm'+fid).find('span').html('');
      }

      function resetm2(fid,mpr) /*Reset Member 2+*/
      {
        var crtot = $('#total1'+fid).html();
        var crpri = $('#mplusprice'+fid).html();
        if(crtot != 0){
          if(crpri != 0){
            var tot = crtot - mpr;
            $('#total1'+fid).html(tot);}}
            $('.resultsm2'+fid).find('input').val('');
            $('#mplusprice'+fid).html('0.00');
            $('.resultsm2'+fid).find('span').html('');
          }

          function resetn(fid,npr) /*Reset Non Member*/
          {
            var crtot = $('#total1'+fid).html();
            var crpri = $('#nprice'+fid).html();
            if(crtot != 0){
              if(crpri != 0){
                var tot = crtot - npr;
                $('#total1'+fid).html(tot);}}
                $('.resultsn'+fid).find('input').val('');
                $('#nprice'+fid).html('0.00');
                $('.resultsn'+fid).find('span').html('');
              }

              function resetn2(fid,npr) /*Reset Non Member 2+*/
              {
                var crtot = $('#total1'+fid).html();
                var crpri = $('#nplusprice'+fid).html();
                if(crtot != 0){
                  if(crpri != 0){
                    var tot = crtot - npr;
                    $('#total1'+fid).html(tot);}}
                    $('.resultsn2'+fid).find('input').val('');
                    $('#nplusprice'+fid).html('0.00');
                    $('.resultsn2'+fid).find('span').html('');
                  }

                  function resets(fid,spr) /*Reset Employer*/
                  {
                    var crtot = $('#total1'+fid).html();
                    var crpri = $('#sprice'+fid).html();
                    if(crtot != 0){
                      if(crpri != 0){
                        var tot = crtot - spr;
                        $('#total1'+fid).html(tot);}}
                        $('.resultss'+fid).find('input').val('');
                        $('#sprice'+fid).html('0.00');
                        $('.resultss'+fid).find('span').html('');
                      }

                      $(document).ready(function () {
                        $('.yourphone').usPhoneFormat({
                          format: '(xxx) xxx-xxxx',
                        });
                      });

                    </script>
                    <script type="text/javascript">
                      $(document).ready(function(){
                        $('input[type="checkbox"]').click(function(){
                          var inputValue = $(this).attr("value");
                          $("." + inputValue).toggle();
                        });
                      });
                    </script>
