jQuery(document).ready(function()
{
	"use strict";
	var wcas_sec_string = wcas_countdown_product.sec_string;
	var wcas_min_string = wcas_countdown_product.min_string;
	var wcas_hour_string = wcas_countdown_product.hour_string;
	var wcas_days_string = wcas_countdown_product.days_string;
	var wcas_weeks_string = wcas_countdown_product.weeks_string;
	var serverTime = new Date(wcas_countdown_product.serverTime);
	var endtime =  new Date(wcas_countdown_product.endtime);
	var difference = parseInt(wcas_countdown_product.difference);
	var  display = document.querySelector('#clock'+wcas_countdown_product.post_id);
	var display_2 = document.querySelector('#clock'+wcas_countdown_product.post_id);
	var difference_2 = parseInt(wcas_countdown_product.difference_2);
	//start 
	if(difference >0)
	{
	 
	
	 //new
	 var end_date = new Date();
	 end_date.setSeconds(end_date.getSeconds() + difference);
	 jQuery('#clock'+wcas_countdown_product.post_id).countdown(wcsa_data_formatter(end_date), function(event) {
		  var $this = jQuery(this).html(event.strftime(''
			+ (event.offset.weeks > 0 ? '<span class="wcas_timer_date_value wcsa_weeks_value">%w</span> <span class="wcas_timer_date_label wcsa_weeks_label">'+wcas_weeks_string+'</span> ' : '')
			+ (event.offset.days > 0 ? '<span class="wcas_timer_date_value wcsa_days_value">%d</span> <span class="wcas_timer_date_label wcsa_days_label">'+wcas_days_string+'</span> ': '')
			+ (event.offset.hours > 0 ?'<span class="wcas_timer_date_value wcsa_hour_value">%H</span> <span class="wcas_timer_date_label wcsa_hour_label">'+wcas_hour_string+'</span> ': '')
			+ (event.offset.minutes > 0 ?'<span class="wcas_timer_date_value wcsa_minute_value">%M</span> <span class="wcas_timer_date_label wcsa_minute_label">'+wcas_min_string+'</span> ': '')
			+ '<span class="wcas_timer_date_value wcsa_second_value">%S</span> <span class="wcas_timer_date_label wcsa_second_label">'+wcas_sec_string+'</span>'));
		}).on('finish.countdown',function(event){setTimeout(function(){jQuery(this).parent().addClass('disabled'); location.reload();}, 5000);});
	}
										
	
	
	else if(difference_2 >0)
	{
	
	  //new
	  var end_date = new Date();
	 end_date.setSeconds(end_date.getSeconds() + difference_2);
	 jQuery('#clock'+wcas_countdown_product.post_id).countdown(wcsa_data_formatter(end_date), function(event) {
		  var $this = jQuery(this).html(event.strftime(''
			+ (event.offset.weeks > 0 ? '<span class="wcas_timer_date_value wcsa_weeks_value">%w</span> <span class="wcas_timer_date_label wcsa_weeks_label">'+wcas_weeks_string+'</span> ' : '')
			+ (event.offset.days > 0 ? '<span class="wcas_timer_date_value wcsa_days_value">%d</span> <span class="wcas_timer_date_label wcsa_days_label">'+wcas_days_string+'</span> ': '')
			+ (event.offset.hours > 0 ?'<span class="wcas_timer_date_value wcsa_hour_value">%H</span> <span class="wcas_timer_date_label wcsa_hour_label">'+wcas_hour_string+'</span> ': '')
			+ (event.offset.minutes > 0 ?'<span class="wcas_timer_date_value wcsa_minute_value">%M</span> <span class="wcas_timer_date_label wcsa_minute_label">'+wcas_min_string+'</span> ': '')
			+ '<span class="wcas_timer_date_value wcsa_second_value">%S</span> <span class="wcas_timer_date_label wcsa_second_label">'+wcas_sec_string+'</span>'));
		}).on('finish.countdown',function(event){setTimeout(function(){jQuery(this).parent().addClass('disabled'); location.reload();}, 5000);});
	}
});