$(function() {
	// 連携キット、local時はexit
	if ($.LiVE.bdkit && location.protocol=="file:") return;
	
	var $counter = $.LiVE.Elements.WIDGETS.counter.find(".countdown_l_b");
	$counter.each(function() {
	
		var id = $(this).parent().attr("id"),
			data = $.LiVE.widget[id].data,
			targetDate = new Date(data.set[0],data.set[1]-1,data.set[2],data.set[3],data.set[4]),
			_counter = $("#counter-" + id);
		
		_counter.addClass("counter-days");
		_counter.countdown({ until: targetDate, onExpiry: countend, layout: '<p>{dn}<br><span class="counterData">Days</span></p><p>{sep}{hnn}<br><span class="counterHour">Hours</span></p><p>{sep}{mnn}<br><span class="counterMin">Minutes</span></p><p>{sep}{snn}<br><span class="counterSec">Seconds</span></p>' });
		
		var w = 0;
		_counter.find('p').each(function(){
			w += $(this).width();
		});
		_counter.width(w);
		
		function countend() {
			if (data.action==1 && $.LiVE.mode.name == "default") {
				if (data.window) {
					var tada = window.open(data.url, "LiVEwindow");
					tada.focus();
				}
				else location.href = data.url;
			}
		}
	});
});