function ContactController(){this.init();}

ContactController.prototype = {
	
	init : function() {
		this.setEvents();
		$("#form1").validate();
	},
	
	setEvents : function() {
		$("#sendButton").click($.proxy(this.onSendButtonClicked, this));
	},
	
	onSendButtonClicked : function(e){
		if(confirm("この内容で送信します。 よろしいですか？")){
			$(e.target).disable();
			var url = "/contacts/send_ajax";
			$.ajax(url, {
				data : $("#form1").serialize(),
				error : function(req, status, ex){
					alert(req.responseText);
				},
				success : function(data, status, req){
					alert("お問い合わせを送信しました。 \r\nトップページに戻ります。");
					//document.location.href = document.location.href;
					document.location.href = "/"
				},
				complete : function() {
					$(e.target).enable();
				}
			});
		}
		return false;
	}
}
