	
//年齢認証
$(document).ready(function(){
 
	var over18 = jQuery.cookie('over18');
	//console.log(over18);
	if(over18 !== "Yes"){
		confirm("当サイトは、アダルトコンテンツを含んでいるため、18歳未満の方の閲覧は禁止しております。ご了承くださいませ。", function () {
			//alert("googleに行ってください");
			window.location.href = 'http://www.google.com/';
		});
	}
 
	$('#remove_cookie').click(function(){
		$.cookie('over18','',{ expires: 0 }); //cookie削除
		location.reload();
	});
 
});
 
function confirm(message, callback) {
	jQuery('#over18confirm').modal({
 
		opacity:80,
		overlayCss: {backgroundColor:"#000"},
 
		closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["20%",],
		overlayId: 'confirm-overlay',
		containerId: 'confirm-container', 
		onShow: function (dialog) {
			var modal = this;
 
			jQuery('.message', dialog.data[0]).append(message);
 
			jQuery('.yes', dialog.data[0]).click(function () {
				//bake cookie
				var clifetime = new Date();
				clifetime.setTime(clifetime.getTime()+(2*60*60*1000));
				jQuery.cookie('over18','Yes',{ expires: clifetime });//有効期限２時間
				//jQuery.cookie('over18','Yes',{ expires: 3 });//有効期限３日
				// close the dialog
				modal.close(); // or jQuery.modal.close();
			});
 
			jQuery('.no', dialog.data[0]).click(function () {
				// call the callback
				if (jQuery.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				//modal.close(); // or jQuery.modal.close();
			});
		}
	});
}
