function beginRegister() {
	$("#register").submit();
}

function showMailDialog() {
	$("#mailDialog").dialog({
		modal: true,
		width: 480
	});
	$("#mailDialog").dialog("open");
}

function mail() {
	selectMailContent("自分たちだけのオリジナルTシャツやチームTシャツをみんなで一緒に買ってお買い得！\n" +
			"『group割 by tmix』\nhttp://groupwari.com/");
	showMailDialog();
}

function mailItem(groupwariId) {
	$.ajax({
		url: "/item/" + groupwariId + "?mode=mail",
		success: function(text) {
			selectMailContent(text);
			showMailDialog();
		}
	});
}

function selectMailContent(text) {
	if (text) {
		$("#mailContent").text(text);
	}
	$("#mailContent").select();
}

function updateCountdown(locator, endTime) {
//	if (navigator.userAgent.indexOf("Mac OS") >= 0) {
//		$(locator + " span").css("font-size", "22px");
//	}

	var seconds = Math.floor((endTime - new Date().getTime()) / 1000);
	
	var s = seconds % 60;
	var m = Math.floor(seconds / 60) % 60;
	var h = Math.floor(seconds / 3600);
	
	$(locator + " .hour").text(h < 10 ? "0" + h : h);
	$(locator + " .minute").text(m < 10 ? "0" + m : m);
	$(locator + " .second").text(s < 10 ? "0" + s : s);
	
	if (seconds > 0) {
		setTimeout("updateCountdown('" + locator + "', " + endTime + ")", 1000);
	}
}
