$(document).ready( function() {
	$("a.submit").click( function(e) {
		e.preventDefault();
		submit($(this).parents('form:first'), $(this).attr("data-action-url"));
		return false;
	});

	$("a.agreement").click( function(e) {
		e.preventDefault();
		var message = $(this).find("#message").attr("value");
		if ($("#agree") != null && $("#agree").attr("checked") == true) {
			submit($(this).parents('form:first'), $(this).attr("data-action-url"));
			return false;
		} else {
			alert(message);
			return false;
		}
	});

	$("a.agr").click( function(e) {
		e.preventDefault();
		var message = $(this).find("#message").attr("value");
		if ($("#agree") != null && ($("#agree").attr("checked") == true || $("#agree").attr("checked") == 'checked')) {
			submit($(this).parents('form:first'), $(this).attr("data-action-url"));
			return false;
		} else {
			alert(message);
			return false;
		}
	});

	$("a.confirm").click( function(e) {
		e.preventDefault();
		var message = $(this).find("#message").attr("value");
		if (message == "") {
			message = "宜しいですか？";
		}
		if ($(this).attr("data-action-url") && confirm(message)) {
			submit($(this).parents('form:first'), $(this).attr("data-action-url"));
			//confirmも一回だけ実行とする.
			$(this).removeAttr("data-action-url");
			return false;
		} else {
			return false;
		}
	});

	$("a.onetime").click( function(e) {
		e.preventDefault();
		if ($(this).attr("data-action-url")) {
			submit($(this).parents('form:first'), $(this).attr("data-action-url"));
//			$(this).attr("href", "javascript:void(0);");
			$(this).removeAttr("data-action-url");
			return false;
		} else {
			return false;
		}
	});

})

function submit(form, action) {
	form.attr("action", action);
	form.attr("method", "post");
	var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;
	if(IE6){
		/*@cc_on
		setTimeout(function(){form.submit();}, 100);
		@*/
	}else{
		form.submit();
	}
}
