// JavaScript Document

$(document).ready(function() {
	
	//console.log($.cookie("adultflag"));
	var nowpage = $("body").attr("class");
	
	//console.log(nowpage)
	if(nowpage == "home"){//homeの場合
	
		resizeWindow();
		
	}
	

	//cookieがセットされていなければ、年齢確認表示
	if ($.cookie("adultflag") ){

	}else{
		
		resizeWindow();
		
		var cssObj = {
		  display: "block",
		  height: $("#wrapper").height()
		}
		
		$(".agecheckwrapper").css(cssObj);
		
		
//		$("#wrapper").css("display","block");
//		$(".imgBoxH").imgAnim({anim:"slow", interval:"8000"});
	}

});



function agecheck(flag){
	

	
	if(flag){
		//header("Location: $url");
		callbackEvent();
		//console.log("成人")
		setcookie();
	   
	}else{
		errormsg = "<img src='/common/images/top_txt_caution.gif' alt='このサイトは20歳未満の方はご利用できません' width='262' height='12' />";
		$(".error").empty();
		$(".error").append(errormsg);
		//console.log("子供")
		//pageEcho($errormsg);
	}

}



function agecheck_110617(flag){
	
	if(flag == "s"){
	  birthy = $('#birthy-s').val();
	  birthm = $('#birthm-s').val();
	  birthd = $('#birthd-s').val();
	}else{
	  birthy = $('#birthy-l').val();
	  birthm = $('#birthm-l').val();
	  birthd = $('#birthd-l').val(); 
	}
	
	//年齢計算
	today = new Date();
	var today=new Date();
	today=today.getFullYear()*10000+today.getMonth()*100+100+today.getDate()
	birthday=parseInt(birthy+""+birthm+""+birthd);
	
	nenrei = Math.floor((today-birthday)/10000);
	
	//alert(nenrei)
	//echo $nenrei;
	
	if(nenrei > 19){
		//header("Location: $url");
		callbackEvent();
		//console.log("成人")
		setcookie();
	   
	}else{
		errormsg = "<img src='/common/images/top_txt_caution.gif' alt='このサイトは20歳未満の方はご利用できません' width='262' height='12' />";
		$(".error").append(errormsg);
		//console.log("子供")
		//pageEcho($errormsg);
	}

}



function setcookie(){
	$.cookie("adultflag", "true", { expires:7, path: '/'}); //7日間
	//console.log($.cookie("adultflag"))
}

function callbackEvent(){//判別後の処理
	
	var nowpage = $("body").attr("class");
	//console.log(nowpage)
	if(nowpage == "home"){//homeの場合
	
		location.href = "news/index.php";
		
	}else{//それ以外の場合
	
	  var cssObj = {
		display: "none"
	  }
	  $(".agecheckwrapper").css(cssObj);
	  
	  
	  
	}
	
}


function resizeWindow(){
	window.resizeTo(1010,screen.availHeight)	
}
