<!--prouct-count-->


<div class="counter_box">

  <input type="hidden" class="timer_time_reset_day_{{ section.id }} timer_time_{{ section.id }}" value="120" />                 

  <script>
    Number.prototype.padLeft = function(base,chr){
      var  len = (String(base || 10).length - String(this).length)+1;
      return len > 0? new Array(len).join(chr || '0')+this : this;
    }

    // setting time reset every day
    var resttime_{{ section.id }}="{{block.settings.enable_timer_reset_every_day}}";
    var someDate = new Date();	
    var ddNextDays = someDate.getDate()+1;
    var dd = someDate.getDate();
    var mm = someDate.getMonth()+ 1;
    var y = someDate.getFullYear();
    var H=someDate.getHours().padLeft(); 
    var m=someDate.getMinutes().padLeft(); 
    var s=someDate.getSeconds().padLeft(); 

    var NextDate = new Date(Date.now()+1*24*60*60*1000);
    var ddN = NextDate.getDate();
    var mmN = NextDate.getMonth()+ 1;
    var yN = NextDate.getFullYear();

    var nextdayDate = yN+'/'+mmN+'/'+ddN;
    var startdayDate = y + '/'+ mm + '/'+ dd;
    var NowTime=H+':'+m+':'+s;
    var TargetDate_{{ section.id }}=nextdayDate+" "+resttime_{{ section.id }};
    var StartDate_{{ section.id }}=startdayDate+" "+resttime_{{ section.id }};
    var timeDate_{{ section.id }}='';
    if(NowTime < resttime_{{ section.id }}) {
      timeDate_{{ section.id }}=StartDate_{{ section.id }};
    } else{

      timeDate_{{ section.id }}=TargetDate_{{ section.id }};
    }

    // start time with time diff.

    var remainderTimeset ="86400";    
    remainderTime= remainderTimeset*1000;

    var ddd = new Date();
    ddd.setTime(ddd.getTime());
    var startTime1=ddd.toGMTString();	                    
    var date1 = new Date(startTime1);
    var date2 = new Date(timeDate_{{ section.id }});
    var timeDiff = Math.abs(date2.getTime() - date1.getTime());
    var diffDays_{{ section.id }} = Math.ceil(timeDiff / (1000)); 
    $(".timer_time_reset_day_{{ section.id }}").val(diffDays_{{ section.id }});    

    var getSecond=remainderTimeset/left_number;

    var secondDiff=parseInt(diffDays_{{ section.id }})+4;

    setTimeout(function(){
      location.reload(true);
    }, secondDiff*1000)


  </script>



  {{ 'jquery.countdownTimer.js' | asset_url | script_tag }}

  <script>
    function timer_home(){

      $('#feature_timer_1_{{ section.id }}').countdowntimer({
        dateAndTime :  timeDate_{{ section.id }} ,
        size : "lg",
        regexpMatchFormat: "([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})",
        regexpReplaceWith: "<samp>$1</samp><span>:</span><samp>$2</samp><span>:</span><samp>$3</samp><span>:</span><samp>$4</samp>" });

    }
    $(document).ready(function() {
      timer_home();
    });
    $(document).on('shopify:section:select', function(e){
      timer_home();
    });
    $(document).on('shopify:section:deselect', function(e){
      timer_home();
    });
  </script>

  <table id="timertwohour">

    <tr>
      <td><span class="cokies1_timer" id="feature_timer_1_{{ section.id }}"></span></td>
    </tr>

    <tr>
      <td>
        <span class="home_tm_lbl_cok">{{ 'products.timer.day' | t }}</span>
        <span class="home_tm_sap_cok">&nbsp;</span>
        <span class="home_tm_lbl_cok">{{ 'products.timer.hour' | t }}</span>
        <span class="home_tm_sap_cok">&nbsp;</span>
        <span class="home_tm_lbl_cok">{{ 'products.timer.minute' | t }}</span>
        <span class="home_tm_sap_cok">&nbsp;</span>
        <span class="home_tm_lbl_cok">{{ 'products.timer.second' | t }}</span>
      </td>
    </tr>
  </table>

</div>




 