jQuery(document).ready(function ($) {
	if ($("#_llms_engagement_delay").length) {
		var deltime = $("#_llms_engagement_delay").val();
		if (deltime == "") {
			$("._llms_engagement_delay_day").val(0);
			$("._llms_engagement_delay_hour").val(0);
			$("._llms_engagement_delay_minute").val(0);
			$("._llms_engagement_delay_second").val(0);
		} else {
			var day = parseInt(deltime);
			deltime -= day;
			deltime *= 86400;
			var hour = parseInt(deltime / 3600);
			deltime %= 3600;
			var minute = parseInt(deltime / 60);
			deltime %= 60;
			$("._llms_engagement_delay_day").val(day);
			$("._llms_engagement_delay_hour").val(hour);
			$("._llms_engagement_delay_minute").val(minute);
			$("._llms_engagement_delay_second").val(Math.round(deltime));
		}
		$("._llms_engagement_delay_day, ._llms_engagement_delay_hour, ._llms_engagement_delay_minute, ._llms_engagement_delay_second").change(function () {
			var day = parseInt($("._llms_engagement_delay_day").val());
			var hour = parseInt($("._llms_engagement_delay_hour").val());
			var minute = parseInt($("._llms_engagement_delay_minute").val());
			var second = parseInt($("._llms_engagement_delay_second").val());
			if (day == NaN) {
				day = 0;
			}
			if (hour == NaN) {
				hour = 0;
			}
			if (minute == NaN) {
				minute = 0;
			}
			if (second == NaN) {
				second = 0;
			}
			var timeinday = day * 86400;
			timeinday += hour * 3600;
			timeinday += minute * 60;
			timeinday += second;
			timeinday = timeinday / 86400;
			$("#_llms_engagement_delay").val(timeinday);
		});
	}
});